1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
|
# type DNSRecordType = ['A', 'AAAA', 'AFSDB', 'APL', 'CAA', 'CDNSKEY', 'CDS',
# 'CERT', 'CNAME', 'CSYNC', 'DHCID', 'DLV', 'DNAME', 'DNSKEY', 'DS', 'EUI48',
# 'EUI64', 'HINFO', 'HIP', 'HTTPS', 'IPSECKEY', 'KEY', 'KX', 'LOC', 'MX',
# 'NAPTR', 'NS', 'NSEC', 'NSEC3', 'NSEC3PARAM', 'OPENPGPKEY', 'PTR', 'RRSIG',
# 'RP', 'SIG', 'SMIMEA', 'SOA', 'SRV', 'SSHFP', 'SVCB', 'TA', 'TKEY', 'TLSA',
# 'TSIG', 'TXT', 'URI', 'ZA', 'AAAA', 'AFSDB', 'APL', 'CAA', 'CDNSKEY', 'CDS',
# 'CERT', 'CNAME', 'CSYNC', 'DHCID', 'DLV', 'DNAME', 'DNSKEY', 'DS', 'EUI48',
# 'EUI64', 'HINFO', 'HIP', 'HTTPS', 'IPSECKEY', 'KEY', 'KX', 'LOC', 'MX',
# 'NAPTR', 'NS', 'NSEC', 'NSEC3', 'NSEC3PARAM', 'OPENPGPKEY', 'PTR', 'RRSIG',
# 'RP', 'SIG', 'SMIMEA', 'SOA', 'SRV', 'SSHFP', 'SVCB', 'TA', 'TKEY', 'TLSA',
# 'TSIG', 'TXT', 'URI', 'ZONEMD']
type DNSRecordType = Enum['A']
type DNSRecord = Struct[{
domain => String,
type => DNSRecordType,
ttl => Integer,
}]
# Sets up a single instance of a reoccuring nsupdate.
# Note that nsupdate::secret.$keyname needs to be made available through hiera
# /etc/puppetlabs/code/environments/production/data/nodes/hornquist.se.yaml
define nsupdate (
String $nameserver,
Array[DNSRecord] $records,
String $iface = $facts['networking']['primary'],
Enum['present', 'absent'] $ensure = present,
String $keyname = $name,
) {
require ::nsupdate::setup
file { "/usr/libexec/nsupdate/${name}":
ensure => $ensure,
mode => '0555',
content => epp('nsupdate/nsupdate.epp', {
iface => $iface,
nameserver => $nameserver,
records => $records,
keyname => $keyname,
})
}
$key = lookup("nsupdate::secrets.\"${keyname}\"")
$secret = Sensitive($key['secret'])
file { "/var/lib/nsupdate/${keyname}.key":
ensure => file,
mode => '0400',
show_diff => false,
content => @("EOF")
key "${keyname}" {
algorithm ${key['algorithm']};
secret "${secret.unwrap}";
};
| EOF
}
cron { "nsupdate ${name}":
ensure => $ensure,
command => "/usr/libexec/nsupdate/${name}",
minute => 0,
}
}
|