Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 29 additions & 0 deletions REFERENCE.md
Original file line number Diff line number Diff line change
Expand Up @@ -1437,6 +1437,8 @@ The following parameters are available in the `knot::domain` defined type:
* [`zone_csync`](#-knot--domain--zone_csync)
* [`zone_subzones`](#-knot--domain--zone_subzones)
* [`local_subzones`](#-knot--domain--local_subzones)
* [`catalog_entries`](#-knot--domain--catalog_entries)
* [`catalog_salt`](#-knot--domain--catalog_salt)

##### <a name="-knot--domain--ensure"></a>`ensure`

Expand Down Expand Up @@ -2047,6 +2049,33 @@ remark: only relevant if $manage_zone set to true

Default value: `[]`

##### <a name="-knot--domain--catalog_entries"></a>`catalog_entries`

Data type: `Hash[String[1],String[1]]`

if this domain is a catalog zone, this parameter let's you simplify
adding zone records to it.
example:
{ myzone.org => mygroup }
ends up in records like:
_unique-id.zones 0 IN PTR myzone.org
group._unique-id.zones 0 IN TXT "mygroup"
remark: only relevant if $manage_zone set to true

Default value: `{}`

##### <a name="-knot--domain--catalog_salt"></a>`catalog_salt`

Data type: `String[1]`

to generate the _unique-id of the catalog entries, the md5sum of
the zone, the group and this salt is used
per rfc, if the unique-id changes, the zone has to be deleted and
newly rebuild. Changing this salt lets you force a reload.
defaults to fqdn which result in a reload if name changes !

Default value: `$facts['networking']['fqdn']`

### <a name="knot--records--caa"></a>`knot::records::caa`

default values can be configured in the class
Expand Down
34 changes: 34 additions & 0 deletions manifests/domain.pp
Original file line number Diff line number Diff line change
Expand Up @@ -193,6 +193,21 @@
# - manage_zone is set to true for both domains
# Any violation of above restrictions is ignored.
# remark: only relevant if $manage_zone set to true
# @param catalog_entries
# if this domain is a catalog zone, this parameter let's you simplify
# adding zone records to it.
# example:
# { myzone.org => mygroup }
# ends up in records like:
# _unique-id.zones 0 IN PTR myzone.org
# group._unique-id.zones 0 IN TXT "mygroup"
# remark: only relevant if $manage_zone set to true
# @param catalog_salt
# to generate the _unique-id of the catalog entries, the md5sum of
# the zone, the group and this salt is used
# per rfc, if the unique-id changes, the zone has to be deleted and
# newly rebuild. Changing this salt lets you force a reload.
# defaults to fqdn which result in a reload if name changes !
#
define knot::domain (
Enum['absent', 'present'] $ensure = 'present',
Expand Down Expand Up @@ -265,6 +280,8 @@
Optional[Knot::Record::Csync] $zone_csync = undef,
Hash[String[1],Knot::Subzone] $zone_subzones = {},
Array[String[1]] $local_subzones = [],
Hash[String[1],String[1]] $catalog_entries = {},
String[1] $catalog_salt = $facts['networking']['fqdn'],
) {
knot::add_conf { $domain:
ensure => $ensure,
Expand Down Expand Up @@ -408,4 +425,21 @@
}
}
}
$catalog_entries.each | String[1] $z, String[1] $gr | {
$unique_id = md5([$z,$gr,$catalog_salt].join(':'))
knot_record { "Catalog for ${z} (${gr})":
target_zone => $domain,
rname => "${unique_id}.zones",
rtype => 'PTR',
rttl => 0,
rcontent => "${z}.",
}
knot_record { "Catalog group for ${z} (${gr})":
target_zone => $domain,
rname => "group.${unique_id}.zones",
rtype => 'TXT',
rttl => 0,
rcontent => "\"${gr}\"",
}
}
}
35 changes: 33 additions & 2 deletions spec/defines/domain_spec.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# frozen_string_literal: true

require 'spec_helper'
require 'digest'

describe 'knot::domain' do
let :default_params do
Expand All @@ -11,7 +12,8 @@
zone_serial_policy: 'increment',
zone_nameservers: [],
zone_subzones: {},
local_subzones: [] }
local_subzones: [],
catalog_entries: {}, }
end

shared_examples 'knot::domain shared examples' do
Expand Down Expand Up @@ -80,7 +82,22 @@
.with_rttl(params[:zone_nameservers_ttl])
.with_rcontent("#{params[:zone_csync][:serial]} #{params[:zone_csync][:flags]} #{params[:zone_csync][:value]}")
end
else
params[:catalog_entries].each do |z, g|
uniqueid = Digest::MD5.hexdigest([z, g, params[:catalog_salt]].join(':'))
is_expected.to contain_knot_record("Catalog for #{z} (#{g})")
.with_target_zone(params[:domain])
.with_rname("#{uniqueid}.zones")
.with_rtype('PTR')
.with_rttl(0)
.with_rcontent("#{z}.")
is_expected.to contain_knot_record("Catalog group for #{z} (#{g})")
.with_target_zone(params[:domain])
.with_rname("group.#{uniqueid}.zones")
.with_rtype('TXT')
.with_rttl(0)
.with_rcontent("\"#{g}\"")
end
else # params[:ensure] != 'present'
params[:zone_records].each do |r|
is_expected.not_to contain_knot_record("record #{r[:rname]}.#{params[:domain]} (#{i})")
end
Expand Down Expand Up @@ -167,6 +184,20 @@

it_behaves_like 'knot::domain shared examples'
end

context 'with a catalog zone' do
let(:title) { 'testdomain' }
let :params do
default_params.merge({ domain: 'catalog.zone',
manage_zone: true,
zone_records: [{ rname: 'verision', rtype: 'TXT', rcontent: '2' }],
zone_nameservers: ['ns1.example.org.'],
catalog_entries: { 'example.org' => 'secondary' },
catalog_salt: '42' })
end

it_behaves_like 'knot::domain shared examples'
end
end
end
end
Loading