aboutsummaryrefslogtreecommitdiffstats
path: root/roles/dns/tasks
diff options
context:
space:
mode:
Diffstat (limited to 'roles/dns/tasks')
-rw-r--r--roles/dns/tasks/main.yml24
1 files changed, 20 insertions, 4 deletions
diff --git a/roles/dns/tasks/main.yml b/roles/dns/tasks/main.yml
index efc9669..68663f7 100644
--- a/roles/dns/tasks/main.yml
+++ b/roles/dns/tasks/main.yml
@@ -58,18 +58,34 @@
command: nsd-control-setup
when: not stat_result.stat.exists
+- name: NSD - get the list of zone files
+ set_fact:
+ zonefiles: "{{ lookup('fileglob', '../templates/zones/*.j2', wantlist=True) }}"
+
+- debug: var=zonefiles
+
- name: NSD - create zones directory
file:
path: /usr/local/etc/nsd/zones
state: directory
- name: NSD - generate zone files
+ vars:
+ domain: "{{ item | basename | regex_replace('\\.zone\\.j2', '') }}"
template:
src: "{{ item }}"
- dest: /usr/local/etc/nsd/zones/{{ item | basename | regex_replace('\.j2', '') }}
- # NOTE: `with_fileglob` always operates from `files/`
- with_fileglob:
- - "../templates/zones/*.j2"
+ dest: "/usr/local/etc/nsd/zones/{{ domain }}.zone"
+ # XXX: `validate` doesn't work with `with_items`???
+ validate: "nsd-checkzone {{ domain }} %s"
+ with_items: "{{ zonefiles }}"
+ notify: reload-nsd
+
+# XXX: the above `validate` doesn't work with `with_items`???
+- name: NSD - check zone files
+ vars:
+ domain: "{{ item | basename | regex_replace('\\.zone\\.j2', '') }}"
+ command: "nsd-checkzone {{ domain }} /usr/local/etc/nsd/zones/{{ domain }}.zone"
+ with_items: "{{ zonefiles }}"
# NOTE: requires variable `zonefiles`
- name: NSD - generate configuration