diff --git a/roles/nsd/tasks/zones.yml b/roles/nsd/tasks/zones.yml index 17eb521..70f6fae 100644 --- a/roles/nsd/tasks/zones.yml +++ b/roles/nsd/tasks/zones.yml @@ -11,12 +11,12 @@ dns_serial: "{{ ansible_date_time.epoch }}" web_hostname_block: |- {% for webserver in groups['webservers'] | sort -%} - {% for web_hostname in (hostvars[webserver]['web_hostname'] | selectattr('host', 'match', item.name) | map(attribute='host') | sort) -%} - {% if web_hostname | match((\S+\.){2}) %} - @ IN A {{ global_public_ip_address }} - @ IN AAAA {{ hostvars[webserver].proxmox_net0.ip6 | default(hostvars[webserver].ansible_default_ipv4.address) | ansible.utils.ipaddr('address') }} + {% for web_hostname in (hostvars[webserver]['web_hostname'] | selectattr('host', 'match', '.*' ~ item.name) | map(attribute='host') | sort) -%} + {% if web_hostname is match("(\S+\.){2}") %} + {{ web_hostname | regex_replace('\.' ~ item.name ~ '$', '') }} IN CNAME {{ hostvars[webserver].ansible_host }}. {% else %} - {{ web_hostname | regex_replace('\.' ~ item.name ~ '$', '') }} IN CNAME {{ webserver }}. + @ IN A {{ global_public_ip_address }} + @ IN AAAA {{ hostvars[webserver].proxmox_net0.ip6 | default(hostvars[webserver].ansible_default_ipv6.address) | ansible.utils.ipaddr('address') }} {% endif %} {% endfor %} {% endfor %} diff --git a/roles/nsd/templates/zones/mateu.be.zone.j2 b/roles/nsd/templates/zones/mateu.be.zone.j2 index 6016194..f5b22d2 100644 --- a/roles/nsd/templates/zones/mateu.be.zone.j2 +++ b/roles/nsd/templates/zones/mateu.be.zone.j2 @@ -44,7 +44,7 @@ rb IN A 194.156.203.253 rc IN A 10.233.211.195 serenor.dmz IN A {{ global_public_ip_address }} serenor.dmz IN AAAA 2a01:e0a:9bd:2811::59 -{% for proxmox_host in groups['proxmox_all_lxc'] + groups['proxmox_all_running'] | sort %} +{% for proxmox_host in (groups['proxmox_all_lxc'] + groups['proxmox_all_qemu']) | sort %} {{ proxmox_host }}.dmz IN A {{ global_public_ip_address }} {% if proxmox_host.startswith('dns') %} {{ proxmox_host }}-v4.dmz IN A {{ global_public_ip_address }}