# ERROR! the field 'hosts' is required but was not set

**URL:** <https://forum.ansible.com/t/error-the-field-hosts-is-required-but-was-not-set/32180>\
**Category:** Ansible Developer\
**Tags:** azure\
**Created:** [February 9, 2020, 9:28am UTC](https://forum.ansible.com/t/error-the-field-hosts-is-required-but-was-not-set/32180 "2020-02-09T09:28:06Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Max3](https://avatars.discourse-cdn.com/v4/letter/m/59ef9b/32.png) [@Max3](https://forum.ansible.com/u/Max3)\
**Post date:** [February 9, 2020, 9:28am UTC](https://forum.ansible.com/t/error-the-field-hosts-is-required-but-was-not-set/32180/1 "2020-02-09T09:28:06Z")

</div>

```auto
**When I run this:**

```

```auto
ansible-playbook -i host.inventory -l dev automation.yml

```

```auto

```

```auto
**I keep on getting this:**

PLAY [dev] ***********************************************************************************************************************************************************************************

TASK [Gathering Facts] ***********************************************************************************************************************************************************************
ok: [server1.westeurope.cloudapp.azure.com]
**ERROR! the field 'hosts' is required but was not set**

```

```auto

```

```auto

```

```auto

```

```auto
**# Here is my automation.yml:**

```

```auto

```

```auto
---
#- name: Prepares and installs a Jenkins automation server on azure
- hosts: dev
  remote_user: dude
  become: true

- roles:
  - cloud-init
  - set_kernel_conf
  - add-authorized-keys
  - create-root-ssh-folder
  - create-ca
  - create-local-tls-certificates
  - install_JDK
  - digicert
  - jenkins

```

```auto

```

```auto
**# Here is my host.inventory:**

```

```auto

```

---

<div class="post-metadata">

**Author:** ![Sebastian\_Meyer](https://avatars.discourse-cdn.com/v4/letter/s/779978/32.png) [@Sebastian\_Meyer](https://forum.ansible.com/u/Sebastian_Meyer)\
**Post date:** [February 9, 2020, 10:02am UTC](https://forum.ansible.com/t/error-the-field-hosts-is-required-but-was-not-set/32180/2 "2020-02-09T10:02:30Z")

</div>

the hyphen in front of roles is incorrect.

- hosts: dev  
&nbsp;&nbsp;remote\_user: dude  
&nbsp;&nbsp;become: true  
&nbsp;&nbsp;roles:  
&nbsp;&nbsp;&nbsp;&nbsp;- ....

Sebastian

---

<div class="post-metadata">

**Author:** ![Max3](https://avatars.discourse-cdn.com/v4/letter/m/59ef9b/32.png) [@Max3](https://forum.ansible.com/u/Max3)\
**Post date:** [February 9, 2020, 10:08am UTC](https://forum.ansible.com/t/error-the-field-hosts-is-required-but-was-not-set/32180/3 "2020-02-09T10:08:23Z")

</div>

**It works!**  
**Thanks Sebastian! 🙂**

On Sunday, February 9, 2020 at 11:02:36 AM UTC+1, Sebastian Meyer D

---

<div class="post-metadata">

**Author:** ![jowestco](https://avatars.discourse-cdn.com/v4/letter/j/85f322/32.png) [@jowestco](https://forum.ansible.com/u/jowestco)\
**Post date:** [February 9, 2020, 3:27pm UTC](https://forum.ansible.com/t/error-the-field-hosts-is-required-but-was-not-set/32180/4 "2020-02-09T15:27:52Z")

</div>

FYI, because the hyphen of roles was at the same level as name it was treated as a second play in the playbook. Your first play did nothing as dude against the dev hosts. Your second play applied roles to an unspecified list of hosts. Thus the error of hosts being required.

-John
