can i use a ansible.cfg var in a playbook?

92 views
Skip to first unread message

Mauro Nigrele

unread,
Jul 26, 2015, 3:08:41 PM7/26/15
to Ansible Project
Hi! 
I need to access the roles_path var which is configured in my ~/.ansible.cfg. I'm using this path because we have a main git repository with a lot of roles to use in our playbooks, so every developer can checkout this repo in any locations and with a local playbook we create the ".ansible.cgf" file so ansible can find automatically these roles without problem.

So, until here all was wonderful but recently i was trying to use this roles_path in a playbook for share this path with a volume in docker, and i can't find how to do it. Any idea about this?

Thanks in advance!      

Paul Markham

unread,
Jul 26, 2015, 11:11:26 PM7/26/15
to Ansible Project, mnig...@lyracons.com
Not sure if this helps, but you can specify the roles directory using environment variable $ANSIBLE_ROLES_PATH. I don't know if you could set this from within a playbook, though. We set this, and others, from a wrapper script.

Mauro Nigrele

unread,
Jul 27, 2015, 3:27:19 PM7/27/15
to Ansible Project, pa...@netrefinery.com
Thanks Paul, i'll try this workaround, but i still thinking that must be a way to access this vars, since ansible is using it internally.

Roman Belyakovsky

unread,
Sep 9, 2015, 5:07:11 PM9/9/15
to Ansible Project, pa...@netrefinery.com
I believe it should be a good idea to check filters or modules code and implement a filter, i.e. role_path(rolename). It's a bit complicated though: if you just copy this code to your filter it won't work due to import issues.
Reply all
Reply to author
Forward
0 new messages