# @param zone # Domain this zone controls. # @param mname # Primary master # @param rname # mail to zone admin # @param retry # Retry value for zone # @param expire # Expire value for zone # @param negative_ttl # Negative ttl for zone # @param ttl # Default ttl for zone # @param refresh # Refresh value for SOA # @param records # Hash of records to create. Instanciates Dns::Record resources. # @param ns # List of nameservers for this zone. Creates Dns::Record resources # with NS entries. # @param type # Zonetype. master, slave, ... # @param update_policy # A bind9 update policy, as a string. # @param dynamic # However if this zone should be treated as a dynamic zone. If # enabled rndc freezes and thaws the zone around static updates. # Otherwise the zone file will be directly changed, and simply # reloaded afterwards. # # Defaults to true if an update_policy is set. # @param soa_ttl # TTL of SOA record. define dns::zone ( 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 = [$mname], String $type = 'master', Optional[String] $update_policy = undef, Boolean $dynamic = $update_policy != undef, ) { $zone_ = dns::ensure_ending_period($zone) $zone_serial = $facts.get("dns_zone_serial.'${zone_}'", 0) concat::fragment { "Dns::Zone - ${zone_}": target => $dns::config_file, content => epp("${module_name}/zoneconf.epp", { zone => $zone_, type => $type, update_policy => $update_policy, }), } # $ns.each |$ns| { # dns::record { "Dns::Zone - record - ${zone} NS ${ns}": # key => '@', # type => 'NS', # zone => $zone_, # value => $ns, # } # } # $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_, # }) $params = { 'rname' => $rname, 'mname' => $mname, 'refresh' => $refresh, 'expire' => $expire, 'negative_ttl' => $negative_ttl, 'soa_ttl' => $soa_ttl, 'retry' => $retry, } if $dynamic { 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_], refreshonly => true, subscribe => Dns_zone2[$zone_], } } else { dns_zone2 { $zone: * => $params, } exec { "Dns::zone reload ${zone_}": command => [$dns::rndc, 'reload', $zone_], refreshonly => true, subscribe => Dns_zone2[$zone_], } } }