Exit Playbook When Any Play Fails

I have a playbook with multiple plays, where each play is executed on a different group of hosts. The behavior that I’m looking for is that if any host in any group is unreachable, the whole playbook fails immediately.

Below is a small repro of the behavior I’m seeing. Using any_errors_fatal, I’m able to prevent any steps in the first play from running if any of the hosts in the group are inaccessible. However, since all of the hosts in the second play are accessible, that play still runs.

Is there a way that I can get the playbook run to fail out as soon as the first play fails?

executing with

`

ansible-playbook playbook-test-unreachable-fatal.yml -i inventory

`

inventory:

`

[just_good_host]
localhost ansible_connection=local

[good_and_bad_hosts]
localhost ansible_connection=local
not.a.real.host.com

`

playbook-test-unreachable-fatal.yml:

`

(attachments)

inventory (130 Bytes)
playbook-test-unreachable-fatal.yml (941 Bytes)

Hi Gordon, with which version of Ansible did you see this? There were quite a few fixes in 2.1+ for this, so if you’re using 2.0.x you may want to consider trying out a more recent version.

Sorry, I should have specified this was with 2.0.1.0. You’re correct. Version 2.1.1.0 gives me the behavior I’m looking for.

Thanks!

Gordon Towne