role_dnsmasq/templates/ansible_inventory.conf.j2

16 lines
461 B
Django/Jinja

# {{ ansible_managed }}
{% for ip in dnsmasq_host_ips %}
{% endfor %}
{% set last_host = groups['all'] | last %}
{% for host in groups['all'] %}
{% if hostvars[host].get('ansible_host', false) %}
{% set hostnames = [hostvars[host]['inventory_hostname']] + [hostvars[host]['inventory_hostname_short']] + hostvars[host]['dnsmasq_host_aliases'] %}
{{ ip }} {{ hostnames | select() | join(' ') }}
{% if host != last_host %}
{% endif %}
{% endif %}
{% endfor %}