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

**URL:** <https://forum.ansible.com/t/confused-newbie-error-the-field-hosts-is-required-but-was-not-set/31054>\
**Category:** Ansible Project\
**Created:** [August 16, 2019, 1:23am UTC](https://forum.ansible.com/t/confused-newbie-error-the-field-hosts-is-required-but-was-not-set/31054 "2019-08-16T01:23:05Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![GM1](https://avatars.discourse-cdn.com/v4/letter/g/7ab992/32.png) [@GM1](https://forum.ansible.com/u/GM1)\
**Post date:** [August 16, 2019, 1:23am UTC](https://forum.ansible.com/t/confused-newbie-error-the-field-hosts-is-required-but-was-not-set/31054/1 "2019-08-16T01:23:05Z")

</div>

Hi there - first I will post my response from when I run my playbook:

ansible-playbook -vv glen.yml

ansible-playbook 2.5.2  
config file = /etc/ansible/ansible.cfg  
configured module search path = [u’/home/gmillard/.ansible/plugins/modules’, u’/usr/share/ansible/plugins/modules’]  
ansible python module location = /usr/lib/python2.7/site-packages/ansible  
executable location = /usr/bin/ansible-playbook  
python version = 2.7.15 (default, May 9 2018, 11:32:33) [GCC 7.3.1 20180130 (Red Hat 7.3.1-2)]  
Using /etc/ansible/ansible.cfg as config file

PLAYBOOK: glen.yml \*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*  
2 plays in glen.yml

PLAY [all] \*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*

TASK [Gathering Facts] \*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*  
task path: /home/gmillard/myplatform/OtherStuff/glen.yml:2  
ok: [fedoracontrol]  
META: ran handlers  
META: ran handlers  
META: ran handlers  
ERROR! the field ‘hosts’ is required but was not set

Now, I’ll post the playbook itself:

---

<div class="post-metadata">

**Author:** ![Zolvaring](https://avatars.discourse-cdn.com/v4/letter/z/ce73a5/32.png) [@Zolvaring](https://forum.ansible.com/u/Zolvaring)\
**Post date:** [August 16, 2019, 1:43am UTC](https://forum.ansible.com/t/confused-newbie-error-the-field-hosts-is-required-but-was-not-set/31054/2 "2019-08-16T01:43:15Z")

</div>

The problem in this case is just the yaml syntax. “-” denotes the start of a new item, typically in a list, so when you write:

- hosts
- name

You are actually writing two separate objects, when what you want is:

- name: “download artifactory”  
hosts: all

---

<div class="post-metadata">

**Author:** ![Zolvaring](https://avatars.discourse-cdn.com/v4/letter/z/ce73a5/32.png) [@Zolvaring](https://forum.ansible.com/u/Zolvaring)\
**Post date:** [August 16, 2019, 1:46am UTC](https://forum.ansible.com/t/confused-newbie-error-the-field-hosts-is-required-but-was-not-set/31054/3 "2019-08-16T01:46:46Z")

</div>

In regards to your second question (sorry I missed it), the module looks okay except you need to indent the module out one more indentation space:

- name:  
hosts:  
tasks:
- get\_url:  
url:

The only other thing that looks immediately wrong to me is your destination parameter – I don’t think “$PWD” will work in this case ansible won’t resolve the command as you execute it. If you are trying to put it in the current working directory of the ansible executor you can try “./” or specify the directory with set\_fact or a variable.

---

<div class="post-metadata">

**Author:** ![GM1](https://avatars.discourse-cdn.com/v4/letter/g/7ab992/32.png) [@GM1](https://forum.ansible.com/u/GM1)\
**Post date:** [August 16, 2019, 11:33am UTC](https://forum.ansible.com/t/confused-newbie-error-the-field-hosts-is-required-but-was-not-set/31054/4 "2019-08-16T11:33:44Z")

</div>

Thanks much my friend - that fixed things - for now. It’s got some other weirdness going on but I think it’s an infrastructure issue.

Glen
