Search code examples
ansibleansible-2.xansible-inventoryansible-template

ERROR! the role Users/xxxx/ansible/roles/basic_install' was not found


i am running an ansible playbook, but it won't find my defined roles. I get the following error:

ERROR! the role 'Users/xxxx/ansible/roles/basic_install' was not found in /Users/xxxx/ansible/playbooks/roles:/Users/xxxx/.ansible/roles:/usr/share/ansible/roles:/etc/ansible/roles:/Users/xxxx/ansible/playbooks

The error appears to be in '/Users/xxxx/ansible/playbooks/byrule.yml': line 6, column 7, but may
be elsewhere in the file depending on the exact syntax problem.

The offending line appears to be:

  roles:
    - role: 'Users/xxxx/ansible/roles/basic_install'
      ^ here

I have the following ansible structure:


ansible/
  ansible.cfg
  inventory
  playbooks/
    byrule.yml
  rules/
    basic_install/
      tasks/
        main.yml
    full_install/
      tasks/
        main.yml

Content of the used playbook:

---
- name: Basic install of packages on Debian
  hosts: all
  become: true
  roles:
    - basic_install

- name: Full install of packages on Debian
  hosts: all
  become: true
  roles:
    - full_install

Best Regards

Based on the error output, i tried to give the rule as a path in the playbook, or move the rules directory into the playbooks directory, but none of them worked, i still get the same error. I would be very grateful for any help.


Solution

  • If you ever anticipate this error, the problem is that the playbooks are inside the playbooks directory, and by default ansible looks there for the roles. The correct way is to keep the playbooks at the same level as the roles directory.