# Forcing a stop on failure

**URL:** <https://forum.ansible.com/t/forcing-a-stop-on-failure/19581>\
**Category:** Ansible Project\
**Created:** [October 21, 2015, 6:44pm UTC](https://forum.ansible.com/t/forcing-a-stop-on-failure/19581 "2015-10-21T18:44:03Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Guy\_Matz1](https://avatars.discourse-cdn.com/v4/letter/g/b5e925/32.png) [@Guy\_Matz1](https://forum.ansible.com/u/Guy_Matz1)\
**Post date:** [October 21, 2015, 6:44pm UTC](https://forum.ansible.com/t/forcing-a-stop-on-failure/19581/1 "2015-10-21T18:44:03Z")

</div>

Hi! I have a playbook that has three plays, each one deploying software to a set of servers . . . if any of these plays fail I want the playbook to stop running. Is that what `any_errors_fatal is for? It sounds like it's close, but I can't tell if in the case of multiple plays it will work as I need.`

`So the top-level playbook is something like this:`

`- hosts: set_a`

`roles:`

`- foo`

`- hosts: set_b`

`roles:`

`- bar`

`- hosts: set_c`

`roles:`

`- baz`

`At specific points within the roles foo and bar I would like to stop the run if there are failures, most importantly, I do not want set_c to get updated. Any thoughts are greatly appreciated!`

`Thanks a lot!`

---

<div class="post-metadata">

**Author:** ![Serge\_van\_Ginderacht](https://avatars.discourse-cdn.com/v4/letter/s/b782af/32.png) [@Serge\_van\_Ginderacht](https://forum.ansible.com/u/Serge_van_Ginderacht)\
**Post date:** [October 21, 2015, 6:58pm UTC](https://forum.ansible.com/t/forcing-a-stop-on-failure/19581/2 "2015-10-21T18:58:22Z")

</div>

​There's the fail module for that, to be combined with a when: conditional.  
​

---

<div class="post-metadata">

**Author:** ![Guy\_Matz](https://avatars.discourse-cdn.com/v4/letter/g/57b2e6/32.png) [@Guy\_Matz](https://forum.ansible.com/u/Guy_Matz)\
**Post date:** [October 22, 2015, 6:28pm UTC](https://forum.ansible.com/t/forcing-a-stop-on-failure/19581/3 "2015-10-22T18:28:11Z")

</div>

Thanks! What I’m not clear on, though, is where that fail would go? or what the condition would be . . ?

`- hosts: set_b`  
`roles:`  
`- bar`

`- tasks:`

`fail: msg='i have failed you'`

`when: any tasks for set_b hosts have failed`

`- hosts: set_c`  
`roles:`  
`- baz`
