# Can't fix "ERROR! the field 'hosts' is required but was not set"

**URL:** <https://forum.ansible.com/t/cant-fix-error-the-field-hosts-is-required-but-was-not-set/37336>\
**Category:** Ansible Project\
**Created:** [November 11, 2022, 12:35pm UTC](https://forum.ansible.com/t/cant-fix-error-the-field-hosts-is-required-but-was-not-set/37336 "2022-11-11T12:35:08Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Oneday\_onedayapps\_Ap](https://avatars.discourse-cdn.com/v4/letter/o/2acd7d/32.png) [@Oneday\_onedayapps\_Ap](https://forum.ansible.com/u/Oneday_onedayapps_Ap)\
**Post date:** [November 11, 2022, 12:35pm UTC](https://forum.ansible.com/t/cant-fix-error-the-field-hosts-is-required-but-was-not-set/37336/1 "2022-11-11T12:35:08Z")

</div>

![OnPaste.20221111-133457.png](https://us1.discourse-cdn.com/ansible/original/2X/5/5393ee7674bec64810be45cdff22c60df3fe4fe3.png)

---

<div class="post-metadata">

**Author:** ![utoddl](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/utoddl/32/249_2.png) [@utoddl](https://forum.ansible.com/u/utoddl)\
**Post date:** [November 11, 2022, 4:36pm UTC](https://forum.ansible.com/t/cant-fix-error-the-field-hosts-is-required-but-was-not-set/37336/2 "2022-11-11T16:36:34Z")

</div>

You have

```auto
- tasks:

```

where you should have

```auto
  tasks:

```

with no leading dash. That dash effectively starts a second play within the playbook, a play for which you have not specified “hosts:”.

---

<div class="post-metadata">

**Author:** ![Walter\_Rowe](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/walter_rowe/32/4506_2.png) [@Walter\_Rowe](https://forum.ansible.com/u/Walter_Rowe)\
**Post date:** [November 14, 2022, 2:38pm UTC](https://forum.ansible.com/t/cant-fix-error-the-field-hosts-is-required-but-was-not-set/37336/3 "2022-11-14T14:38:27Z")

</div>

Does the blank line at the top matter, or not having one is simply a best practice?

Walter
