# @summary A single DNS record # # @example # dns::record { 'A www.example.com': # zone => 'example.com', # key => 'www', # value => '203.0.113.4', # } # # @param type # Record type (A, AAAA, ...) # @param cls # DNS class type (IN, HS, CH, HS) # @param ttl # TTL for record. # @param duplicate # Allow multiple records with the same name and class. # Most record types only allow one value, but some allow multiple. # Setting this to true allows for multiple. This value is # automatically true for TXT, MX & NS. # @param zone # Name of the zone this record belongs to. # @param value # Record content. # Syntax depends on `type`. # Some record types have extra processing. # TXT splits data into chunks of 255 characters (TODO shouldn't # this be bytes) and the surrounds each chunk with quotation marks. # @param key # DNS key. Will be treated as absolute if ending with a period, or # relative to the zone if not. '@' for the "empty" key. # TODO tests for above? define dns::record ( Dns::Zonename $zone, Dns::Rr $type, String $value, Dns::Class $cls = 'IN', String $key = '@', Optional[Dns::Ttl] $ttl = undef, Boolean $duplicate = false, ) { $allow_duplicate = case $type { 'TXT', 'MX', 'NS': { true } default: { false } } $value_ = case $type { 'TXT': { $value.slice(255).map |$x| { "\"${x.join()}\"" }.join(' ') } default: { $value } } dns_record2 { $name: type => $type, value => $value_, cls => $cls, zone => $zone, ttl => $ttl, key => $key, named_checkzone => $dns::checkzone, } }