# exit code on skipping: no hosts match

**URL:** <https://forum.ansible.com/t/exit-code-on-skipping-no-hosts-match/17993>\
**Category:** Ansible Project\
**Created:** [April 16, 2015, 12:16pm UTC](https://forum.ansible.com/t/exit-code-on-skipping-no-hosts-match/17993 "2015-04-16T12:16:07Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Alex\_Rodenberg1](https://avatars.discourse-cdn.com/v4/letter/a/aeb1de/32.png) [@Alex\_Rodenberg1](https://forum.ansible.com/u/Alex_Rodenberg1)\
**Post date:** [April 16, 2015, 12:16pm UTC](https://forum.ansible.com/t/exit-code-on-skipping-no-hosts-match/17993/1 "2015-04-16T12:16:07Z")

</div>

Hi

What is the reason for doing Exit code 0 on a skipping: no hosts match ?

I would really love to get a different exit code, so I get a warning if my playbook failed to run against a host…

My ansible inventory is run up against a dynamic inventory, so I need to know if the host is not available from there.

I run my playbook with:

- hosts: ‘{{ target }}’

And pass it to the playbook as --extra-vars “target=x.x.x.x”

Is there a way I don’t know about I can force an error if its not there?

My alternative is to run checks against the inventory beforehand, but if I can skip that step it would greatly simplify my task.

---

<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:** [April 16, 2015, 2:30pm UTC](https://forum.ansible.com/t/exit-code-on-skipping-no-hosts-match/17993/2 "2015-04-16T14:30:35Z")

</div>

First you can have multiple plays per run, so existing on a play not  
matching hosts might not be the correct thing.

Also that might be a 'correct' run, one case, for example, is  
'unprovisioned' hosts on a bootstraping play.

---

<div class="post-metadata">

**Author:** ![Jason\_DeTiberus](https://avatars.discourse-cdn.com/v4/letter/j/43a26b/32.png) [@Jason\_DeTiberus](https://forum.ansible.com/u/Jason_DeTiberus)\
**Post date:** [April 16, 2015, 2:57pm UTC](https://forum.ansible.com/t/exit-code-on-skipping-no-hosts-match/17993/3 "2015-04-16T14:57:11Z")

</div>

Now an interesting feature would be to be able do something like registered variables at the playbook level. Then you could have a second play using localhost that inspects the result of the previous play to determine further action or success/failure.
