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

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:

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

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.

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