I've just done some testing, and a role in the current working directory WILL be used, but only if the role cannot be found elsewhere. This is with Ubuntu 16.04 and Ansible 2.5.1.
I haven't worked out the precedence yet, but it appears to be :
- the roles directory below the directory containing the playbook
- the elements of roles_path from left to right (two elements in my case)
OR
- the elements of the DEFAULT_ROLES_PATH from left to right (three elements)
- the directory the playbook is in
- the current working directory
To test this, I put a test role in each of the eight possible locations (my CWD test was from /tmp) then renamed them all so that the playbook would be unable to find them. I then ran the playbook and got the expected failure to find the role. Then I renamed the role in each of the locations in turn, to the name expected by the playbook, checked that the playbook could find it, then renamed it away again.
One surprise was that although the comment in the distributed ansible.cfg says that the roles_path variable is for "additional paths to search for roles in", in fact roles_path will, if specified, REPLACE the defaults.
On my system the default role paths (i.e., with no roles_path specified in ansible.cfg) are ~/.ansible/roles, /usr/share/ansible/roles, and /etc/ansible/roles.
Regards, K.
On Wednesday, April 25, 2018 at 6:18:22 AM UTC+10, Karl Auer wrote: