# Building a list from complex YAML

**URL:** <https://forum.ansible.com/t/building-a-list-from-complex-yaml/25072>\
**Category:** Ansible Project\
**Created:** [July 24, 2017, 8:34pm UTC](https://forum.ansible.com/t/building-a-list-from-complex-yaml/25072 "2017-07-24T20:34:12Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Francois\_Herbet](https://avatars.discourse-cdn.com/v4/letter/f/a88e57/32.png) [@Francois\_Herbet](https://forum.ansible.com/u/Francois_Herbet)\
**Post date:** [July 24, 2017, 8:34pm UTC](https://forum.ansible.com/t/building-a-list-from-complex-yaml/25072/1 "2017-07-24T20:34:12Z")

</div>

Hi Guys need some advice on this case

here’s my hostvars

---

<div class="post-metadata">

**Author:** ![Francois\_Herbet](https://avatars.discourse-cdn.com/v4/letter/f/a88e57/32.png) [@Francois\_Herbet](https://forum.ansible.com/u/Francois_Herbet)\
**Post date:** [July 24, 2017, 9:09pm UTC](https://forum.ansible.com/t/building-a-list-from-complex-yaml/25072/2 "2017-07-24T21:09:41Z")

</div>

look like i’ve the proper json\_query

- debug: msg=“{{ item }}”  
with\_items:
- “{{ SERVICE.MC|json\_query(‘\*.PIM\_GROUP’) }}”

which gives

“msg”: [  
“GS\_SIGMAX\_MC\_A\_PIM”,  
“GS\_SIGMAY\_MC\_A\_PIM”  
]
