Search code examples
ansibleansible-inventory

Ansible not seeing host list or role


When I run ansible-playbook -k configure-clish.yml I get the following errors:

I don't think it's a syntax problem because no syntax issues show in Visual Studio Code.

[WARNING]: provided hosts list is empty, only localhost is available. Note that the implicit localhost does not match 'all'

ERROR! the role 'ashwin_sid.gaia_fw1' was not found in /app/sandbox/playbooks/roles:/home/.ansible/roles:/usr/share/ansible/roles:/etc/ansible/roles:/app/sandbox/playbooks

The error appears to be in '/app/sandbox/playbooks/configure-clish.yml': line 25, column 16, but may
be elsewhere in the file depending on the exact syntax problem.

The offending line appears to be:

   'import_role:
     name: ashwin_sid.gaia_fw1
           ^ here'

This is the playbook:

- hosts: localhost
   tasks:
    - command: /bin/echo "{{ lookup('pipe','date +%Y-%m-%d_%H-%M') }}"
      register: foo

    - file:
        path: ../SHOW
        state: directory

 - hosts: ckp
   serial: 1
   gather_facts: no
   tasks:
     - name: SHOW COMMAND
       import_role:
         name: ashwin_sid.gaia_fw1
         tasks_from: setclish
       vars:
         cmdfile: configure-clish.cmd
         logdir: ../SHOW

This is the hosts file:

[ckp]
lab ansible_host=192.168.2.1

This is the ansible.cfg file:

[defaults]
roles_path = /app/sandbox/roles/ashwin_sid.gaia_fw1
inventory = /app/sandbox/hosts
host_key_checking = False
retry_files_enabled = False

Solution

  • As the error says, you don't have a role named ashwin_sid.gaia_fw1. Make sure that role is somewhere in /app/sandbox/playbooks/roles, /home/.ansible/roles, /usr/share/ansible/roles, /etc/ansible/roles, or /app/sandbox/playbooks and your issue should be fixed.