exit code on skipping: no hosts match

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.

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.

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.