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

**URL:** <https://forum.ansible.com/t/can-i-use-a-ansible-cfg-var-in-a-playbook/18855>\
**Category:** Ansible Project\
**Created:** [July 26, 2015, 6:50am UTC](https://forum.ansible.com/t/can-i-use-a-ansible-cfg-var-in-a-playbook/18855 "2015-07-26T06:50:13Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Mauro\_Nigrele](https://avatars.discourse-cdn.com/v4/letter/m/c89c15/32.png) [@Mauro\_Nigrele](https://forum.ansible.com/u/Mauro_Nigrele)\
**Post date:** [July 26, 2015, 6:50am UTC](https://forum.ansible.com/t/can-i-use-a-ansible-cfg-var-in-a-playbook/18855/1 "2015-07-26T06:50:13Z")

</div>

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!

---

<div class="post-metadata">

**Author:** ![Paul\_Markham](https://avatars.discourse-cdn.com/v4/letter/p/9d8465/32.png) [@Paul\_Markham](https://forum.ansible.com/u/Paul_Markham)\
**Post date:** [July 27, 2015, 3:11am UTC](https://forum.ansible.com/t/can-i-use-a-ansible-cfg-var-in-a-playbook/18855/2 "2015-07-27T03:11:26Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![Mauro\_Nigrele](https://avatars.discourse-cdn.com/v4/letter/m/c89c15/32.png) [@Mauro\_Nigrele](https://forum.ansible.com/u/Mauro_Nigrele)\
**Post date:** [July 27, 2015, 7:27pm UTC](https://forum.ansible.com/t/can-i-use-a-ansible-cfg-var-in-a-playbook/18855/3 "2015-07-27T19:27:19Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![Roman\_Belyakovsky](https://avatars.discourse-cdn.com/v4/letter/r/ecae2f/32.png) [@Roman\_Belyakovsky](https://forum.ansible.com/u/Roman_Belyakovsky)\
**Post date:** [September 9, 2015, 9:07pm UTC](https://forum.ansible.com/t/can-i-use-a-ansible-cfg-var-in-a-playbook/18855/4 "2015-09-09T21:07:11Z")

</div>

I believe it should be a good idea to check filters or modules [code](https://github.com/ansible/ansible/blob/devel/lib/ansible/plugins/lookup/file.py) 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.
