2022-02-21 20:41:31 +00:00
|
|
|
---
|
|
|
|
|
2024-05-22 18:22:17 +00:00
|
|
|
- name: "Create config directory of DNS zone {{ zone.config.origin }}"
|
2023-02-08 16:56:13 +00:00
|
|
|
ansible.builtin.file:
|
2022-02-21 20:41:31 +00:00
|
|
|
path: "{{ bind_config_directory }}/{{ zone.file | dirname }}"
|
|
|
|
owner: "{{ bind_unix_user }}"
|
|
|
|
group: "{{ bind_unix_group }}"
|
2023-02-26 21:22:07 +00:00
|
|
|
mode: "0755"
|
2022-02-21 20:41:31 +00:00
|
|
|
state: directory
|
|
|
|
with_items:
|
|
|
|
- "{{ view.zones }}"
|
|
|
|
loop_control:
|
|
|
|
loop_var: zone
|
2024-05-22 18:22:17 +00:00
|
|
|
when: zone.file is defined and
|
|
|
|
zone.file | length > 0
|
2022-02-21 20:41:31 +00:00
|
|
|
|
2023-02-08 20:47:45 +00:00
|
|
|
- name: "Template view {{ view.name }}"
|
2023-02-08 16:56:13 +00:00
|
|
|
ansible.builtin.template:
|
2022-02-21 20:41:31 +00:00
|
|
|
src: "{{ inventory_hostname }}/etc/named/{{ zone.file }}.j2"
|
2024-04-29 19:57:30 +00:00
|
|
|
dest: "{{ bind_config_directory + '/' + zone.file }}"
|
2022-02-21 20:41:31 +00:00
|
|
|
owner: "{{ bind_unix_user }}"
|
|
|
|
group: "{{ bind_unix_group }}"
|
2023-02-26 21:22:07 +00:00
|
|
|
mode: "0644"
|
2022-02-21 20:41:31 +00:00
|
|
|
with_items:
|
|
|
|
- "{{ view.zones }}"
|
|
|
|
loop_control:
|
|
|
|
loop_var: zone
|
2024-05-22 18:22:17 +00:00
|
|
|
when: zone.config.type == 'master'
|
2023-02-11 15:00:33 +00:00
|
|
|
notify: Restart named
|
2024-04-29 19:57:30 +00:00
|
|
|
|
|
|
|
- name: Check if last character in zone files is a newline
|
|
|
|
ansible.builtin.include_tasks: verify_zone_file.yml
|
|
|
|
with_items:
|
|
|
|
- "{{ view.zones }}"
|
|
|
|
loop_control:
|
|
|
|
loop_var: zone
|
2024-05-22 18:22:17 +00:00
|
|
|
when: zone.config.type == 'master'
|
|
|
|
|
|
|
|
- name: Sign Zones
|
|
|
|
ansible.builtin.include_tasks: sign_zone_file.yml
|
|
|
|
with_items:
|
|
|
|
- "{{ view.zones }}"
|
|
|
|
loop_control:
|
|
|
|
loop_var: zone
|
|
|
|
when: zone.config.type == 'master' and
|
|
|
|
bind9_dnssec_keys | selectattr('origin', 'in', zone.config.origin) | map(attribute='zone_signing_key') | length > 0 and
|
|
|
|
(bind9_dnssec_keys | selectattr('origin', 'in', zone.config.origin) | map(attribute='zone_signing_key'))[0].private | length > 0 and
|
|
|
|
(bind9_dnssec_keys | selectattr('origin', 'in', zone.config.origin) | map(attribute='zone_signing_key'))[0].public | length > 0
|