diff options
author | Hugo Hörnquist <hugo@lysator.liu.se> | 2022-02-14 19:34:47 +0100 |
---|---|---|
committer | Hugo Hörnquist <hugo@lysator.liu.se> | 2022-02-14 19:45:16 +0100 |
commit | 4622d7afd1e1c76151b1635c90e28988cb09f6c5 (patch) | |
tree | 336a65965cbb456fe4fdfe94a8b5d213068a879d | |
parent | Replace select with reject. (diff) | |
download | dns_record-4622d7afd1e1c76151b1635c90e28988cb09f6c5.tar.gz dns_record-4622d7afd1e1c76151b1635c90e28988cb09f6c5.tar.xz |
Add automatic reverse zone.
-rw-r--r-- | lib/puppet/functions/dns_record/rev_record.rb | 18 | ||||
-rw-r--r-- | lib/puppet/type/dns_record.rb | 2 |
2 files changed, 19 insertions, 1 deletions
diff --git a/lib/puppet/functions/dns_record/rev_record.rb b/lib/puppet/functions/dns_record/rev_record.rb new file mode 100644 index 0000000..4b1d34e --- /dev/null +++ b/lib/puppet/functions/dns_record/rev_record.rb @@ -0,0 +1,18 @@ +require 'ipaddr' + +Puppet::Functions.create_function(:'dns_record::rev_record') do + dispatch :rev_record do + param 'Stdlib::IP::Address::V6::Nosubnet', :ip + param 'Stdlib::IP::Address::V6::Nosubnet', :netmask + return_type 'Tuple[String,2]' + end + + def rev_record(ip, netmask) + cidr = IPAddr.new("::/#{netmask}").prefix + addr = IPAddr.new ip + parts = addr.ip6_arpa.split('.') + + [ parts.take(cidr/4).join('.'), + parts.drop(cidr/4).join('.') ] + end +end diff --git a/lib/puppet/type/dns_record.rb b/lib/puppet/type/dns_record.rb index 0e22156..7f212dd 100644 --- a/lib/puppet/type/dns_record.rb +++ b/lib/puppet/type/dns_record.rb @@ -20,7 +20,7 @@ Puppet::Type.newtype(:dns_record) do newproperty(:type) do desc "DNS Record type, such as A, or TXT" - newvalues(:A, :AAAA, :CNAME, :NS) + newvalues(:A, :AAAA, :CNAME, :NS, :PTR) isrequired end |