# Jinja can't access to a dictionnary containing var

**URL:** <https://forum.ansible.com/t/jinja-cant-access-to-a-dictionnary-containing-var/19715>\
**Category:** Ansible Project\
**Created:** [November 9, 2015, 9:29pm UTC](https://forum.ansible.com/t/jinja-cant-access-to-a-dictionnary-containing-var/19715 "2015-11-09T21:29:16Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Pierre\_Mavro](https://avatars.discourse-cdn.com/v4/letter/p/67e7ee/32.png) [@Pierre\_Mavro](https://forum.ansible.com/u/Pierre_Mavro)\
**Post date:** [November 9, 2015, 9:29pm UTC](https://forum.ansible.com/t/jinja-cant-access-to-a-dictionnary-containing-var/19715/1 "2015-11-09T21:29:16Z")

</div>

Hi,

I’ve got a dictionary which looks like this:

`"var": { "nm_java_apps_params": { "nm-core": { "dest_folder": '/tmp/test' "port": 9487, "start_options": " -Xmx16G -XX:+UseG1GC -XX:+UseStringDeduplication", "version": "latest" }, "nm-staticmaps": {`“dest\_folder”: ‘/tmp/test’`"port": 9462, "start_options": "", "war_name": "latest.war" } } }`

In a role, I can access data like this:

`{{ nm_java_apps_params['{{my_var}}']['dest_folder'] }}`

However, when I’m trying in Jinja with the same way, I’ve got:

`{'msg': "AnsibleUndefinedVariable: One or more undefined variables: 'dict object' has no attribute '{{my_var}}'", 'failed': True}`

Any idea of what I missed here ?

Thanks in advance

---

<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:** [November 9, 2015, 9:49pm UTC](https://forum.ansible.com/t/jinja-cant-access-to-a-dictionnary-containing-var/19715/2 "2015-11-09T21:49:40Z")

</div>

You should not nest jinja2 print statements. Instead you can just use raw vars once you are inside of {{ }}

Such as:

{{ nm\_java\_apps\_params[my\_var][‘dest\_folder’] }}

---

<div class="post-metadata">

**Author:** ![Pierre\_Mavro](https://avatars.discourse-cdn.com/v4/letter/p/67e7ee/32.png) [@Pierre\_Mavro](https://forum.ansible.com/u/Pierre_Mavro)\
**Post date:** [November 10, 2015, 7:30am UTC](https://forum.ansible.com/t/jinja-cant-access-to-a-dictionnary-containing-var/19715/3 "2015-11-10T07:30:55Z")

</div>

Hi,

Thanks, I think I was too tired to see that stupid mistake.

Thanks a lot !
