-1

Question

Kindly explain why a directory path cannot be specified directory in the list item of roles.

- name: Test
  hosts: local
  become: true
  roles:
    - ubuntu/16/site.nginx
#    - { role: 'site.nginx', dir: 'ubuntu/16' } <---- ERROR
#    - { role: 'ubuntu/16/site.nginx' }   <--- OK

Error

ERROR! the role 'centos/16/site.nginx' was not found in ...
The offending line appears to be:

  roles:
    - ubuntu/16/site.nginx
      ^ here

Directory Structure

roles
└── ubuntu
    └── 16
        ├── site.ngnix

OK playbook

- name: Test
  hosts: local
  become: true
  roles:
    - { role: 'ubuntu/16/site.nginx' }

Result

....
PLAY RECAP *********************************************************************
localhost                  : ok=15   changed=2    unreachable=0    failed=0  

References

Community
  • 1
  • 1
mon
  • 18,789
  • 22
  • 112
  • 205
  • `dir: 'ubuntu/16'` is your own invention based on misunderstanding of the example in the manual; the problem with `- ubuntu/16/site.nginx` cannot be reproduced on Ansible 2.2.2; the answer you linked suggests using a relative path (although it's not necessary in current Ansible), which you do not even try. If you tried, you would at least show you read the answer under the question you linked. – techraf Apr 17 '17 at 04:18
  • [Same question](http://stackoverflow.com/questions/40851527/the-dir-parameter-for-calling-roles/40851941#40851941) – Konstantin Suvorov Apr 17 '17 at 06:07
  • You also commented under my answer (now deleted, because you changed the question): "*Pasted again but the same error.*" I'm afraid you did not paste anything, because the error in the question shows `the role 'centos/16/site.nginx' was not found` while you have no string `centos` in your supposed playbooks. – techraf Apr 17 '17 at 07:08
  • Possible duplicate of [Ansible: playbook calling Role in a directory that is in the roles directory](http://stackoverflow.com/questions/37355099/ansible-playbook-calling-role-in-a-directory-that-is-in-the-roles-directory) – Matthew Schuchard Apr 17 '17 at 11:32

1 Answers1

0
  1. update ansible.cfg file as below.

roles_path=roles/:roles/ubuntu/16.

  1. Specify only site.nginx under roles section in the play book.