# Option to make "No hosts matched" a FATAL error?

**URL:** <https://forum.ansible.com/t/option-to-make-no-hosts-matched-a-fatal-error/18568>\
**Category:** Ansible Project\
**Created:** [June 22, 2015, 10:05pm UTC](https://forum.ansible.com/t/option-to-make-no-hosts-matched-a-fatal-error/18568 "2015-06-22T22:05:03Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Marc\_Abramowitz](https://avatars.discourse-cdn.com/v4/letter/m/a5b964/32.png) [@Marc\_Abramowitz](https://forum.ansible.com/u/Marc_Abramowitz)\
**Post date:** [June 22, 2015, 10:05pm UTC](https://forum.ansible.com/t/option-to-make-no-hosts-matched-a-fatal-error/18568/1 "2015-06-22T22:05:03Z")

</div>

Hi all is there a way to make it so that “No hosts matched” becomes a FATAL error?

I’m using a CI job to kick off ansible to deploy something and in this case if it cannot find a host to deploy to, I want that to be a fatal error. Right now, ansible returns a zero exit code so the CI job succeeds and then people ask my why the job succeeded but the new code wasn’t deployed.

Marc

---

<div class="post-metadata">

**Author:** ![Marc\_Abramowitz](https://avatars.discourse-cdn.com/v4/letter/m/a5b964/32.png) [@Marc\_Abramowitz](https://forum.ansible.com/u/Marc_Abramowitz)\
**Post date:** [June 22, 2015, 10:41pm UTC](https://forum.ansible.com/t/option-to-make-no-hosts-matched-a-fatal-error/18568/2 "2015-06-22T22:41:51Z")

</div>

One stab at fixing this:

[https://github.com/ansible/ansible/pull/11350](https://github.com/ansible/ansible/pull/11350)

---

<div class="post-metadata">

**Author:** ![Brian\_Coca](https://avatars.discourse-cdn.com/v4/letter/b/6de8d8/32.png) [@Brian\_Coca](https://forum.ansible.com/u/Brian_Coca)\
**Post date:** [June 26, 2015, 4:11am UTC](https://forum.ansible.com/t/option-to-make-no-hosts-matched-a-fatal-error/18568/3 "2015-06-26T04:11:49Z")

</div>

lets make this a configuration option, this used to be the case and  
many people asked for it to change into a warning, as default  
localhost entry meant you always have an inventory.

---

<div class="post-metadata">

**Author:** ![Brian\_Coca](https://avatars.discourse-cdn.com/v4/letter/b/6de8d8/32.png) [@Brian\_Coca](https://forum.ansible.com/u/Brian_Coca)\
**Post date:** [June 26, 2015, 4:13am UTC](https://forum.ansible.com/t/option-to-make-no-hosts-matched-a-fatal-error/18568/4 "2015-06-26T04:13:40Z")

</div>

scratch that ... this is different, i was referring to empty  
inventories, this is about plays not matching any host.
