add bind role
authorRalf Jung <post@ralfj.de>
Fri, 11 May 2018 17:15:38 +0000 (19:15 +0200)
committerRalf Jung <post@ralfj.de>
Fri, 11 May 2018 17:15:38 +0000 (19:15 +0200)
dns.yml [new file with mode: 0644]
roles/bind/files/Makefile [new file with mode: 0644]
roles/bind/tasks/main.yml [new file with mode: 0644]

diff --git a/dns.yml b/dns.yml
new file mode 100644 (file)
index 0000000..780bf21
--- /dev/null
+++ b/dns.yml
@@ -0,0 +1,3 @@
+- hosts: bind
+  roles:
+  - bind
diff --git a/roles/bind/files/Makefile b/roles/bind/files/Makefile
new file mode 100644 (file)
index 0000000..b8db07b
--- /dev/null
@@ -0,0 +1,19 @@
+include Makefile.conf
+
+user      ?= bind
+zonemaker ?= zonemaker/zonemaker
+RNDC      ?= /usr/sbin/rndc
+
+# heres comes the magic
+zonefiles = $(addprefix db.,${zones})
+all: ${zonefiles}
+.PHONY: all
+
+db.%: db.%.py
+       @echo $* $< $@
+       @sudo -u ${user} ${zonemaker} $< > $@ || rm -f $@
+       @cat $@
+       @echo
+       @${RNDC} reload $* # this only returns errors if the zone had not previously been loaded :-/
+       @sleep 1
+       @fgrep 'zone '$*'/IN' /var/log/syslog | tail -n 5
diff --git a/roles/bind/tasks/main.yml b/roles/bind/tasks/main.yml
new file mode 100644 (file)
index 0000000..beb8ea0
--- /dev/null
@@ -0,0 +1,31 @@
+- name: install bind
+  apt: name=bind9,hash-slinger state=latest
+- name: install zonemaker
+  git:
+    dest: /var/lib/bind/zonemaker
+    repo: 'https://git.ralfj.de/zonemaker.git'
+    version: master
+- name: install Makefile
+  copy:
+    dest: /var/lib/bind/Makefile
+    src: files/Makefile
+# dyn-nsupdate
+- name: install dyn-nsupdate build-deps
+  apt: name=libboost-regex-dev,libboost-program-options-dev,cmake state=latest
+- name: clone dyn-nsupdate
+  git:
+    dest: /var/lib/bind/dyn-nsupdate.d
+    repo: 'https://git.ralfj.de/dyn-nsupdate.git'
+    version: master
+  register: dyn_nsupdate_src
+- name: create build dir
+  file: path=/var/lib/bind/dyn-nsupdate.d/nsupd-wrapper/build state=directory owner=bind
+- name: compile dyn-nsupdate
+  when: dyn_nsupdate_src.changed
+  become_user: bind
+  shell: "cmake .. -DCMAKE_BUILD_TYPE=Release -DDYNNSUPDATE_CONFIG_FILE=/var/lib/bind/dyn-nsupdate.conf && make"
+  args:
+    chdir: /var/lib/bind/dyn-nsupdate.d/nsupd-wrapper/build
+- name: install dyn-nsupdate
+  when: dyn_nsupdate_src.changed
+  command: install /var/lib/bind/dyn-nsupdate.d/nsupd-wrapper/build/dyn-nsupdate /var/lib/bind/dyn-nsupdate -o bind -g bind -m +rx,u+ws