"ansible_eth2": {"active": true,"device": "eth2","macaddress": "30:0e:d5:cb:11:fe","type": "ether"},
- hosts: foo.example.comvars:target_macaddr: "0c:c4:7a:17:9a:94"tasks:- debug:var: hostvars[inventory_hostname]['ansible_' + item].devicewhen: hostvars[inventory_hostname]['ansible_' + item].macaddress is defined and hostvars[inventory_hostname]['ansible_' + item].macaddress == target_macaddrwith_items: '{{ ansible_interfaces }}'