# reffering variables inside vars.yml

**URL:** <https://forum.ansible.com/t/reffering-variables-inside-vars-yml/14026>\
**Category:** Ansible Project\
**Created:** [November 28, 2013, 3:55pm UTC](https://forum.ansible.com/t/reffering-variables-inside-vars-yml/14026 "2013-11-28T15:55:55Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Frank3](https://avatars.discourse-cdn.com/v4/letter/f/8c91f0/32.png) [@Frank3](https://forum.ansible.com/u/Frank3)\
**Post date:** [November 28, 2013, 3:55pm UTC](https://forum.ansible.com/t/reffering-variables-inside-vars-yml/14026/1 "2013-11-28T15:55:55Z")

</div>

I guys, ansible newbie here…

I’ve read how to refere variables inside vars.yml file here:  
[http://www.ansibleworks.com/docs/YAMLSyntax.html](http://www.ansibleworks.com/docs/YAMLSyntax.html)

foo: 1  
foo\_value: {{ foo }}

then under my playbook.yml load vars.yml with vars\_file: directive and call them with {{ foo\_value }}.  
This is working fine but, what about this:

foo:  
bar: hello  
baz: {{ bar }}

and call it under the play with {{ foo.baz }}.  
Is there a way to do this?

I’ve tried this 4 ways but wihout success… [http://pastie.org/8514924](http://pastie.org/8514924)

help 🙂

cheers,  
Frank

---

<div class="post-metadata">

**Author:** ![Walid](https://avatars.discourse-cdn.com/v4/letter/w/ea5d25/32.png) [@Walid](https://forum.ansible.com/u/Walid)\
**Post date:** [November 30, 2013, 9:44pm UTC](https://forum.ansible.com/t/reffering-variables-inside-vars-yml/14026/2 "2013-11-30T21:44:17Z")

</div>

I guess your problem is the missing quotes, check below an example from Michael last month

- hosts: all  
vars:  
cat: yes  
x: 42  
decoded:  
home: “/usr/bob”  
moo: yes  
xyz: “{{ decoded.home }}”  
glorp: “{{ raz }}”  
fish: “{{ decoded.xyz }}”  
baz: “{{ fish }}”  
raz: “{{ decoded.moo }}”

---

<div class="post-metadata">

**Author:** ![Michael\_DeHaan2](https://avatars.discourse-cdn.com/v4/letter/m/da6949/32.png) [@Michael\_DeHaan2](https://forum.ansible.com/u/Michael_DeHaan2)\
**Post date:** [December 1, 2013, 1:57pm UTC](https://forum.ansible.com/t/reffering-variables-inside-vars-yml/14026/3 "2013-12-01T13:57:10Z")

</div>

When posting a problem, it always helps to state what the problem you are seeing actually is.

Otherwise, how are we to guess? 🙂
