ansible/roles/knotd/tasks/main.yml
2022-08-17 19:00:07 +02:00

60 lines
1.5 KiB
YAML

---
- name: Install knotd and dnspython
apt:
name:
- knot
- python3-dnspython
- name: Install config files
template:
src: knot.conf.j2
dest: /etc/knot/knot.conf
owner: root
group: knot
mode: u=rw,g=r,o=
notify:
- Restart knotd
- name: Create zones directory
file:
path: "{{ knotd__zones_dir }}"
state: directory
owner: root
group: "{{ knotd__group }}"
mode: u=rwx,g=rx,o=
- name: Create zone files
dns_zone:
path: "{{ knotd__zones_dir }}/{{ item.key }}.zone"
owner: root
group: "{{ knotd__group }}"
mode: u=rw,g=r,o=
origin: "{{ item.key }}"
soa: "{{ item.value.soa }}"
hosts: "{{ item.value.hosts | default(omit) }}"
ns: "{{ item.value.ns | default(omit) }}"
mx: "{{ item.value.mx | default(omit) }}"
cname: "{{ item.value.cname | default(omit) }}"
txt: "{{ item.value.txt | default(omit) }}"
a: "{{ item.value.a | default(omit) }}"
aaaa: "{{ item.value.aaaa | default(omit) }}"
when: "item.value.master is not defined
and (item.value.enabled | default(true))"
loop: "{{ knotd__zones | dict2items }}"
notify:
- Reload knotd
- name: Remove disabled zone files
file:
path: "{{ knotd__zones_dir }}/{{ item.key }}.zone"
state: absent
when: "item.value.master is not defined
and not (item.value.enabled | default(true))"
loop: "{{ knotd__zones | dict2items }}"
- name: Enable and start knotd
systemd:
name: knot.service
enabled: true
state: started
...