# Variabla variable name, or dynamic variables...

**URL:** <https://forum.ansible.com/t/variabla-variable-name-or-dynamic-variables/23382>\
**Category:** Ansible Developer\
**Created:** [January 4, 2017, 9:15pm UTC](https://forum.ansible.com/t/variabla-variable-name-or-dynamic-variables/23382 "2017-01-04T21:15:42Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Christian\_Tardif](https://avatars.discourse-cdn.com/v4/letter/c/f05b48/32.png) [@Christian\_Tardif](https://forum.ansible.com/u/Christian_Tardif)\
**Post date:** [January 4, 2017, 9:15pm UTC](https://forum.ansible.com/t/variabla-variable-name-or-dynamic-variables/23382/1 "2017-01-04T21:15:42Z")

</div>

Hi,

I’m trying to accomplish something like this.

I have a variable defined with register. Let’s call it just json **output**. That’s a json output from an API. Content look like:

{  
“my.server”: {  
“not\_after”: “2019-11-27T21:36:56UTC”,  
“not\_before”: “2014-11-27T21:36:56UTC”,  
“serial”: 1  
},  
[… and many more …]

}

To get the information, I have a variable named vm\_name (defined in vars: ) which has “my.server” as content

I want to run through my json stream, and find the above entry. Tried to do something like:

debug:  
msg=“{{ output[‘{{ vm\_name }}’] }}”

which , obviously, does not work.

How can I do to actually expand {{ output[‘{{ vm\_name }}’] }} to actually perform: {{output[‘my.server’]}}

Thanks!

Christian

---

<div class="post-metadata">

**Author:** ![sivel](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/sivel/32/1198_2.png) [@sivel](https://forum.ansible.com/u/sivel)\
**Post date:** [January 4, 2017, 9:23pm UTC](https://forum.ansible.com/t/variabla-variable-name-or-dynamic-variables/23382/2 "2017-01-04T21:23:20Z")

</div>

“{{ output[vm\_name] }}”

You can think of {{ }} as a code block, so anything inside of that should be referenced as bare variables.

---

<div class="post-metadata">

**Author:** ![Christian\_Tardif](https://avatars.discourse-cdn.com/v4/letter/c/f05b48/32.png) [@Christian\_Tardif](https://forum.ansible.com/u/Christian_Tardif)\
**Post date:** [January 5, 2017, 2:25am UTC](https://forum.ansible.com/t/variabla-variable-name-or-dynamic-variables/23382/3 "2017-01-05T02:25:15Z")

</div>

Oh! Great!

Thank you for that. That’ll help to understand a lot of things, then! 🙂
