--- /dev/null
+#! /bin/sh
+
+if [ -z "$1" ]; then
+ echo "Usage: $0 domain" >&2
+ exit 1
+fi
+
+domain="$1"
+shift
+
+cd "`dirname \"$0\"`" &&
+ANSIBLE_ROLES_PATH=debian/roles \
+ exec ./run-role add-dns-domain "$@" -e domain="$domain"
--- /dev/null
+- name: Check domain
+ stat:
+ path: "/etc/bind/{{ domain }}"
+ register: domain_exists
+
+- name: Copy domain template
+ become: true
+ template:
+ src: domain
+ dest: "/etc/bind/{{ domain }}"
+ owner: bind
+ group: bind
+ mode: '0600'
+ force: no
+ when: not domain_exists.stat.exists
+
+- name: Update config
+ become: true
+ shell: |
+echo '
+
+zone "{{ domain }}" {
+ type master;
+ file "/etc/bind/{{ domain }}";
+ allow-query { any; };
+ notify yes;
+};
+' >> /etc/bind/named.conf.local
+
+
+ when: not domain_exists.stat.exists
+
+- name: Reload BIND
+ become: true
+ service:
+ name: bind9
+ state: reloaded
+ when: not domain_exists.stat.exists
--- /dev/null
+$TTL 86400
+@ IN SOA ns1.{{ domain }}. hostmaster.{{ domain }}. (
+ {{ now().strftime('%Y%m%d') }}00 ; Serial
+ 86400 ; Refresh 1d
+ 3600 ; Retry 1h
+ 2419200 ; Expire 28 days
+ 86400) ; Default TTL 1d
+
+ IN NS ns1.{{ domain }}.
+ IN A ???
+ns1 IN A ???
+www IN CNAME {{ domain }}.