# trying to nest loop with a hash

**URL:** <https://forum.ansible.com/t/trying-to-nest-loop-with-a-hash/15633>\
**Category:** Ansible Project\
**Created:** [July 9, 2014, 4:37pm UTC](https://forum.ansible.com/t/trying-to-nest-loop-with-a-hash/15633 "2014-07-09T16:37:12Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Alain\_Kreienbuhl](https://avatars.discourse-cdn.com/v4/letter/a/e495f1/32.png) [@Alain\_Kreienbuhl](https://forum.ansible.com/u/Alain_Kreienbuhl)\
**Post date:** [July 9, 2014, 4:37pm UTC](https://forum.ansible.com/t/trying-to-nest-loop-with-a-hash/15633/1 "2014-07-09T16:37:12Z")

</div>

Hello,

Want I’d like to do is something like that :

`

- name: firewalling allow from loadbalancer  
ufw: rule=allow from\_ip={{item[1]}} proto=tcp to\_port={{item[0].value.porthttp}}  
with\_nested:
- my\_apps\_dict
- trusted\_networks  
tags:
- ufw

`

with my\_apps\_dict looking like :

`  
my\_apps\_dict:  
app1:  
porthttp: xxx  
…  
app2:  
porthttp: xxx  
…  
…  
…

`

and trusted network being a simple list.

I’ve being searching but to no avail, any ideas ?

Thanks

---

<div class="post-metadata">

**Author:** ![Serge\_van\_Ginderacht](https://avatars.discourse-cdn.com/v4/letter/s/b782af/32.png) [@Serge\_van\_Ginderacht](https://forum.ansible.com/u/Serge_van_Ginderacht)\
**Post date:** [July 9, 2014, 5:57pm UTC](https://forum.ansible.com/t/trying-to-nest-loop-with-a-hash/15633/2 "2014-07-09T17:57:37Z")

</div>

​Maybe

​  
&nbsp;&nbsp;with\_nested:  
&nbsp;&nbsp;&nbsp;&nbsp;- my\_apps\_dict.items()  
&nbsp;&nbsp;&nbsp;&nbsp;- trusted\_networks

?

---

<div class="post-metadata">

**Author:** ![Michael\_DeHaan1](https://avatars.discourse-cdn.com/v4/letter/m/5e9695/32.png) [@Michael\_DeHaan1](https://forum.ansible.com/u/Michael_DeHaan1)\
**Post date:** [July 9, 2014, 7:54pm UTC](https://forum.ansible.com/t/trying-to-nest-loop-with-a-hash/15633/3 "2014-07-09T19:54:09Z")

</div>

You may need to write a custom iterator lookup plugin for something like that. Not sure what I’d call it.
