Successfully notifying hurricane electric when DNS updates are pushed.

This commit is contained in:
Tom Alexander 2023-06-20 00:24:47 -04:00
parent 2e4c2c3f9b
commit e755cb4251
Signed by: talexander
GPG Key ID: D3A179C9A53C0EDE
3 changed files with 54 additions and 12 deletions

View File

@ -17,8 +17,8 @@ $ORIGIN fizz.buzz.
3600 IN NS ns1.he.net. 3600 IN NS ns1.he.net.
; Allow receiving mail at fizz.buzz ; Allow receiving mail at fizz.buzz
IN MX 10 in1-smtp.messagingengine.com IN MX 10 in1-smtp.messagingengine.com.
IN MX 20 in2-smtp.messagingengine.com IN MX 20 in2-smtp.messagingengine.com.
; Allows receivers to know you send your mail via Fastmail, and other servers ; Allows receivers to know you send your mail via Fastmail, and other servers
IN TXT v=spf1 include:spf.messagingengine.com ?all IN TXT v=spf1 include:spf.messagingengine.com ?all
@ -27,12 +27,12 @@ ns1 IN A 74.80.180.138
ns2 IN A 74.80.180.138 ns2 IN A 74.80.180.138
; Allow receiving mail on subdomains ; Allow receiving mail on subdomains
* IN MX 10 in1-smtp.messagingengine.com * IN MX 10 in1-smtp.messagingengine.com.
* IN MX 20 in2-smtp.messagingengine.com * IN MX 20 in2-smtp.messagingengine.com.
; The A-records for mail.fizz.buzz override the wildcard, so we have to manually re-create the MX records ; The A-records for mail.fizz.buzz override the wildcard, so we have to manually re-create the MX records
mail IN MX 10 in1-smtp.messagingengine.com mail IN MX 10 in1-smtp.messagingengine.com.
mail IN MX 20 in2-smtp.messagingengine.com mail IN MX 20 in2-smtp.messagingengine.com.
; Access webmail at mail.fizz.buzz ; Access webmail at mail.fizz.buzz
mail IN A 103.168.172.47 mail IN A 103.168.172.47

View File

@ -1,12 +1,13 @@
launch=gsqlite3 launch=gsqlite3
gsqlite3-database=/var/lib/powerdns/pdns.sqlite3 gsqlite3-database=/var/lib/powerdns/pdns.sqlite3
gsqlite3-pragma-foreign-keys=yes gsqlite3-pragma-foreign-keys=yes
master=yes primary=yes
allow-axfr-ips= allow-axfr-ips=
dnsupdate=yes dnsupdate=yes
allow-dnsupdate-from=10.215.1.0/24 allow-dnsupdate-from=
# Only notify on ipv4 # Only notify ns1.he.net
only-notify=0.0.0.0/0 only-notify=216.218.130.2/32, 10.215.1.0/24
also-notify=216.218.130.2
# Autogenerated configuration file template # Autogenerated configuration file template

View File

@ -23,6 +23,7 @@
group: pdns group: pdns
loop: loop:
- /var/lib/powerdns - /var/lib/powerdns
- /var/lib/powerdns/zones
- name: Copy files - name: Copy files
copy: copy:
@ -37,6 +38,17 @@
- src: bind.conf - src: bind.conf
dest: /usr/local/etc/pdns/ dest: /usr/local/etc/pdns/
- name: Copy files
copy:
src: "files/{{ item.src }}"
dest: "{{ item.dest }}"
mode: 0644
owner: pdns
group: pdns
loop:
- src: master.db
dest: /var/lib/powerdns/zones/
- name: Initialize DB - name: Initialize DB
command: "sudo -u pdns sqlite3 -init /usr/local/share/doc/powerdns/schema.sqlite3.sql /var/lib/powerdns/pdns.sqlite3" command: "sudo -u pdns sqlite3 -init /usr/local/share/doc/powerdns/schema.sqlite3.sql /var/lib/powerdns/pdns.sqlite3"
register: initdb register: initdb
@ -47,8 +59,6 @@
when: initdb.changed when: initdb.changed
register: initsql register: initsql
command: "sudo -u pdns zone2sql zone2sql --gsqlite=yes --named-conf=/usr/local/etc/pdns/bind.conf --transactions=yes" command: "sudo -u pdns zone2sql zone2sql --gsqlite=yes --named-conf=/usr/local/etc/pdns/bind.conf --transactions=yes"
args:
stdin: "{{ lookup('file', 'master.db') }}"
- name: Initialize DB - name: Initialize DB
when: initdb.changed when: initdb.changed
@ -103,3 +113,34 @@
- name: Allow AXFR from the externaldns tsig key - name: Allow AXFR from the externaldns tsig key
command: pdnsutil add-meta fizz.buzz TSIG-ALLOW-AXFR externaldns command: pdnsutil add-meta fizz.buzz TSIG-ALLOW-AXFR externaldns
when: '"externaldns" not in tsigaxfr.stdout' when: '"externaldns" not in tsigaxfr.stdout'
- name: Check AXFR-MASTER-TSIG
command: pdnsutil get-meta fizz.buzz AXFR-MASTER-TSIG
register: signnotify
changed_when: false
check_mode: no
- name: Sign the notifications
command: pdnsutil set-meta fizz.buzz AXFR-MASTER-TSIG secureaxfr
when: '"secureaxfr" not in signnotify.stdout'
- name: Check NOTIFY-DNSUPDATE
command: pdnsutil get-meta fizz.buzz NOTIFY-DNSUPDATE
register: notifydnsupdate
changed_when: false
check_mode: no
- name: Send out notifications on dns update
command: pdnsutil set-meta fizz.buzz NOTIFY-DNSUPDATE 1
when: '"1" not in notifydnsupdate.stdout'
- name: Check zone kind
command: pdnsutil show-zone fizz.buzz
register: showzone
changed_when: false
check_mode: no
- name: Set to Master to enable pushing updates
command: pdnsutil set-kind fizz.buzz primary
when: '"Master" not in showzone.stdout'