# using variables in group\_vars/\*

**URL:** <https://forum.ansible.com/t/using-variables-in-group-vars/23988>\
**Category:** Ansible Project\
**Created:** [March 16, 2017, 9:48am UTC](https://forum.ansible.com/t/using-variables-in-group-vars/23988 "2017-03-16T09:48:31Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![dch](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/dch/32/7132_2.png) [@dch](https://forum.ansible.com/u/dch)\
**Post date:** [March 16, 2017, 9:48am UTC](https://forum.ansible.com/t/using-variables-in-group-vars/23988/1 "2017-03-16T09:48:31Z")

</div>

How can I reference another variable within group\_vars files?

Specifically, I have a bunch of RFC1918-style (loopback internal like  
192.168.1.1) IP addresses for things that are referenced all over the  
place. Depending on the environment, those addresses are different  
(test/dev, production) and I can't simply use DNS lookups.  
I'm aware of ansible's precedence [1] but this is more about \*when\*  
these files get processed, and whether they're handled as a gorup, or in  
separate passes.

# group\_vars/all.yml

---

<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:** [March 16, 2017, 1:40pm UTC](https://forum.ansible.com/t/using-variables-in-group-vars/23988/2 "2017-03-16T13:40:13Z")

</div>

It doesn't matter as the templating happens lazily (on use) not on  
processing the files.

---

<div class="post-metadata">

**Author:** ![dch](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/dch/32/7132_2.png) [@dch](https://forum.ansible.com/u/dch)\
**Post date:** [March 19, 2017, 11:47pm UTC](https://forum.ansible.com/t/using-variables-in-group-vars/23988/3 "2017-03-19T23:47:14Z")

</div>

Thanks Brian,

I found the issue - it seems one can't use hash values defined in an  
earlier file, which sort of makes sense if they're not processed in  
discrete phases. I moved config.net.\* up to net.\* and all works well,  
the hashes are not overlapping anymore:

# group\_vars/all.yml
