diff options
author | Hugo Hörnquist <hugo@lysator.liu.se> | 2023-05-05 01:46:46 +0200 |
---|---|---|
committer | Hugo Hörnquist <hugo@lysator.liu.se> | 2023-06-06 18:31:17 +0200 |
commit | 812c3f4d6162cf7af8f8cbedb6abb6d72bd537e9 (patch) | |
tree | 109619457ac9b9028eae7297c4f72deadad68c52 /manifests/zone.pp | |
parent | tmp disable creation. (diff) | |
download | dns-812c3f4d6162cf7af8f8cbedb6abb6d72bd537e9.tar.gz dns-812c3f4d6162cf7af8f8cbedb6abb6d72bd537e9.tar.xz |
"Working" product.
Diffstat (limited to 'manifests/zone.pp')
-rw-r--r-- | manifests/zone.pp | 96 |
1 files changed, 50 insertions, 46 deletions
diff --git a/manifests/zone.pp b/manifests/zone.pp index 954ff48..33c2b0d 100644 --- a/manifests/zone.pp +++ b/manifests/zone.pp @@ -30,21 +30,25 @@ # reloaded afterwards. # # Defaults to true if an update_policy is set. +# @param soa_ttl +# TTL of SOA record. define dns::zone ( - String $mname, - String $rname, + Boolean $manage_soa = true, + String $rname = undef, + String $mname = $ns[0], Dns::Ttl $refresh = '24h', Dns::Ttl $retry = '2h', Dns::Ttl $expire = '1000h', Dns::Ttl $negative_ttl = '2d', Dns::Ttl $ttl = '24h', + Optional[Dns::Ttl] $soa_ttl = undef, String $zone = $name, Array[Dns::RecordEntry] $records = [], - Array[String] $ns = [], + Array[String] $ns = [$mname], String $type = 'master', @@ -53,30 +57,9 @@ define dns::zone ( ) { $zone_ = dns::ensure_ending_period($zone) - concat { "${dns::zone_directory}/${zone}.db": - validate_cmd => "${dns::checkzone} '${zone}' %", - ensure_newline => true, - require => if $dynamic { Exec["Dns::zone freeze ${zone}"] } else { undef }, - } - $zone_serial = $facts.get("dns_zone_serial.'${zone_}'", 0) - concat::fragment { "Dns::Record - ${zone} - SOA": - target => "${dns::zone_directory}/${zone}.db", - order => '01', - content => epp("${module_name}/zone.epp", { - zone => $zone_, - mname => dns::ensure_ending_period($mname), - rname => dns::convert_to_rname($rname), - serial => $zone_serial + 1, - refresh => $refresh, - expire => $expire, - negative_ttl => $negative_ttl, - default_ttl => $ttl, - }), - } - - concat::fragment { "Dns::Zone - ${zone}": + concat::fragment { "Dns::Zone - ${zone_}": target => $dns::config_file, content => epp("${module_name}/zoneconf.epp", { zone => $zone_, @@ -85,38 +68,59 @@ define dns::zone ( }), } - $ns.each |$ns| { - dns::record { "Dns::Zore - record - ${zone} NS ${ns}": - type => 'NS', - zone => $zone, - } - } + # $ns.each |$ns| { + # dns::record { "Dns::Zone - record - ${zone} NS ${ns}": + # key => '@', + # type => 'NS', + # zone => $zone_, + # value => $ns, + # } + # } - $fixed_records = $records.each |$record| { - { "Dns::Zone - record - ${zone} - ${record['class']} ${record['type']} ${record['key']} ${record['value']}" - => $record + { dns_name => $record['key'] } } - } + # $fixed_records = $records.map |$record| { + # ["Dns::Zone - record - ${zone_} - ${record['class']} ${record['type']} ${record['key']} ${record['value']}", + # $record + { key => $record['key'] } - ['key']] + # }.convert_to(Hash) + + # create_resources(dns::record, $fixed_records, { + # zone => $zone_, + # }) - create_resources(dns::record, $fixed_records, { - zone => $zone, - }) + $params = { + 'rname' => $rname, + 'mname' => $mname, + 'refresh' => $refresh, + 'expire' => $expire, + 'negative_ttl' => $negative_ttl, + 'soa_ttl' => $soa_ttl, + 'retry' => $retry, + } if $dynamic { - exec { "Dns::zone freeze ${zone}": - command => [$dns::rndc, 'freeze', $zone], + dns_zone2 { $zone: + require => Exec["Dns::zone freeze ${zone_}"], + * => $params, + } + + exec { "Dns::zone freeze ${zone_}": + command => [$dns::rndc, 'freeze', $zone_], refreshonly => true, } - exec { "Dns::zone thaw ${zone}": - command => [$dns::rndc, 'thaw', $zone], + exec { "Dns::zone thaw ${zone_}": + command => [$dns::rndc, 'thaw', $zone_], refreshonly => true, - subscribe => Concat["${dns::zone_directory}/${zone}.db"], + subscribe => Dns_zone2[$zone_], } } else { - exec { "Dns::zone reload ${zone}": - command => [$dns::rndc, 'reload', $zone], + dns_zone2 { $zone: + * => $params, + } + + exec { "Dns::zone reload ${zone_}": + command => [$dns::rndc, 'reload', $zone_], refreshonly => true, - subscribe => Concat["${dns::zone_directory}/${zone}.db"], + subscribe => Dns_zone2[$zone_], } } } |