# dict in dict access value in with\_item

**URL:** <https://forum.ansible.com/t/dict-in-dict-access-value-in-with-item/19707>\
**Category:** Ansible Project\
**Created:** [November 7, 2015, 1:48pm UTC](https://forum.ansible.com/t/dict-in-dict-access-value-in-with-item/19707 "2015-11-07T13:48:05Z")\
**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 7, 2015, 1:48pm UTC](https://forum.ansible.com/t/dict-in-dict-access-value-in-with-item/19707/1 "2015-11-07T13:48:05Z")

</div>

Hi,

I’ve got a dict in dict in a var file. When debuging this var, it 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" } } }`

I would like to be able to use those vars in a role with a with\_item statement. Here is what it looks like:

`

- name: create operation folder  
file: path=“{{item}}” owner=user mode=0755 state=directory  
with\_items:
- nm\_java\_apps\_params[“{{another\_var\_here}}”][‘dest\_folder’]  
`

But I can’t get it correctly resolved. Here is what I got:

`  
TASK: [nm.java-apps | create operation folder] \*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*

changed: [x.x.x.x] =\> (item=nm\_java\_apps\_params[“my\_var”][‘dest\_folder’])  
`

In fact it creates a folder named: “nm\_java\_apps\_params[“my\_var”][‘dest\_folder’]”, which is of course what I’m not really expecting. I thought having ‘/tmp/test’ instead.

Any ideas on how I can resolve this problem ?

Thanks

---

<div class="post-metadata">

**Author:** ![Alex\_Leonhardt](https://avatars.discourse-cdn.com/v4/letter/a/ec9cab/32.png) [@Alex\_Leonhardt](https://forum.ansible.com/u/Alex_Leonhardt)\
**Post date:** [November 7, 2015, 2:17pm UTC](https://forum.ansible.com/t/dict-in-dict-access-value-in-with-item/19707/2 "2015-11-07T14:17:20Z")

</div>

I think you need ‘with\_nested’ here?  
[http://docs.ansible.com/ansible/playbooks\_loops.html](http://docs.ansible.com/ansible/playbooks_loops.html)

Alex

---

<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 7, 2015, 2:47pm UTC](https://forum.ansible.com/t/dict-in-dict-access-value-in-with-item/19707/3 "2015-11-07T14:47:16Z")

</div>

It works ! Thanks !
