# Accessing "Ansible Variables" in custom modules ?

**URL:** <https://forum.ansible.com/t/accessing-ansible-variables-in-custom-modules/11571>\
**Category:** Ansible Project\
**Created:** [May 23, 2012, 11:18pm UTC](https://forum.ansible.com/t/accessing-ansible-variables-in-custom-modules/11571 "2012-05-23T23:18:52Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Kumar3](https://avatars.discourse-cdn.com/v4/letter/k/ebca7d/32.png) [@Kumar3](https://forum.ansible.com/u/Kumar3)\
**Post date:** [May 23, 2012, 11:18pm UTC](https://forum.ansible.com/t/accessing-ansible-variables-in-custom-modules/11571/1 "2012-05-23T23:18:52Z")

</div>

Hi :

Is there anyway to access the setup module variables in a custom  
built modules ?  
Are there variables passed to the modules.

Thanks,

---

<div class="post-metadata">

**Author:** ![Michael\_DeHaan](https://avatars.discourse-cdn.com/v4/letter/m/c4cdca/32.png) [@Michael\_DeHaan](https://forum.ansible.com/u/Michael_DeHaan)\
**Post date:** [May 24, 2012, 12:23am UTC](https://forum.ansible.com/t/accessing-ansible-variables-in-custom-modules/11571/2 "2012-05-24T00:23:21Z")

</div>

Easiest thing is to pass them back to the modules using the dollar  
sign syntax. In other words, they already bubble up back to the  
playbook, so you just pass the things in that you need.

Trivial example:

command echo $ansible\_hostname

Modules don't require the setup module to be used (think  
/usr/bin/ansible vs /usr/bin/ansible-playbook), so they don't read  
from there.
