Make ansible-playbook accept a roles-path argument?

Is it possible to pass the roles_path parameter (from ansible.cfg) or an equivalent as an argument to ansible-playbook?

My use case is: I’m using the ansible-galaxy (tool not web service) to pull my shared ansible roles from private GitHub repositories into a local directory called “vendor_roles”, and I’d like ansible playbook to look in this directory too - currently I work around this by symlinking the roles into the roles directory.

I’d also like to share this with the rest of my time without mandating a specific setting in their ansible.cfg file, which can be another barrier to entry / I’d rather give them a Makefile checked into our source control…

If this is not currently possible (browsing the source it doesn’t appear to be) would a pull request to this end likely be accepted?

Thanks :slight_smile:

Hi Daniel, you can use the environment variable ANSIBLE_ROLES_PATH=/path/to/roles in front of ansible-playbook to modify the path on the fly, without having to modify your ansible.cfg (or deploy a local cfg in the working directory). In either case, the roles path can be a colon-separated list (just like $PATH) so that it will search multiple paths.

Aha! That's perfect - thanks James

Thanks James, I didn’t know about this. Will come in very handy!

No problem. By design, every configuration option has a corresponding environment variable you can use, just look in constants.py to see them (they all start with ANSIBLE_).

Hey James,

Your solution for using ANSIBLE_ROLES_PATH works! I am having issues trying to find out where the constants.py file is that you’re talking about.