# iterating over lists nested within hash keys

**URL:** <https://forum.ansible.com/t/iterating-over-lists-nested-within-hash-keys/13349>\
**Category:** Ansible Project\
**Created:** [August 22, 2013, 11:36am UTC](https://forum.ansible.com/t/iterating-over-lists-nested-within-hash-keys/13349 "2013-08-22T11:36:44Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Ali-Akber\_Saifee](https://avatars.discourse-cdn.com/v4/letter/a/13edae/32.png) [@Ali-Akber\_Saifee](https://forum.ansible.com/u/Ali-Akber_Saifee)\
**Post date:** [August 22, 2013, 11:36am UTC](https://forum.ansible.com/t/iterating-over-lists-nested-within-hash-keys/13349/1 "2013-08-22T11:36:44Z")

</div>

I have a use-case where a hash is populated with entries from combinations of host/groups variables resulting in something that (simplified) looks like : [https://gist.github.com/alisaifee/343512d19714375c0fd8](https://gist.github.com/alisaifee/343512d19714375c0fd8). I want to give the items in ‘sublist’ the same treatment with respect to the ‘name’ key in each hash entry - so essentially I want to implement one task that uses a with\_\* to iterate over all the sublists combined and also have access to the ‘name’ value in each iteration.

I’m really hoping theres something obvious that I’ve missed 🙂

---

<div class="post-metadata">

**Author:** ![Michael\_DeHaan2](https://avatars.discourse-cdn.com/v4/letter/m/da6949/32.png) [@Michael\_DeHaan2](https://forum.ansible.com/u/Michael_DeHaan2)\
**Post date:** [August 22, 2013, 11:43am UTC](https://forum.ansible.com/t/iterating-over-lists-nested-within-hash-keys/13349/2 "2013-08-22T11:43:05Z")

</div>

There’s already a RFE ticket for adding a lookup plugin for something like this.

Stay tuned!

---

<div class="post-metadata">

**Author:** ![Ali-Akber\_Saifee](https://avatars.discourse-cdn.com/v4/letter/a/13edae/32.png) [@Ali-Akber\_Saifee](https://forum.ansible.com/u/Ali-Akber_Saifee)\
**Post date:** [August 22, 2013, 12:17pm UTC](https://forum.ansible.com/t/iterating-over-lists-nested-within-hash-keys/13349/3 "2013-08-22T12:17:46Z")

</div>

out of desperation i went with a filter plugin that looks like : [https://gist.github.com/alisaifee/9409e65b808ff005b027](https://gist.github.com/alisaifee/9409e65b808ff005b027) (im not even sure if the name makes sense)

used as :

task:  
… ${item.key} … ${item.value}  
with\_items: “{{thing | zipped\_hash(‘key\_lookup’,‘list\_lookup’)}}”

as always , looking forward to deleting my ./custom folder 😃

---

<div class="post-metadata">

**Author:** ![Michael\_DeHaan2](https://avatars.discourse-cdn.com/v4/letter/m/da6949/32.png) [@Michael\_DeHaan2](https://forum.ansible.com/u/Michael_DeHaan2)\
**Post date:** [August 22, 2013, 9:34pm UTC](https://forum.ansible.com/t/iterating-over-lists-nested-within-hash-keys/13349/4 "2013-08-22T21:34:39Z")

</div>

This shouldn’t be a filter plugin, it should be a new lookup plugin.

with\_items is one, as is with\_nested

Take a look!
