# Ansible resolve dictionary key or parameter variable

**URL:** <https://forum.ansible.com/t/ansible-resolve-dictionary-key-or-parameter-variable/17194>\
**Category:** Ansible Project\
**Created:** [January 6, 2015, 10:36am UTC](https://forum.ansible.com/t/ansible-resolve-dictionary-key-or-parameter-variable/17194 "2015-01-06T10:36:50Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Eli\_Finkelshteyn](https://avatars.discourse-cdn.com/v4/letter/e/f4b2a3/32.png) [@Eli\_Finkelshteyn](https://forum.ansible.com/u/Eli_Finkelshteyn)\
**Post date:** [January 6, 2015, 10:36am UTC](https://forum.ansible.com/t/ansible-resolve-dictionary-key-or-parameter-variable/17194/1 "2015-01-06T10:36:50Z")

</div>

In Ansible, if I try to use a variable as a parameter name, or a key name, it is never resolved. For example, if I have `{{ some_var }}: true`, or:

template: “{{ resolve\_me\_to\_src }}”: “some\_src”

the variables will just be used literally and never resolve. My specific use case is using this with the ec2 module, where some of my tag names are stored as variables:

- name: Provision a set of instances  
ec2:  
group: “{{ aws\_security\_group }}”  
instance\_type: “{{ aws\_instance\_type }}”  
image: “{{ aws\_ami\_id }}”  
region: “{{ aws\_region }}”  
vpc\_subnet\_id: “{{ aws\_vpc\_subnet\_id }}”  
key\_name: “{{ aws\_key\_name }}”  
wait: true  
count: “{{ num\_machines }}”  
instance\_tags: { “{{ some\_tag }}”: “{{ some\_value }}”, “{{ other\_tag }}”: “{{ other\_value }}” }

Is there any way around this? Can I mark that I want to force evaluation somehow?

Eli

---

<div class="post-metadata">

**Author:** ![Eli\_Finkelshteyn](https://avatars.discourse-cdn.com/v4/letter/e/f4b2a3/32.png) [@Eli\_Finkelshteyn](https://forum.ansible.com/u/Eli_Finkelshteyn)\
**Post date:** [January 6, 2015, 7:14pm UTC](https://forum.ansible.com/t/ansible-resolve-dictionary-key-or-parameter-variable/17194/2 "2015-01-06T19:14:00Z")

</div>

By the way, I’m on 1.8.2, in case that helps.

---

<div class="post-metadata">

**Author:** ![vaida.dan](https://avatars.discourse-cdn.com/v4/letter/v/5daacb/32.png) [@vaida.dan](https://forum.ansible.com/u/vaida.dan)\
**Post date:** [January 10, 2015, 7:09pm UTC](https://forum.ansible.com/t/ansible-resolve-dictionary-key-or-parameter-variable/17194/3 "2015-01-10T19:09:18Z")

</div>

Where are you defining those variables that you expect to be resolved by instance\_tags? For example, are you doing it in host\_vars/localhost?  
BTW, have you had a look at [http://docs.ansible.com/ec2\_tag\_module.html](http://docs.ansible.com/ec2_tag_module.html)?
