ansible : get roles from playbook in a subfolder

You can probably use the variable roles_path. It points to the folder where your roles are stored.


As mentioned your ansible.cfg is not likely being picked up by ansible. You could test if your ansible.cfg is being picked up by setting this:

[defaults]
roles_path = ./isnasiblegettingmycfg

and checking the debug output. The ansible.cfg is looked for in:

  • ANSIBLE_CONFIG (an environment variable)
  • ansible.cfg (in the current directory)
  • .ansible.cfg (in the home directory)
  • /etc/ansible/ansible.cfg

Roles are looked for in the directory of the executed playbook, and in the directory roles/ relative to the executed playbook and roles_path. So another simple solution is:

cd ~/stack/plays/ && ln -s ../roles