# How to use variables from ansible.cfg in custom module

**URL:** <https://forum.ansible.com/t/how-to-use-variables-from-ansible-cfg-in-custom-module/20203>\
**Category:** Ansible Developer\
**Created:** [January 13, 2016, 6:15pm UTC](https://forum.ansible.com/t/how-to-use-variables-from-ansible-cfg-in-custom-module/20203 "2016-01-13T18:15:22Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![CyberCyber](https://avatars.discourse-cdn.com/v4/letter/c/a88e4f/32.png) [@CyberCyber](https://forum.ansible.com/u/CyberCyber)\
**Post date:** [January 13, 2016, 6:15pm UTC](https://forum.ansible.com/t/how-to-use-variables-from-ansible-cfg-in-custom-module/20203/1 "2016-01-13T18:15:22Z")

</div>

Hi,

I am working on a custom module and would like to use variables from ansible.cfg in the python script. Specifically, I need to use DEFAULT\_REMOTE\_TMP. How can I access this from within my module ?

---

<div class="post-metadata">

**Author:** ![Brian\_Coca](https://avatars.discourse-cdn.com/v4/letter/b/6de8d8/32.png) [@Brian\_Coca](https://forum.ansible.com/u/Brian_Coca)\
**Post date:** [January 14, 2016, 5:33pm UTC](https://forum.ansible.com/t/how-to-use-variables-from-ansible-cfg-in-custom-module/20203/2 "2016-01-14T17:33:16Z")

</div>

modules only get data passed to themin options, they don't have access  
to ansible.cfg, variables or facts directly, but you do execute the  
modules in that remote temp directory so \_\_file\_\_ should have the  
path.

---

<div class="post-metadata">

**Author:** ![CyberCyber](https://avatars.discourse-cdn.com/v4/letter/c/a88e4f/32.png) [@CyberCyber](https://forum.ansible.com/u/CyberCyber)\
**Post date:** [January 14, 2016, 11:59pm UTC](https://forum.ansible.com/t/how-to-use-variables-from-ansible-cfg-in-custom-module/20203/3 "2016-01-14T23:59:06Z")

</div>

Using os.path.expanduser( **file** ) I was able to get the temporary directory and use it in my code.

Thanks so much Brian!
