From 3c3afcfb580fa7c3e43412df8bd07b1f60c94ce2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Hugo=20H=C3=B6rnquist?= Date: Tue, 6 Jun 2023 21:41:12 +0200 Subject: Change to new DNS module. --- manifests/dns.pp | 10 +++++++++ manifests/dns_zones.pp | 56 ------------------------------------------------ manifests/publish_dns.pp | 11 +++++----- 3 files changed, 15 insertions(+), 62 deletions(-) create mode 100644 manifests/dns.pp delete mode 100644 manifests/dns_zones.pp (limited to 'manifests') diff --git a/manifests/dns.pp b/manifests/dns.pp new file mode 100644 index 0000000..bd24bde --- /dev/null +++ b/manifests/dns.pp @@ -0,0 +1,10 @@ +# Simple profile for testing DNS module +class profiles::dns ( + Array[String] $realized_zones = [], +) { + include ::dns + + $realized_zones.each |$zone| { + Dns::Record <<| zone == $zone |>> + } +} diff --git a/manifests/dns_zones.pp b/manifests/dns_zones.pp deleted file mode 100644 index eea3dd6..0000000 --- a/manifests/dns_zones.pp +++ /dev/null @@ -1,56 +0,0 @@ -# Sets up our dns-server, assumes that all zone information comes from -# hiera. -class profiles::dns_zones ( - Hash $zones, - Hash $default = {}, - Optional[Hash] $views = undef, - Hash $view_defaults = {}, - String $default_view = '_GLOBAL_', - Hash $zonedata_default = {}, - Hash[String,Hash] $zonedata = {}, - Hash[String,Array[Hash]] $records = {}, -) { - - if $views != undef { - class { 'dns': - enable_views => true, - } - create_resources(dns::view, $views, $view_defaults) - } else { - include ::dns - } - - create_resources(dns::zone, $zones, $default) - - create_resources(dns_zone, $zonedata, $zonedata_default) - - $zonedata.each |$zone, $_| { - Dns_record <<| zone == $zone |>> - - # This breaks if views are used - # "rndc reload $zone IN $view" works, but then we have too loop - # somehow - exec { "reload ${zone}": - command => ['rndc' ,'reload', $zone], - path => ['/usr/bin', '/usr/sbin'], - refreshonly => true, - subscribe => Dns_zone[$zone], - } - } - - $records.each |$zone, $record_entries| { - $zone_hash = $record_entries.map |$d| { - $type = $d['type'] - $key = $d['key'] - $value = $d['value'] - ["${zone} ${type} ${key} ${value}", $d] - } - - create_resources(dns_record, Hash($zone_hash), { - 'zone' => $zone, - }) - - } - - -} diff --git a/manifests/publish_dns.pp b/manifests/publish_dns.pp index df10854..f88292f 100644 --- a/manifests/publish_dns.pp +++ b/manifests/publish_dns.pp @@ -2,22 +2,21 @@ class profiles::publish_dns ( ) { if fact('ipaddress6') { - - @@dns_record { "AAAA automatic ${::fqdn}": + @@dns::record { "AAAA automatic ${::fqdn}": type => 'AAAA', - zone => $facts['domain'], + zone => "${$facts['domain']}.", key => $facts['hostname'], value => $facts['ipaddress6'], } - [$record, $zone] = dns_record::rev_record( + [$record, $zone] = dns::rev_record( $facts['networking']['ip6'], $facts['networking']['netmask6']) - @@dns_record { "PTR automatic ${::fqdn}": + @@dns::record { "PTR automatic ${::fqdn}": type => 'PTR', - zone => $zone, + zone => "${zone}.", key => $record, value => "${::fqdn}.", } -- cgit v1.2.3