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

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!

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.

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.

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.