Ansible-Pull – Understanding ‘Fatal: [localhost]: FAILED!’ Error

ansibleansible-playbook

What does the following message mean?

fatal: [localhost]: FAILED! => {"changed": false, "msg": "one of the following is required: name, list"}

The scenario:

I run:

$ sudo ansible-pull -C ${user}/ansible -U https://github.com/${user}/${company}/ansible.git

I get:

Starting Ansible Pull at 2018-08-22 09:31:09
/bin/ansible-pull -C ${user}/ansible -U https://github.com/${user}/${company}/ansible.git
 [WARNING]: Could not match supplied host pattern, ignoring: main
localhost  [WARNING]| SUCCESS : Your git=> {
    " version iafter": "fs too old 737822b1d4to fully s01e8f0c3b3upport the1a033be175 depth argcc1634b1c"ument.
Fal, 
    "beling back fore": "f7to full ch37822b1d40eckouts.
1e8f0c3b31a033be175cc1634b1c", 
    "changed": false, 
    "remote_url_changed": false
}
 [WARNING]: provided hosts list is empty, only localhost is available. Note
that the implicit localhost does not match 'all'
 [WARNING]: Could not match supplied host pattern, ignoring: main

PLAY [localhost] ***************************************************************

TASK [Gathering Facts] *********************************************************
ok: [localhost]

TASK [update repositories] *****************************************************
fatal: [localhost]: FAILED! => {"changed": false, "msg": "one of the following is required: name, list"}
    to retry, use: --limit @/root/.ansible/pull/main/local.retry

PLAY RECAP *********************************************************************
localhost                  : ok=1    changed=0    unreachable=0    failed=1  

Where:

$ cat local.yml 
- hosts: localhost
  become: true
  pre_tasks:
    - name: update repositories
      yum: update_cache=yes
      changed_when: False

  tasks:
    - include: tasks/packages.yml

And

$ cat tasks/packages.yml
  - name: Install packages
    yum: name={{item}}
    with_items:
    - vim
    - htop
    - mc
    - byobu

Best Answer

Your pre task with the yum module needs either the parameter name or list. You can't use the parameter update_cache alone.

You could use for example:

yum:
  name: '*'
  state: latest
  update_cache: yes

to update the cache and all packages before installing new ones.