--- - name: Install bind9 ansible.builtin.apt: name: - "bind9" state: "present" become: true - name: Deploy acme.key ansible.builtin.copy: content: "{{ hostvars['console']['bind']['acme_key'] }}" dest: "/etc/bind/acme.key" owner: "bind" group: "bind" mode: "0640" become: true notify: "notification_restart_bind" no_log: true - name: Deploy forward zone files ansible.builtin.template: src: "{{ hostvars['console']['node']['config_path'] }}/services/systemd/fw/bind/lib/{{ item.src }}.j2" dest: "/var/lib/bind/{{ item.dest }}" owner: "bind" group: "bind" mode: "0640" loop: - src: "db.public" dest: "db.{{ domain['public'] }}" - src: "db.internal" dest: "db.{{ domain['internal'] }}" become: true notify: "notification_restart_bind" no_log: true - name: Deploy IPv4 reverse zone files vars: reverse_net: "{{ item.key }}" ansible.builtin.template: src: "{{ hostvars['console']['node']['config_path'] }}/services/systemd/fw/bind/lib/db.ipv4.rev.j2" dest: "/var/lib/bind/db.{{ item.key }}.ipv4.rev" owner: bind group: bind mode: "0644" loop: "{{ network['reverse_zone']['ipv4'] | dict2items }}" become: true notify: "notification_restart_bind" no_log: true - name: Deploy IPv6 reverse zones vars: reverse_net: "{{ item.key }}" ansible.builtin.template: src: "{{ hostvars['console']['node']['config_path'] }}/services/systemd/fw/bind/lib/db.ipv6.rev.j2" dest: "/var/lib/bind/db.{{ item.key }}.ipv6.rev" owner: bind group: bind mode: "0644" loop: "{{ network['reverse_zone']['ipv6'] | dict2items }}" become: true notify: "notification_restart_bind" no_log: true - name: Find BIND journal files ansible.builtin.find: paths: "/var/lib/bind" patterns: "*.jnl" file_type: file become: true register: bind_journal_files no_log: true - name: Clean BIND journal files ansible.builtin.file: path: "{{ item.path }}" state: absent loop: "{{ bind_journal_files.files }}" become: true notify: "notification_restart_bind" no_log: true - name: Deploy named.conf ansible.builtin.template: src: "{{ hostvars['console']['node']['config_path'] }}/services/systemd/fw/bind/etc/named.conf.j2" dest: "/etc/bind/named.conf" owner: "root" group: "bind" mode: "0640" validate: "/usr/bin/named-checkconf -z %s" become: true notify: "notification_restart_bind" - name: Create named.service.d ansible.builtin.file: path: "/etc/systemd/system/named.service.d" state: "directory" owner: "root" group: "root" mode: "0755" become: true - name: Set named.service.d/override.conf ansible.builtin.copy: dest: "/etc/systemd/system/named.service.d/override.conf" content: | [Service] Restart=always RestartSec=60 owner: "root" group: "root" mode: "0644" become: true notify: "notification_restart_bind" - name: Enable bind9 service ansible.builtin.systemd: name: "named.service" state: "started" enabled: true become: true # Verify working # dig A fw.ilnmors.internal @fd00:10::3 # dig AAAA fw.ilnmors.internal @fd00:10::3