2021-01-16 02:00:19 +01:00
|
|
|
---
|
|
|
|
|
2024-04-14 22:41:41 +02:00
|
|
|
- name: Render knot master config
|
|
|
|
ansible.builtin.template:
|
2021-01-16 02:00:19 +01:00
|
|
|
src: etc/knot/knot.conf.j2
|
|
|
|
dest: /etc/knot/knot.conf
|
|
|
|
owner: knot
|
|
|
|
group: knot
|
2024-04-14 22:41:41 +02:00
|
|
|
mode: "0640"
|
2021-01-16 02:00:19 +01:00
|
|
|
vars:
|
|
|
|
zones: "{{ hostvars[inventory_hostname] | dict2items | selectattr('key', 'match', '^knot_zone_.+$') | map(attribute='value') | list }}"
|
2021-11-05 12:58:53 +01:00
|
|
|
notify: restart knot
|
2024-05-05 13:13:58 +02:00
|
|
|
|
|
|
|
- name: Create knot zone directories
|
|
|
|
ansible.builtin.file:
|
|
|
|
path: "{{ item }}"
|
|
|
|
state: directory
|
|
|
|
owner: knot
|
|
|
|
group: knot
|
|
|
|
mode: "0750"
|
|
|
|
loop:
|
|
|
|
- "{{ knot_zone_master_storage_path }}"
|
|
|
|
- "{{ knot_zone_replica_storage_path }}"
|
|
|
|
|
|
|
|
- name: Make sure all zones have a name
|
|
|
|
ansible.builtin.assert:
|
|
|
|
that:
|
|
|
|
- "'name' in item.value"
|
|
|
|
- "item.value.name | type_debug == 'str'"
|
|
|
|
fail_msg: "{{ item.key }} does not have a name"
|
|
|
|
loop: "{{ hostvars[inventory_hostname] | dict2items | selectattr('key', 'match', '^knot_zone_.+$') | list }}"
|
|
|
|
|
|
|
|
- name: Make sure all zones have at least one master defined
|
|
|
|
ansible.builtin.assert:
|
|
|
|
that:
|
|
|
|
- "'masters' in item.value"
|
|
|
|
- "item.value.masters | type_debug == 'list'"
|
|
|
|
- "item.value.masters | length > 0"
|
|
|
|
fail_msg: "{{ item.key }} does not have a zone master"
|
|
|
|
loop: "{{ hostvars[inventory_hostname] | dict2items | selectattr('key', 'match', '^knot_zone_.+$') | list }}"
|
|
|
|
|
|
|
|
- name: Render knot zone files
|
|
|
|
ansible.builtin.template:
|
|
|
|
src: var/lib/knot/master/zone.j2
|
|
|
|
dest: "{{ knot_zone_master_storage_path }}/{{ item.name }}zone"
|
|
|
|
owner: knot
|
|
|
|
group: knot
|
|
|
|
mode: "0640"
|
2024-06-23 15:54:38 +02:00
|
|
|
validate: "/usr/bin/kzonecheck -o {{ item.name }} -v %s"
|
2024-05-05 13:13:58 +02:00
|
|
|
vars:
|
|
|
|
zone: "{{ item }}"
|
|
|
|
when: "inventory_hostname in item['masters']"
|
|
|
|
loop: "{{ hostvars[inventory_hostname] | dict2items | selectattr('key', 'match', '^knot_zone_.+$') | map(attribute='value') | list }}"
|
|
|
|
notify: reload knot
|
|
|
|
|
|
|
|
- name: Start and enable knot
|
|
|
|
ansible.builtin.service:
|
|
|
|
name: knot
|
|
|
|
state: started
|
|
|
|
enabled: true
|