10zone.conf.j2 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. # {{ ansible_managed }}
  2. {% set local_zone_type = item.local_zone_type | default(unbound_local_zone) %}
  3. {% set domains_with_reverses = item.domains_with_reverses | default(unbound_domains_with_reverses) %}
  4. {% set local_zones = item.local_zones | default(unbound_local_zone) %}
  5. {% set inventory_domain = item.inventory_domain | default(unbound_inventory_domain) %}
  6. {% set domains = item.domains | default(unbound_domains) %}
  7. {% set inventory_domain_with_reverse = item.inventory_domain_with_reverse|default(unbound_inventory_domain_with_reverse) %}
  8. {% for domain in domains_with_reverses %}
  9. local-zone: "{{domain.domain_name}}." {{local_zone_type[domain.domain_name] | default(unbound_default_local_zone)}}
  10. {% for subdomain, ip in domain.iteritems() %}
  11. {% if subdomain != "domain_name" %}
  12. local-data: "{{ subdomain }}.{{ domain.domain_name }}. IN A {{ ip }}"
  13. local-data-ptr: "{{ ip }} {{ subdomain }}.{{ domain.domain_name }}"
  14. {% endif %}
  15. {% endfor %}
  16. {% endfor %}
  17. {% for domain in local_zones %}
  18. local-zone: "{{domain}}." {{local_zone_type[domain] | default(unbound_default_local_zone)}}
  19. {% endfor %}
  20. {% for group, domain in inventory_domain.iteritems() %}
  21. # Group {{group}}
  22. {% for host in groups[group] %}
  23. local-data: "{{ hostvars[host]['inventory_hostname_short'] }}.{{ domain }}. IN A {{ hostvars[host][ 'ansible_ssh_host'] }}"
  24. {% if inventory_domain_with_reverse %}
  25. local-data-ptr: "{{ hostvars[host]['ansible_ssh_host'] }} {{ hostvars[host]['inventory_hostname_short'] }}.{{ domain }}."
  26. {% endif %}
  27. {% endfor %}
  28. {% endfor %}
  29. {% for domain in domains %}
  30. # local-zone: "{{domain.domain_name}}." {{local_zone_type[domain.domain_name] | default(unbound_default_local_zone)}}
  31. {% for subdomain, entry in domain.iteritems() %}
  32. {% if subdomain != "domain_name" %}
  33. local-data: "{{ subdomain }}.{{ domain.domain_name }}. {{ entry }}"
  34. {% endif %}
  35. {% endfor %}
  36. {% endfor %}