Adding DNS role

This commit is contained in:
Ian Roddis
2026-04-21 10:07:06 -04:00
parent 3a873051e7
commit 043d315b80
14 changed files with 464 additions and 1 deletions
+49
View File
@@ -0,0 +1,49 @@
---
- name: Create BIND9 directories
ansible.builtin.file:
path: "{{ item }}"
state: directory
mode: '0755'
loop:
- "{{ dns_data_dir }}"
- "{{ dns_data_dir }}/config"
- "{{ dns_data_dir }}/zones"
- "{{ dns_data_dir }}/cache"
- name: Set DNS zone serial from current timestamp
ansible.builtin.set_fact:
dns_zone_serial: "{{ lookup('pipe', 'date +%Y%m%d%H') | int }}"
- name: Deploy named.conf
ansible.builtin.template:
src: named.conf.j2
dest: "{{ dns_data_dir }}/config/named.conf"
mode: '0644'
notify: Restart BIND9
- name: Deploy zone file
ansible.builtin.template:
src: zone.j2
dest: "{{ dns_data_dir }}/zones/{{ base_domain }}.zone"
mode: '0644'
notify: Restart BIND9
- name: Deploy BIND9 docker-compose
ansible.builtin.template:
src: docker-compose.yml.j2
dest: "{{ dns_data_dir }}/docker-compose.yml"
mode: '0644'
notify: Restart BIND9
- name: Start BIND9
community.docker.docker_compose_v2:
project_src: "{{ dns_data_dir }}"
state: present
when: not (molecule_test_mode | default(false))
- name: Wait for BIND9 to be ready
ansible.builtin.wait_for:
host: 127.0.0.1
port: 53
timeout: 30
when: not (molecule_test_mode | default(false))