Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

conf_d: merge the unbound_conf_d and conf_d params #350

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
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
15 changes: 3 additions & 12 deletions REFERENCE.md
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,7 @@ The following parameters are available in the `unbound` class:
* [`username`](#-unbound--username)
* [`package_name`](#-unbound--package_name)
* [`package_ensure`](#-unbound--package_ensure)
* [`purge_unbound_conf_d`](#-unbound--purge_unbound_conf_d)
* [`purge_conf_d`](#-unbound--purge_conf_d)
* [`root_hints_url`](#-unbound--root_hints_url)
* [`runtime_dir`](#-unbound--runtime_dir)
* [`auto_trust_anchor_file`](#-unbound--auto_trust_anchor_file)
Expand Down Expand Up @@ -244,7 +244,6 @@ The following parameters are available in the `unbound` class:
* [`redis_server_host`](#-unbound--redis_server_host)
* [`redis_server_port`](#-unbound--redis_server_port)
* [`redis_timeout`](#-unbound--redis_timeout)
* [`unbound_conf_d`](#-unbound--unbound_conf_d)
* [`hints_file`](#-unbound--hints_file)
* [`update_root_hints`](#-unbound--update_root_hints)
* [`hints_file_content`](#-unbound--hints_file_content)
Expand Down Expand Up @@ -1571,11 +1570,11 @@ the ensure value for the packages

Default value: `'installed'`

##### <a name="-unbound--purge_unbound_conf_d"></a>`purge_unbound_conf_d`
##### <a name="-unbound--purge_conf_d"></a>`purge_conf_d`

Data type: `Boolean`

if true all unmanaged files in $unbound_conf_d will be purged
if true purge all unmanaged files in conf_d folder

Default value: `false`

Expand Down Expand Up @@ -1867,14 +1866,6 @@ see https://nlnetlabs.nl/documentation/unbound/unbound.conf/

Default value: `100`

##### <a name="-unbound--unbound_conf_d"></a>`unbound_conf_d`

Data type: `Stdlib::Absolutepath`

similar to conf_d, will be merged with conf_d version in future

Default value: `"${confdir}/unbound.conf.d"`

##### <a name="-unbound--hints_file"></a>`hints_file`

Data type: `Unbound::Hints_file`
Expand Down
3 changes: 2 additions & 1 deletion data/os/Debian.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
---
unbound::pidfile: '/run/unbound.pid'
unbound::runtime_dir: '/var/lib/unbound'
unbound::purge_unbound_conf_d: true
unbound::conf_d: "%{lookup('confdir')}/unbound.conf.d"
unbound::purge_conf_d: true
17 changes: 7 additions & 10 deletions manifests/init.pp
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@
# @param username see https://nlnetlabs.nl/documentation/unbound/unbound.conf/
# @param package_name The package(s) to install to get unbound
# @param package_ensure the ensure value for the packages
# @param purge_unbound_conf_d if true all unmanaged files in $unbound_conf_d will be purged
# @param purge_conf_d if true purge all unmanaged files in conf_d folder
# @param root_hints_url the url to download the root hints file
# @param runtime_dir the runtime directory used
# @param auto_trust_anchor_file see https://nlnetlabs.nl/documentation/unbound/unbound.conf/
Expand Down Expand Up @@ -203,7 +203,6 @@
# @param redis_server_host see https://nlnetlabs.nl/documentation/unbound/unbound.conf/
# @param redis_server_port see https://nlnetlabs.nl/documentation/unbound/unbound.conf/
# @param redis_timeout see https://nlnetlabs.nl/documentation/unbound/unbound.conf/
# @param unbound_conf_d similar to conf_d, will be merged with conf_d version in future
# @param hints_file the root hints file to use
# @param update_root_hints f we should update the root hints file
# @param hints_file_content the contents of the root hints file
Expand Down Expand Up @@ -377,7 +376,7 @@
# OpenBSD sets this to an empty string
Variant[String,Array] $package_name = 'unbound',
String[1] $package_ensure = 'installed',
Boolean $purge_unbound_conf_d = false,
Boolean $purge_conf_d = false,
String[1] $root_hints_url = 'https://www.internic.net/domain/named.root',
Stdlib::Absolutepath $runtime_dir = $confdir,
Stdlib::Absolutepath $auto_trust_anchor_file = "${runtime_dir}/root.key",
Expand Down Expand Up @@ -414,14 +413,13 @@
String[1] $redis_server_host = '127.0.0.1',
Integer[1,65536] $redis_server_port = 6379,
Integer[1] $redis_timeout = 100,
Stdlib::Absolutepath $unbound_conf_d = "${confdir}/unbound.conf.d",
Unbound::Hints_file $hints_file = "${confdir}/root.hints",
Enum['absent','present','unmanaged'] $update_root_hints = fact('systemd') ? { true => 'present', default => 'unmanaged' },
Optional[String[1]] $hints_file_content = undef,
Hash[String[1], Unbound::Rpz] $rpzs = {},
Optional[String[1]] $unbound_version = $facts['unbound_version'],
) {
$_base_dirs = [$confdir, $conf_d, $keys_d, $runtime_dir]
$_base_dirs = [$confdir, $keys_d, $runtime_dir]
$_piddir = if $pidfile { dirname($pidfile) } else { undef }
if $_piddir and !($_piddir in ['/run', '/var/run']) {
$dirs = unique($_base_dirs + [$_piddir])
Expand Down Expand Up @@ -541,12 +539,11 @@
}

# purge unmanaged files in configuration directory
file { $unbound_conf_d:
file { $conf_d:
ensure => 'directory',
owner => 'root',
group => '0',
purge => $purge_unbound_conf_d,
recurse => $purge_unbound_conf_d,
owner => $owner,
purge => $purge_conf_d,
recurse => $purge_conf_d,
}

concat { $config_file:
Expand Down
35 changes: 21 additions & 14 deletions spec/classes/init_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,10 @@
on_supported_os.each do |os, facts|
context "on #{os}" do
let(:facts) { facts.merge(concat_basedir: '/dne') }
let(:package) { 'unbound' }
let(:conf_file) { "#{conf_dir}/unbound.conf" }
let(:conf_d_dir) { "#{conf_dir}/conf.d" }
let(:unbound_conf_d) { "#{conf_dir}/unbound.conf.d" }
let(:keys_d_dir) { "#{conf_dir}/keys.d" }
let(:hints_file) { "#{conf_dir}/root.hints" }
let(:package) { 'unbound' }

pidfile = nil

Expand All @@ -23,33 +21,44 @@
pidfile = '/run/unbound.pid'
let(:service) { 'unbound' }
let(:conf_dir) { '/etc/unbound' }
let(:purge_unbound_conf_d) { true }
let(:purge_conf_d) { true }
let(:control_path) { '/usr/sbin/unbound-control' }
when 'OpenBSD'
pidfile = '/var/run/unbound.pid'
let(:service) { 'unbound' }
let(:conf_dir) { '/var/unbound/etc' }
let(:purge_unbound_conf_d) { false }
let(:purge_conf_d) { false }
let(:control_path) { '/usr/sbin/unbound-control' }
when 'FreeBSD'
pidfile = '/usr/local/etc/unbound/unbound.pid'
let(:service) { 'unbound' }
let(:conf_dir) { '/usr/local/etc/unbound' }
let(:purge_unbound_conf_d) { false }
let(:purge_conf_d) { false }
let(:control_path) { '/usr/local/sbin/unbound-control' }
when 'Darwin'
pidfile = '/var/run/unbound.pid'
let(:service) { 'org.macports.unbound' }
let(:conf_dir) { '/opt/local//etc/unbound' }
let(:purge_unbound_conf_d) { false }
let(:purge_conf_d) { false }
else
pidfile = '/var/run/unbound/unbound.pid'
let(:service) { 'unbound' }
let(:conf_dir) { '/etc/unbound' }
let(:purge_unbound_conf_d) { false }
let(:purge_conf_d) { false }
let(:control_path) { '/usr/sbin/unbound-control' }
end

if facts[:os]['family'] == 'Archlinux'
let(:owner) { 'root' }
else
let(:owner) { 'unbound' }
end
if facts[:os]['family'] == 'Debian'
let(:conf_d_dir) { "#{conf_dir}/unbound.conf.d" }
else
let(:conf_d_dir) { "#{conf_dir}/conf.d" }
end

context 'with default params' do
it { is_expected.to compile.with_all_deps }
it { is_expected.to contain_class('unbound') }
Expand All @@ -58,7 +67,6 @@
it { is_expected.to contain_service(service) }
it { is_expected.to contain_concat(conf_file) }
it { is_expected.to contain_file(conf_dir) }
it { is_expected.to contain_file(conf_d_dir) }
it { is_expected.to contain_file(keys_d_dir) }
it { is_expected.to contain_file(hints_file) }

Expand All @@ -66,13 +74,12 @@
it { is_expected.to contain_systemd__timer('roothints.timer') }
end

it do

Check failure on line 77 in spec/classes/init_spec.rb

View workflow job for this annotation

GitHub Actions / Puppet / 8 (Ruby 3.2)

unbound on debian-11-x86_64 with default params is expected to contain File[/etc/unbound/unbound.conf.d] with ensure => "directory", owner => "unbound", purge => true and recurse => true Failure/Error: expect(subject).to contain_file(conf_d_dir).with( 'ensure' => 'directory', 'owner' => owner, 'purge' => purge_conf_d, 'recurse' => purge_conf_d ) expected that the catalogue would contain File[/etc/unbound/unbound.conf.d]

Check failure on line 77 in spec/classes/init_spec.rb

View workflow job for this annotation

GitHub Actions / Puppet / 8 (Ruby 3.2)

unbound on debian-12-x86_64 with default params is expected to contain File[/etc/unbound/unbound.conf.d] with ensure => "directory", owner => "unbound", purge => true and recurse => true Failure/Error: expect(subject).to contain_file(conf_d_dir).with( 'ensure' => 'directory', 'owner' => owner, 'purge' => purge_conf_d, 'recurse' => purge_conf_d ) expected that the catalogue would contain File[/etc/unbound/unbound.conf.d]

Check failure on line 77 in spec/classes/init_spec.rb

View workflow job for this annotation

GitHub Actions / Puppet / 8 (Ruby 3.2)

unbound on ubuntu-20.04-x86_64 with default params is expected to contain File[/etc/unbound/unbound.conf.d] with ensure => "directory", owner => "unbound", purge => true and recurse => true Failure/Error: expect(subject).to contain_file(conf_d_dir).with( 'ensure' => 'directory', 'owner' => owner, 'purge' => purge_conf_d, 'recurse' => purge_conf_d ) expected that the catalogue would contain File[/etc/unbound/unbound.conf.d]

Check failure on line 77 in spec/classes/init_spec.rb

View workflow job for this annotation

GitHub Actions / Puppet / 8 (Ruby 3.2)

unbound on ubuntu-22.04-x86_64 with default params is expected to contain File[/etc/unbound/unbound.conf.d] with ensure => "directory", owner => "unbound", purge => true and recurse => true Failure/Error: expect(subject).to contain_file(conf_d_dir).with( 'ensure' => 'directory', 'owner' => owner, 'purge' => purge_conf_d, 'recurse' => purge_conf_d ) expected that the catalogue would contain File[/etc/unbound/unbound.conf.d]

Check failure on line 77 in spec/classes/init_spec.rb

View workflow job for this annotation

GitHub Actions / Puppet / 7 (Ruby 2.7)

unbound on debian-11-x86_64 with default params is expected to contain File[/etc/unbound/unbound.conf.d] with ensure => "directory", owner => "unbound", purge => true and recurse => true Failure/Error: expect(subject).to contain_file(conf_d_dir).with( 'ensure' => 'directory', 'owner' => owner, 'purge' => purge_conf_d, 'recurse' => purge_conf_d ) expected that the catalogue would contain File[/etc/unbound/unbound.conf.d]

Check failure on line 77 in spec/classes/init_spec.rb

View workflow job for this annotation

GitHub Actions / Puppet / 7 (Ruby 2.7)

unbound on debian-12-x86_64 with default params is expected to contain File[/etc/unbound/unbound.conf.d] with ensure => "directory", owner => "unbound", purge => true and recurse => true Failure/Error: expect(subject).to contain_file(conf_d_dir).with( 'ensure' => 'directory', 'owner' => owner, 'purge' => purge_conf_d, 'recurse' => purge_conf_d ) expected that the catalogue would contain File[/etc/unbound/unbound.conf.d]

Check failure on line 77 in spec/classes/init_spec.rb

View workflow job for this annotation

GitHub Actions / Puppet / 7 (Ruby 2.7)

unbound on ubuntu-20.04-x86_64 with default params is expected to contain File[/etc/unbound/unbound.conf.d] with ensure => "directory", owner => "unbound", purge => true and recurse => true Failure/Error: expect(subject).to contain_file(conf_d_dir).with( 'ensure' => 'directory', 'owner' => owner, 'purge' => purge_conf_d, 'recurse' => purge_conf_d ) expected that the catalogue would contain File[/etc/unbound/unbound.conf.d]

Check failure on line 77 in spec/classes/init_spec.rb

View workflow job for this annotation

GitHub Actions / Puppet / 7 (Ruby 2.7)

unbound on ubuntu-22.04-x86_64 with default params is expected to contain File[/etc/unbound/unbound.conf.d] with ensure => "directory", owner => "unbound", purge => true and recurse => true Failure/Error: expect(subject).to contain_file(conf_d_dir).with( 'ensure' => 'directory', 'owner' => owner, 'purge' => purge_conf_d, 'recurse' => purge_conf_d ) expected that the catalogue would contain File[/etc/unbound/unbound.conf.d]
expect(subject).to contain_file(unbound_conf_d).with(
expect(subject).to contain_file(conf_d_dir).with(
'ensure' => 'directory',
'owner' => 'root',
'group' => '0',
'purge' => purge_unbound_conf_d,
'recurse' => purge_unbound_conf_d
'owner' => owner,
'purge' => purge_conf_d,
'recurse' => purge_conf_d
)
end

Expand Down
Loading