the option "any_errors_fatal" on a block level should (if a single node
fails) have all nodes to fail and then execute "rescue" in all nodes.
However, as per my testing I can see that that the rescue block is only
executed on the failed node only not in all nodes. I think that the proper
behaviour should be that the resuce block is executed on all the nodes in
order to implement a rollback behaviour.
This issue has been raised before as per this thread and i should be
working since ansible 2.0 but with Ansible 2.7 that i am testing with this
is not happening.
The playbook and output is as shown below
*inventroy:*
h1 ansible_connection=local
h2 ansible_connection=local
h3 ansible_connection=local
h4 ansible_connection=local
h5 ansible_connection=local
*Playbook:*
---
- hosts: all
gather_facts: no
tasks:
- block:
- fail:
when: inventory_hostname == 'h3'
rescue:
- name: Save By Rescue
debug: msg="here we are in the rescue"
any_errors_fatal: yes
Play output
PLAY [all]
************************************************************************************************************************************
TASK [fail]
***********************************************************************************************************************************
skipping: [h1]
skipping: [h2]
fatal: [h3]: FAILED! => {"changed": false, "msg": "Failed as requested from
task"}
skipping: [h4]
skipping: [h5]
TASK [Chenc another Task]
*********************************************************************************************************************
ok: [h1] => {
"msg": "Another Task"
}
ok: [h2] => {
"msg": "Another Task"
}
ok: [h4] => {
"msg": "Another Task"
}
ok: [h5] => {
"msg": "Another Task"
}
TASK [Save By Rescue]
*************************************************************************************************************************
ok: [h3] => {
"msg": "here we are in the rescue"
}
PLAY RECAP
************************************************************************************************************************************
h1 : ok=1 changed=0 unreachable=0 failed=0
h2 : ok=1 changed=0 unreachable=0 failed=0
h3 : ok=1 changed=0 unreachable=0 failed=1
h4 : ok=1 changed=0 unreachable=0 failed=0
h5 : ok=1 changed=0 unreachable=0 failed=0
--
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/7e4d3858-22af-4edc-92b0-de89021ebea5%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.