From 510a3014391d056a26555a5be1320c3f1b94f796 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Hugo=20H=C3=B6rnquist?= Date: Thu, 4 Nov 2021 18:33:21 +0100 Subject: Set up nsupdate. --- modules/nsupdate/templates/nsupdate.epp | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) create mode 100644 modules/nsupdate/templates/nsupdate.epp (limited to 'modules/nsupdate/templates/nsupdate.epp') diff --git a/modules/nsupdate/templates/nsupdate.epp b/modules/nsupdate/templates/nsupdate.epp new file mode 100644 index 0000000..66fe4b2 --- /dev/null +++ b/modules/nsupdate/templates/nsupdate.epp @@ -0,0 +1,18 @@ +<%- | + String $iface, + String $nameserver, + String $keyname, + Array[DNSRecord] $records, +| -%> +#!/bin/bash + +IP=$(ip -j a show dev <%= $iface %> | jq --raw-output '.[0].addr_info[] | select(.family == "inet").local') + +nsupdate "$@" -k '/var/lib/nsupdate/<%= $keyname %>.key' << EOF +server <%= $nameserver %> +<%- $records.each |$record| { -%> +update delete <%= $record['domain'] %> <%= $record['type'] %> +update add <%= $record['domain'] %> <%= $record['ttl'] %> <%= $record['type'] %> ${IP} +<%- } -%> +send +EOF -- cgit v1.2.3