summaryrefslogtreecommitdiff
path: root/manifests/record.pp
diff options
context:
space:
mode:
authorHugo Hörnquist <hugo@lysator.liu.se>2023-05-05 00:31:37 +0200
committerHugo Hörnquist <hugo@lysator.liu.se>2023-05-05 00:31:37 +0200
commiteb38e6252b3c52a44d0d33679b3bc3178674c7f8 (patch)
treeb7958e38f9893c347af4c04a53f65a103cef3292 /manifests/record.pp
parentInitial commit (diff)
downloaddns-eb38e6252b3c52a44d0d33679b3bc3178674c7f8.tar.gz
dns-eb38e6252b3c52a44d0d33679b3bc3178674c7f8.tar.xz
Everything
Diffstat (limited to 'manifests/record.pp')
-rw-r--r--manifests/record.pp48
1 files changed, 48 insertions, 0 deletions
diff --git a/manifests/record.pp b/manifests/record.pp
new file mode 100644
index 0000000..83476a0
--- /dev/null
+++ b/manifests/record.pp
@@ -0,0 +1,48 @@
+# @param type
+# Record type (A, AAAA, ...)
+# @param class
+# DNS class type (IN, HS, CH, HS)
+# @param dns_name
+# Name of record (example.com.)
+# Note that the trailing period **IS** significant
+# @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 & NS.
+# @param zone
+# Name of the zone this record belongs to.
+# @param value
+# Record content.
+# Syntax depends on `type`.
+define dns::record (
+ String $zone,
+ Dns::Rr $type,
+ String $value,
+ Dns::Class $class = 'IN',
+ String $dns_name = $name,
+ Optional[Dns::Ttl] $ttl = undef,
+ Boolean $duplicate = false,
+) {
+ $allow_duplicate = case $type {
+ 'TXT',
+ 'NS': {
+ true
+ }
+ default: {
+ false
+ }
+ }
+
+ $frag_name = if $allow_duplicate {
+ "Dns::Record - ${zone} - ${class} ${type} ${dns_name} ${value}"
+ } else {
+ "Dns::Record - ${zone} - ${class} ${type} ${dns_name}"
+ }
+
+ concat::fragment { $frag_name:
+ target => "${dns::zone_directory}/${zone}.db",
+ }
+}