# fail a play if a hosts: value is incorrect?

**URL:** <https://forum.ansible.com/t/fail-a-play-if-a-hosts-value-is-incorrect/23990>\
**Category:** Ansible Project\
**Created:** [March 16, 2017, 10:44am UTC](https://forum.ansible.com/t/fail-a-play-if-a-hosts-value-is-incorrect/23990 "2017-03-16T10:44:00Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![zlemini](https://avatars.discourse-cdn.com/v4/letter/z/c37758/32.png) [@zlemini](https://forum.ansible.com/u/zlemini)\
**Post date:** [March 16, 2017, 10:44am UTC](https://forum.ansible.com/t/fail-a-play-if-a-hosts-value-is-incorrect/23990/1 "2017-03-16T10:44:00Z")

</div>

Is it possible to configure Ansible to fail early if a **hosts:** value is incorrect, i.e. doesn’t match a target machine in the inventory?

If the **hosts:** value is undefined like this:

`

- name: Test module(s)  
hosts:  
`

Then Ansible throws this: “ERROR! the field ‘hosts’ is required but was not set”

I am wondering if similar behaviour can be configured if the **hosts:** value is misconfigured.

---

<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:** [March 16, 2017, 1:48pm UTC](https://forum.ansible.com/t/fail-a-play-if-a-hosts-value-is-incorrect/23990/2 "2017-03-16T13:48:35Z")

</div>

It will skip the play cause no groups/hosts match.
