From 812c3f4d6162cf7af8f8cbedb6abb6d72bd537e9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Hugo=20H=C3=B6rnquist?= Date: Fri, 5 May 2023 01:46:46 +0200 Subject: "Working" product. --- manifests/record.pp | 32 +++++++++++++++++++++++--------- 1 file changed, 23 insertions(+), 9 deletions(-) (limited to 'manifests/record.pp') diff --git a/manifests/record.pp b/manifests/record.pp index 83476a0..2ecb52f 100644 --- a/manifests/record.pp +++ b/manifests/record.pp @@ -11,23 +11,29 @@ # 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 & NS. +# 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. define dns::record ( String $zone, Dns::Rr $type, String $value, - Dns::Class $class = 'IN', - String $dns_name = $name, + Dns::Class $cls = 'IN', + String $key = $name, Optional[Dns::Ttl] $ttl = undef, Boolean $duplicate = false, ) { + $zone_ = dns::ensure_ending_period($zone) + $allow_duplicate = case $type { 'TXT', + 'MX', 'NS': { true } @@ -36,13 +42,21 @@ define dns::record ( } } - $frag_name = if $allow_duplicate { - "Dns::Record - ${zone} - ${class} ${type} ${dns_name} ${value}" - } else { - "Dns::Record - ${zone} - ${class} ${type} ${dns_name}" + $value_ = case $type { + 'TXT': { + $value.slice(255).map |$x| { "\"${x.join()}\"" }.join(' ') + } + default: { + $value + } } - concat::fragment { $frag_name: - target => "${dns::zone_directory}/${zone}.db", + dns_record2 { $name: + type => $type, + value => $value_, + cls => $cls, + zone => $zone, + ttl => $ttl, + key => $key, } } -- cgit v1.2.3