{% if item.comment is defined and item.comment %}
# {{ item.comment }}
{% endif %}
interface {{ item.interface }} {
{% if item.options is defined and item.options %}
{{ item.options | indent(2, true) }}
{% endif %}

{% if item.prefixes is defined and item.prefixes %}
{% if hostvars[inventory_hostname]["ansible_" + item.interface] is defined and hostvars[inventory_hostname]["ansible_" + item.interface].ipv6 is defined and hostvars[inventory_hostname]["ansible_" + item.interface].ipv6 %}
{% for element in item.prefixes %}
{% if element.prefix is defined and element.prefix %}
{% if element.comment is defined and element.comment %}
  # {{ element.comment }}
{% endif %}
  prefix {{ element.prefix }} {
{% if element.options is defined and element.options %}
{{ element.options | indent(4, true) }}
{% endif %}
  };

{% endif %}
{% endfor %}
{% else %}
  # No IPv6 prefixes present on the interface, prefix advertisement disabled

{% endif %}
{% endif %}
{% if item.routes is defined and item.routes %}
{% for element in item.routes %}
{% if element.route is defined and element.route %}
{% if element.comment is defined and element.comment %}
  # {{ element.comment }}
{% endif %}
  route {{ element.route }} {
{% if element.options is defined and element.options %}
{{ element.options | indent(4, true) }}
{% endif %}
  };

{% endif %}
{% endfor %}
{% endif %}
{% if item.nameservers is defined and item.nameservers %}
{% for element in item.nameservers %}
{% if element.comment is defined and element.comment %}
  # {{ element.comment }}
{% endif %}
  RDNSS {{ element.rdnss | join(" ") }} {
{% if element.options is defined and element.options %}
{{ element.options | indent(4, true) }}
{% endif %}
  };

{% endfor %}
{% else %}
{% if hostvars[inventory_hostname]["ansible_" + item.interface] is defined and hostvars[inventory_hostname]["ansible_" + item.interface].ipv6 is defined and hostvars[inventory_hostname]["ansible_" + item.interface].ipv6 %}
{% set radvd_tpl_nameservers = hostvars[inventory_hostname]["ansible_" + item.interface].ipv6 | map(attribute='address') | list %}
  # Advertise router on {{ item.interface }} interface as local DNS server
  RDNSS {{ radvd_tpl_nameservers | join(" ") }} {
  };

{% endif %}
{% endif %}
{% if item.domains is defined and item.domains %}
{% for element in item.domains %}
{% if (element.dnssl is defined and element.dnssl[0] not in [ 'False', 'false' ] and element.dnssl) %}
{% if element.comment is defined and element.comment %}
  # {{ element.comment }}
{% endif %}
  DNSSL {{ element.dnssl | join(" ") }} {
{% if element.options is defined and element.options %}
{{ element.options | indent(4, true) }}
{% endif %}
  };

{% endif %}
{% endfor %}
{% endif %}
{% if item.clients is defined and item.clients %}
  clients {
{% for element in item.clients %}
{% if element is defined and element %}
    {{ element }};
{% endif %}
{% endfor %}
  };

{% endif %}
};