Make ansible-playbook accept a roles-path argument?

10,293 views
Skip to first unread message

Daniel Upton

unread,
Feb 9, 2015, 5:48:08 PM2/9/15
to ansible...@googlegroups.com
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 :)

James Cammarata

unread,
Feb 10, 2015, 1:27:52 AM2/10/15
to ansible...@googlegroups.com
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.

--
You received this message because you are subscribed to the Google Groups "Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ansible-proje...@googlegroups.com.
To post to this group, send email to ansible...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/2a1c1c4b-9b1c-4c50-b4a4-d39d7ae28ca3%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Daniel Upton

unread,
Feb 10, 2015, 1:56:49 AM2/10/15
to ansible...@googlegroups.com
Aha! That's perfect - thanks James

Tom Bamford

unread,
Feb 10, 2015, 7:29:41 AM2/10/15
to ansible...@googlegroups.com
Thanks James, I didn't know about this. Will come in very handy!

James Cammarata

unread,
Feb 10, 2015, 8:57:17 AM2/10/15
to ansible...@googlegroups.com
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_).

Jeffrey Wen

unread,
Nov 22, 2016, 1:38:27 PM11/22/16
to Ansible Project
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.
Reply all
Reply to author
Forward
0 new messages