# Exit Playbook When Any Play Fails

**URL:** <https://forum.ansible.com/t/exit-playbook-when-any-play-fails/22275>\
**Category:** Ansible Developer\
**Created:** [August 11, 2016, 3:55pm UTC](https://forum.ansible.com/t/exit-playbook-when-any-play-fails/22275 "2016-08-11T15:55:50Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Gordon\_Towne](https://avatars.discourse-cdn.com/v4/letter/g/bc8723/32.png) [@Gordon\_Towne](https://forum.ansible.com/u/Gordon_Towne)\
**Post date:** [August 11, 2016, 3:55pm UTC](https://forum.ansible.com/t/exit-playbook-when-any-play-fails/22275/1 "2016-08-11T15:55:50Z")

</div>

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](http://not.a.real.host.com)

`

playbook-test-unreachable-fatal.yml:

`

> **(attachments)**
>
> [inventory](https://forum.ansible.com/uploads/short-url/ygEnYnYdlFybzFCtFnVXqFRSX3S) (130 Bytes)  
> [playbook-test-unreachable-fatal.yml](https://forum.ansible.com/uploads/short-url/8w5oqx3TUjQGgPkzrY4naaYjvpE.yml) (941 Bytes)

---

<div class="post-metadata">

**Author:** ![James\_Cammarata](https://avatars.discourse-cdn.com/v4/letter/j/7c8e57/32.png) [@James\_Cammarata](https://forum.ansible.com/u/James_Cammarata)\
**Post date:** [August 11, 2016, 7:50pm UTC](https://forum.ansible.com/t/exit-playbook-when-any-play-fails/22275/2 "2016-08-11T19:50:14Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![Gordon\_Towne](https://avatars.discourse-cdn.com/v4/letter/g/bc8723/32.png) [@Gordon\_Towne](https://forum.ansible.com/u/Gordon_Towne)\
**Post date:** [August 11, 2016, 8:46pm UTC](https://forum.ansible.com/t/exit-playbook-when-any-play-fails/22275/3 "2016-08-11T20:46:51Z")

</div>

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
