# Referencing variables within the same datastructure

**URL:** <https://forum.ansible.com/t/referencing-variables-within-the-same-datastructure/15146>\
**Category:** Ansible Project\
**Created:** [May 2, 2014, 5:40pm UTC](https://forum.ansible.com/t/referencing-variables-within-the-same-datastructure/15146 "2014-05-02T17:40:55Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Hernandes\_Sousa](https://avatars.discourse-cdn.com/v4/letter/h/eb8c5e/32.png) [@Hernandes\_Sousa](https://forum.ansible.com/u/Hernandes_Sousa)\
**Post date:** [May 2, 2014, 5:40pm UTC](https://forum.ansible.com/t/referencing-variables-within-the-same-datastructure/15146/1 "2014-05-02T17:40:55Z")

</div>

Hi,

I’m trying to do the same as mentioned in this issue [https://github.com/ansible/ansible/issues/4450](https://github.com/ansible/ansible/issues/4450) without success:

ansible:  
foo: “value”  
bar: “/tmp/{{ ansible.foo }}”

This causes the following error: recursive loop detected in template string.

I understand this is because I’m referencing a variable created in the same data structure, but Michael mentioned this was fixed on the devel branch 7 months ago, is there a way to accomplish this?

I’m running 1.5.5.

---

<div class="post-metadata">

**Author:** ![Michael\_DeHaan1](https://avatars.discourse-cdn.com/v4/letter/m/5e9695/32.png) [@Michael\_DeHaan1](https://forum.ansible.com/u/Michael_DeHaan1)\
**Post date:** [May 2, 2014, 7:12pm UTC](https://forum.ansible.com/t/referencing-variables-within-the-same-datastructure/15146/2 "2014-05-02T19:12:04Z")

</div>

Yes, you simply can’t do this.

You can reference variables in another datastructure, however.
