# looping through list of dictionaries

**URL:** <https://forum.ansible.com/t/looping-through-list-of-dictionaries/30693>\
**Category:** Ansible Project\
**Created:** [July 1, 2019, 8:32pm UTC](https://forum.ansible.com/t/looping-through-list-of-dictionaries/30693 "2019-07-01T20:32:52Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Brian\_Goulet](https://avatars.discourse-cdn.com/v4/letter/b/e9c0ed/32.png) [@Brian\_Goulet](https://forum.ansible.com/u/Brian_Goulet)\
**Post date:** [July 1, 2019, 8:32pm UTC](https://forum.ansible.com/t/looping-through-list-of-dictionaries/30693/1 "2019-07-01T20:32:52Z")

</div>

my playbook grabs show command output from a cisco switch and then reformats that output into structured data thanks to a parsing script written by someone smarter than me. i’m pretty new to ansible data structures but I believe this data is a list (ios\_vlans) of dictionary objects (vlans) which contains multiple elements, including one that is also a list (ports). here is sample data

# Schema Output

---

<div class="post-metadata">

**Author:** ![Kai\_Stian\_Olstad](https://avatars.discourse-cdn.com/v4/letter/k/e19adc/32.png) [@Kai\_Stian\_Olstad](https://forum.ansible.com/u/Kai_Stian_Olstad)\
**Post date:** [July 1, 2019, 9:09pm UTC](https://forum.ansible.com/t/looping-through-list-of-dictionaries/30693/2 "2019-07-01T21:09:55Z")

</div>

with\_items is a parameter for the task not the module debug, so with\_items need to indented at the same level as name and debug.  
with\_items takes a list, so you need  
&nbsp;&nbsp;with\_items: "{{ ios\_vlans.vlans }}"

---

<div class="post-metadata">

**Author:** ![Brian\_Goulet](https://avatars.discourse-cdn.com/v4/letter/b/e9c0ed/32.png) [@Brian\_Goulet](https://forum.ansible.com/u/Brian_Goulet)\
**Post date:** [July 2, 2019, 1:38pm UTC](https://forum.ansible.com/t/looping-through-list-of-dictionaries/30693/3 "2019-07-02T13:38:54Z")

</div>

> ha! well that was silly. beaten by space characters again. thank you so much Kai.
