complex LOOPS in playbook

Hi Guys,

hope someone can guide me here!

i succesfully get facts from one of my network devices

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 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

Not pretty, but something like this should work if the IP is only shown once in the facts:

   - debug: msg="Interface for {{ item.value.ipv4.keys().0 }} is {{ item.key }}"
     when: item.value.ipv4.keys().0 == '10.255.72.253'
     with_dict: '{{ ansible_facts.interfaces_ip }}'