# complex loop in playbook

**URL:** <https://forum.ansible.com/t/complex-loop-in-playbook/24868>\
**Category:** Ansible Project\
**Created:** [June 30, 2017, 10:04pm UTC](https://forum.ansible.com/t/complex-loop-in-playbook/24868 "2017-06-30T22:04:26Z")\
**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:** [June 30, 2017, 10:04pm UTC](https://forum.ansible.com/t/complex-loop-in-playbook/24868/1 "2017-06-30T22:04:26Z")

</div>

Hi Guys,

hope someone can guide me here!

i succesfully get facts from my IOS-XR PE

ansible\_facts:  
interfaces\_ip:  
GigabitEthernet0/0/0/2.1004:  
ipv4:  
172.24.70.157:  
prefix\_length: 30  
GigabitEthernet0/0/0/2.1031:  
ipv4:  
10.255.72.253:  
prefix\_length: 30

i’ve played with some of the example given here \> [http://docs.ansible.com/ansible/playbooks\_loops.html](http://docs.ansible.com/ansible/playbooks_loops.html) but without success

how can i get the interface (3rd Level) linked to an IP adress (5th Level) i already know (from host\_vars)

thanks in advance!

\ Francois

---

<div class="post-metadata">

**Author:** ![Reiner\_Nippes](https://avatars.discourse-cdn.com/v4/letter/r/91b2a8/32.png) [@Reiner\_Nippes](https://forum.ansible.com/u/Reiner_Nippes)\
**Post date:** [July 5, 2017, 5:04pm UTC](https://forum.ansible.com/t/complex-loop-in-playbook/24868/2 "2017-07-05T17:04:51Z")

</div>

maybe json\_query will do the trick: [https://docs.ansible.com/ansible/playbooks\_filters.html#json-query-filter](https://docs.ansible.com/ansible/playbooks_filters.html#json-query-filter)
