{% set nodes = query('netbox.netbox.nb_lookup', 'devices', raw_data=true) | selectattr('config_context') | selectattr('config_context', 'contains', 'master') | selectattr('config_context.master', '==', inventory_hostname) | map(attribute='name') -%} { {% for node in nodes %} "{{ hostvars[node].interfaces | selectattr('name', '==', 'lo') | map(attribute='ip_addresses') | first | selectattr('role') | selectattr('role.value', '==', 'loopback') | map(attribute='address') | ipv4 | first | ipaddr('address') }}": -1{{ '' if loop.last else ',' }} {# TODO help my eyes the goggles do nothing +#} {% endfor %} }