In 2.3, there’s a possible regression with any_errors_fatal and tasks in roles. https://github.com/ansible/ansible/issues/14100 says to bring the question to the list, so here I am.
In 2.3:
$ ansible-playbook -i inventory play.yml
PLAY [all] *******************************************************************************
TASK [Gathering Facts] *******************************************************************
ok: [two]
ok: [one]TASK [testrole : fail] *******************************************************************
ok: [two]
fatal: [one]: FAILED! => {“changed”: false, “failed”: true, “failed_when_result”: true, “msg”: “Failed as requested from task”}TASK [testrole : should not be reached] **************************************************
ok: [two] => {
“changed”: false,
“msg”: “Yet here I am”
}
to retry, use: --limit @/home/centos/play.retryPLAY RECAP *******************************************************************************
one : ok=1 changed=0 unreachable=0 failed=1
two : ok=3 changed=0 unreachable=0 failed=0$ cat inventory
one ansible_connection=local
two ansible_connection=local
$ cat play.yml
- hosts: all
any_errors_fatal: true
roles:- testrole
$ cat roles/testrole/tasks/main.yml
fail:
failed_when: inventory_hostname == ‘one’name: should not be reached
debug:
msg: Yet here I am
$
In 2.2:
$ ansible-playbook -i inventory play.yml
PLAY [all] *********************************************************************
TASK [setup] *******************************************************************
ok: [one]
ok: [two]TASK [testrole : fail] *********************************************************
fatal: [one]: FAILED! => {“changed”: false, “failed”: true, “failed_when_result”: true, “msg”: “Failed as requested from task”}
ok: [two]NO MORE HOSTS LEFT *************************************************************
to retry, use: --limit @/home/centos/play.retryPLAY RECAP *********************************************************************
one : ok=1 changed=0 unreachable=0 failed=1
two : ok=2 changed=0 unreachable=0 failed=0$
Thanks,
Ed