``forward``
The domain of the forward lookup zone for each domain (key)
-``ipvar``
- The variable assigned to a system in the Ansible inventory. This allows systems to have multiple IPs assigned for a front and ipmi network, for example. See **Inventory Example** below.
+``ipvar`` OR ``ipvars[]``
+ The variable(s) assigned to a system in the Ansible inventory. This allows systems to have multiple IPs assigned for a front and ipmi network, for example. See **Inventory Example** below.
``dynamic``
Specifies whether the parent zone/domain should allow Dynamic DNS records. See **Dynamic DNS** below for more information.
- www IN TXT "my www host"
- ns1.private IN A 192.168.0.1
private.example.com:
- ipvar: ip
+ ipvars:
+ - ip
+ - if_25Gb_ip
dynamic: true
ddns_hostname_prefixes:
- dyn
{% set domain = item.key %}
-{% if item.value.ipvar is defined and item.value.ipvar.0 is defined %}
-{% set ipvar = item.value.ipvar %}
+
+{# Normalize ipvars: prefer item.value.ipvars (list), fallback to single ipvar #}
+{% set ipvars = [] %}
+{% if item.value.ipvars is defined %}
+ {% set ipvars = item.value.ipvars %}
+{% elif item.value.ipvar is defined %}
+ {% set ipvars = [ item.value.ipvar ] %}
{% endif %}
+
;
; {{ ansible_managed }}
;
{% endfor %}
{% endif %}
-{% if item.value.ipvar is defined and item.value.ipvar.0 is defined %}
-{% for host in groups['all'] %}
-{% if hostvars[host][ipvar] is defined %}
-{% set ipaddr = hostvars[host][ipvar] %}
-{{ hostvars[host]['inventory_hostname_short'] }} IN A {{ hostvars[host][ipvar] }}
-{% endif %}
-{% endfor %}
+{# Emit A records for each host and each ipvar #}
+{% if ipvars | length > 0 %}
+{% for host in groups['all'] %}
+{% for ipvar in ipvars %}
+{% if hostvars[host][ipvar] is defined %}
+{{ hostvars[host]['inventory_hostname_short'] }} IN A {{ hostvars[host][ipvar] }}
+{% endif %}
+{% endfor %}
+{% endfor %}
{% endif %}
{% set zone = item.1 %}
{% set domain = item.0.forward %}
-{% set ipvar = item.0.ipvar %}
+
+{# Normalize ipvars from item.0: prefer ipvars list, fall back to ipvar #}
+{% set ipvars = [] %}
+{% if item.0.ipvars is defined and item.0.ipvars %}
+ {% set ipvars = item.0.ipvars %}
+{% elif item.0.ipvar is defined and item.0.ipvar %}
+ {% set ipvars = [ item.0.ipvar ] %}
+{% endif %}
+
;
; {{ ansible_managed }}
;
; Reverse zone {{ zone }} belongs to forward zone {{ domain }}
-{% for host in groups['all'] %}
-{% if hostvars[host][ipvar] is defined %}
-{% set octet1,octet2,octet3,octet4 = hostvars[host][ipvar].split('.') %}
-{% set cutip = octet1 + '.' + octet2 + '.' + octet3 %}
-{% if cutip == zone %}
-{{ octet4 }} IN PTR {{ hostvars[host]['inventory_hostname_short'] }}.{{ domain }}.
+{% if ipvars | length > 0 %}
+{% for host in groups['all'] %}
+{% for ipvar in ipvars %}
+{% if hostvars[host][ipvar] is defined %}
+{% set octet1,octet2,octet3,octet4 = hostvars[host][ipvar].split('.') %}
+{% set cutip = octet1 + '.' + octet2 + '.' + octet3 %}
+{% if cutip == zone %}
+{% set short = hostvars[host].inventory_hostname_short | default(host) %}
+{{ octet4 }} IN PTR {{ short }}.{{ domain }}.
+{% endif %}
+{% endif %}
+{% endfor %}
+{% endfor %}
{% endif %}
-{% endif %}
-{% endfor %}