From: Ralf Jung Date: Fri, 11 May 2018 17:15:38 +0000 (+0200) Subject: add bind role X-Git-Url: https://git.ralfj.de/ansible.git/commitdiff_plain/a48a0035e2c2e0ce00a8d08961536bcd3290c1e2?ds=sidebyside;hp=6fe1d02b761553a93b11c0029b8c4f3237837dba add bind role --- diff --git a/dns.yml b/dns.yml new file mode 100644 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 index 0000000..b8db07b --- /dev/null +++ b/roles/bind/files/Makefile @@ -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 index 0000000..beb8ea0 --- /dev/null +++ b/roles/bind/tasks/main.yml @@ -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