diff --git a/templates/host.conf.j2 b/templates/host.conf.j2 index 6dec476..7a681ef 100644 --- a/templates/host.conf.j2 +++ b/templates/host.conf.j2 @@ -1,8 +1,9 @@ # {{ ansible_managed }} -{% for ip in dnsmasq_host_ipv4 %} -{{ ip }} {{ dnsmasq_client_hostname }} {{ dnsmasq_host_aliases | join(' ') }} -{% endfor %} -{% for ip in dnsmasq_host_ipv6 %} +{% set ips = dnsmasq_host_ipv4 + dnsmasq_host_ipv6 %} + +{% for ip in ips %} +{% if ip | length > 0 %} {{ ip }} {{ dnsmasq_client_hostname }} {{ dnsmasq_host_aliases | join(' ') }} +{% endif %} {% endfor %}