Hi Amir,
Have you taken a look at
http://docs.ansible.com/ansible/playbooks_error_handling.html#aborting-the-play?
I haven't used it myself, but i think the any_errors_fatal play option may
be what you need?

matt


On Fri, Sep 2, 2016 at 5:21 PM, Amir Samary <[email protected]> wrote:

> Hi everyone!
>
> I have a bunch of servers that need will be need frequent patching. I am
> planning on using Ansible to coordinate the patching process. The keep
> point here is that it must be an "all or nothing" patching. Either all
> servers are patched or none.
>
> The tasks I was considering for my playbook would be something like: 1 -
> Go to all servers and take an lvm snapshot 2 - IIF task 1 works on all
> servers, apply the changes 3 - If one of the hosts fails for any reason,
> roll back the snapshot on ALL NODES.
>
> The problem is that I am new to Ansible and I can't express this on a
> playbook. I have written this simple testing playbook:
>
> ---
> - hosts: all
>   strategy: linear
>
>   tasks:
>   - block:
>       - debug: msg='Testing on {{ inventory_hostname }}...'
>       - command: /home/amirsamary/activity.sh
>         changed_when: false
>     rescue:
>       - debug: msg='Rollback of {{ inventory_hostname }}...'
>   - debug: msg='I continued running tasks on {{ inventory_hostname }}...'
>
> I have two hosts on my inventory. On the first node, activity.sh returns
> true and on the second node, activity.sh returns false. So, node2 will
> always fail. The problem is that the rescue tasks will only run for the
> failed host and not for all of them (as one would expect anyway) and the
> playbook keeps running the other tasks.
>
> I have heard a lot about how good Ansible was to orchestrate complex tasks
> on thousands of servers. But I can't seem to find a way of safely implement
> an "all or nothing strategy" with it. What am I missing?
>
> --
> You received this message because you are subscribed to the Google Groups
> "Ansible Project" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to [email protected].
> To post to this group, send email to [email protected].
> To view this discussion on the web visit https://groups.google.com/d/
> msgid/ansible-project/91ea2246-79c2-4dd8-beb3-460cdcae267c%40googlegroups.
> com
> <https://groups.google.com/d/msgid/ansible-project/91ea2246-79c2-4dd8-beb3-460cdcae267c%40googlegroups.com?utm_medium=email&utm_source=footer>
> .
> For more options, visit https://groups.google.com/d/optout.
>

-- 
You received this message because you are subscribed to the Google Groups 
"Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/CAMfrScdy00mqZfdZc8Tuvndw6GTwiZXfKwYde5F5ZyoZH_svbg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to