# Could a value refer another key’s value as variable

**URL:** <https://forum.ansible.com/t/could-a-value-refer-another-key-s-value-as-variable/22025>\
**Category:** Ansible Project\
**Created:** [July 15, 2016, 5:09am UTC](https://forum.ansible.com/t/could-a-value-refer-another-key-s-value-as-variable/22025 "2016-07-15T05:09:48Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![David\_Wong](https://avatars.discourse-cdn.com/v4/letter/d/47e85d/32.png) [@David\_Wong](https://forum.ansible.com/u/David_Wong)\
**Post date:** [July 15, 2016, 5:09am UTC](https://forum.ansible.com/t/could-a-value-refer-another-key-s-value-as-variable/22025/1 "2016-07-15T05:09:48Z")

</div>

Hi,

I would like to do something in playbook like

myapp:  
version: 1.2  
path: xxxx\_{{version}

I want to refer another key’s value to devise new value. It does not work.

Is it possible at all?

Regards,

David

---

<div class="post-metadata">

**Author:** ![jpeacock](https://avatars.discourse-cdn.com/v4/letter/j/7bcc69/32.png) [@jpeacock](https://forum.ansible.com/u/jpeacock)\
**Post date:** [July 20, 2016, 7:43pm UTC](https://forum.ansible.com/t/could-a-value-refer-another-key-s-value-as-variable/22025/2 "2016-07-20T19:43:16Z")

</div>

I do this all the time, but I always quote the RHS of each assignment. NOTE also that you are missing a closing brace in your example code.

John

---

<div class="post-metadata">

**Author:** ![David\_Wong](https://avatars.discourse-cdn.com/v4/letter/d/47e85d/32.png) [@David\_Wong](https://forum.ansible.com/u/David_Wong)\
**Post date:** [July 21, 2016, 3:50am UTC](https://forum.ansible.com/t/could-a-value-refer-another-key-s-value-as-variable/22025/3 "2016-07-21T03:50:00Z")

</div>

Hi John

Thank for your reply, do you mean quoting like this:

---

<div class="post-metadata">

**Author:** ![jdelaporte](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/jdelaporte/32/366_2.png) [@jdelaporte](https://forum.ansible.com/u/jdelaporte)\
**Post date:** [July 21, 2016, 7:29pm UTC](https://forum.ansible.com/t/could-a-value-refer-another-key-s-value-as-variable/22025/4 "2016-07-21T19:29:16Z")

</div>

Does field2’s value display correctly if you use the full path to the other variable?

---

<div class="post-metadata">

**Author:** ![David\_Wong](https://avatars.discourse-cdn.com/v4/letter/d/47e85d/32.png) [@David\_Wong](https://forum.ansible.com/u/David_Wong)\
**Post date:** [July 22, 2016, 9:11am UTC](https://forum.ansible.com/t/could-a-value-refer-another-key-s-value-as-variable/22025/5 "2016-07-22T09:11:39Z")

</div>

Hi Joanna,

I tried that as well, it still did not work, it will fail with:

…recursive loop detected in template string: {{record.field1}}"}

David
