# Any suggestions for structuring a playbook, perhaps with rescue and always?

**URL:** <https://forum.ansible.com/t/any-suggestions-for-structuring-a-playbook-perhaps-with-rescue-and-always/27702>\
**Category:** Ansible Project\
**Created:** [June 4, 2018, 3:10pm UTC](https://forum.ansible.com/t/any-suggestions-for-structuring-a-playbook-perhaps-with-rescue-and-always/27702 "2018-06-04T15:10:36Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Rick\_Williams](https://avatars.discourse-cdn.com/v4/letter/r/f17d59/32.png) [@Rick\_Williams](https://forum.ansible.com/u/Rick_Williams)\
**Post date:** [June 4, 2018, 3:10pm UTC](https://forum.ansible.com/t/any-suggestions-for-structuring-a-playbook-perhaps-with-rescue-and-always/27702/1 "2018-06-04T15:10:36Z")

</div>

Hi all,

I’m trying to sort out a playbook and have been reading about blocks, rescue, always. I’ve also tried using a handler with run\_once. But I’m still struggling.

Here’s what I’m trying to achieve:

1. I want to run some tasks on an inventory of nexus switches.
2. I want to update a mongodb collection with the result of the tasks for each switch. I’ve written a module to do this.
3. When all of the switches have been processed, I want to update the mongodb collection again with a summary of all of the results.

Does anyone have any suggestions for how to do something like this ?

This was my first attempt:
