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

**When I run this:**

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

**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**




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

---
#- 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

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

the hyphen in front of roles is incorrect.

- hosts: dev
  remote_user: dude
  become: true
  roles:
    - ....

Sebastian

It works!
Thanks Sebastian! :slight_smile:

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

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