Skip to content

Commit 762cd27

Browse files
committed
conf_d: merge the unbound_conf_d and conf_d params
AFAICT the intention of theses two parameters is the same so lets merge them fixes #342
1 parent 737a023 commit 762cd27

File tree

4 files changed

+35
-39
lines changed

4 files changed

+35
-39
lines changed

REFERENCE.md

Lines changed: 3 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -207,7 +207,7 @@ The following parameters are available in the `unbound` class:
207207
* [`username`](#-unbound--username)
208208
* [`package_name`](#-unbound--package_name)
209209
* [`package_ensure`](#-unbound--package_ensure)
210-
* [`purge_unbound_conf_d`](#-unbound--purge_unbound_conf_d)
210+
* [`purge_conf_d`](#-unbound--purge_conf_d)
211211
* [`root_hints_url`](#-unbound--root_hints_url)
212212
* [`runtime_dir`](#-unbound--runtime_dir)
213213
* [`auto_trust_anchor_file`](#-unbound--auto_trust_anchor_file)
@@ -244,7 +244,6 @@ The following parameters are available in the `unbound` class:
244244
* [`redis_server_host`](#-unbound--redis_server_host)
245245
* [`redis_server_port`](#-unbound--redis_server_port)
246246
* [`redis_timeout`](#-unbound--redis_timeout)
247-
* [`unbound_conf_d`](#-unbound--unbound_conf_d)
248247
* [`hints_file`](#-unbound--hints_file)
249248
* [`update_root_hints`](#-unbound--update_root_hints)
250249
* [`hints_file_content`](#-unbound--hints_file_content)
@@ -1571,11 +1570,11 @@ the ensure value for the packages
15711570

15721571
Default value: `'installed'`
15731572

1574-
##### <a name="-unbound--purge_unbound_conf_d"></a>`purge_unbound_conf_d`
1573+
##### <a name="-unbound--purge_conf_d"></a>`purge_conf_d`
15751574

15761575
Data type: `Boolean`
15771576

1578-
if true all unmanaged files in $unbound_conf_d will be purged
1577+
if true purge all unmanaged files in conf_d folder
15791578

15801579
Default value: `false`
15811580

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

18681867
Default value: `100`
18691868

1870-
##### <a name="-unbound--unbound_conf_d"></a>`unbound_conf_d`
1871-
1872-
Data type: `Stdlib::Absolutepath`
1873-
1874-
similar to conf_d, will be merged with conf_d version in future
1875-
1876-
Default value: `"${confdir}/unbound.conf.d"`
1877-
18781869
##### <a name="-unbound--hints_file"></a>`hints_file`
18791870

18801871
Data type: `Unbound::Hints_file`

data/os/Debian.yaml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
---
22
unbound::pidfile: '/run/unbound.pid'
33
unbound::runtime_dir: '/var/lib/unbound'
4-
unbound::purge_unbound_conf_d: true
4+
unbound::conf_d: "/etc/unbound/unbound.conf.d"
5+
unbound::purge_conf_d: true

manifests/init.pp

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,7 @@
166166
# @param username see https://nlnetlabs.nl/documentation/unbound/unbound.conf/
167167
# @param package_name The package(s) to install to get unbound
168168
# @param package_ensure the ensure value for the packages
169-
# @param purge_unbound_conf_d if true all unmanaged files in $unbound_conf_d will be purged
169+
# @param purge_conf_d if true purge all unmanaged files in conf_d folder
170170
# @param root_hints_url the url to download the root hints file
171171
# @param runtime_dir the runtime directory used
172172
# @param auto_trust_anchor_file see https://nlnetlabs.nl/documentation/unbound/unbound.conf/
@@ -203,7 +203,6 @@
203203
# @param redis_server_host see https://nlnetlabs.nl/documentation/unbound/unbound.conf/
204204
# @param redis_server_port see https://nlnetlabs.nl/documentation/unbound/unbound.conf/
205205
# @param redis_timeout see https://nlnetlabs.nl/documentation/unbound/unbound.conf/
206-
# @param unbound_conf_d similar to conf_d, will be merged with conf_d version in future
207206
# @param hints_file the root hints file to use
208207
# @param update_root_hints f we should update the root hints file
209208
# @param hints_file_content the contents of the root hints file
@@ -377,7 +376,7 @@
377376
# OpenBSD sets this to an empty string
378377
Variant[String,Array] $package_name = 'unbound',
379378
String[1] $package_ensure = 'installed',
380-
Boolean $purge_unbound_conf_d = false,
379+
Boolean $purge_conf_d = false,
381380
String[1] $root_hints_url = 'https://www.internic.net/domain/named.root',
382381
Stdlib::Absolutepath $runtime_dir = $confdir,
383382
Stdlib::Absolutepath $auto_trust_anchor_file = "${runtime_dir}/root.key",
@@ -414,14 +413,13 @@
414413
String[1] $redis_server_host = '127.0.0.1',
415414
Integer[1,65536] $redis_server_port = 6379,
416415
Integer[1] $redis_timeout = 100,
417-
Stdlib::Absolutepath $unbound_conf_d = "${confdir}/unbound.conf.d",
418416
Unbound::Hints_file $hints_file = "${confdir}/root.hints",
419417
Enum['absent','present','unmanaged'] $update_root_hints = fact('systemd') ? { true => 'present', default => 'unmanaged' },
420418
Optional[String[1]] $hints_file_content = undef,
421419
Hash[String[1], Unbound::Rpz] $rpzs = {},
422420
Optional[String[1]] $unbound_version = $facts['unbound_version'],
423421
) {
424-
$_base_dirs = [$confdir, $conf_d, $keys_d, $runtime_dir]
422+
$_base_dirs = [$confdir, $keys_d, $runtime_dir]
425423
$_piddir = if $pidfile { dirname($pidfile) } else { undef }
426424
if $_piddir and !($_piddir in ['/run', '/var/run']) {
427425
$dirs = unique($_base_dirs + [$_piddir])
@@ -541,12 +539,11 @@
541539
}
542540

543541
# purge unmanaged files in configuration directory
544-
file { $unbound_conf_d:
542+
file { $conf_d:
545543
ensure => 'directory',
546-
owner => 'root',
547-
group => '0',
548-
purge => $purge_unbound_conf_d,
549-
recurse => $purge_unbound_conf_d,
544+
owner => $owner,
545+
purge => $purge_conf_d,
546+
recurse => $purge_conf_d,
550547
}
551548

552549
concat { $config_file:

spec/classes/init_spec.rb

Lines changed: 23 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,6 @@
1010
context "on #{os}" do
1111
let(:facts) { facts.merge(concat_basedir: '/dne') }
1212
let(:package) { 'unbound' }
13-
let(:conf_file) { "#{conf_dir}/unbound.conf" }
14-
let(:conf_d_dir) { "#{conf_dir}/conf.d" }
15-
let(:unbound_conf_d) { "#{conf_dir}/unbound.conf.d" }
16-
let(:keys_d_dir) { "#{conf_dir}/keys.d" }
17-
let(:hints_file) { "#{conf_dir}/root.hints" }
1813

1914
pidfile = nil
2015

@@ -23,33 +18,47 @@
2318
pidfile = '/run/unbound.pid'
2419
let(:service) { 'unbound' }
2520
let(:conf_dir) { '/etc/unbound' }
26-
let(:purge_unbound_conf_d) { true }
21+
let(:purge_conf_d) { true }
2722
let(:control_path) { '/usr/sbin/unbound-control' }
2823
when 'OpenBSD'
2924
pidfile = '/var/run/unbound.pid'
3025
let(:service) { 'unbound' }
3126
let(:conf_dir) { '/var/unbound/etc' }
32-
let(:purge_unbound_conf_d) { false }
27+
let(:purge_conf_d) { false }
3328
let(:control_path) { '/usr/sbin/unbound-control' }
3429
when 'FreeBSD'
3530
pidfile = '/usr/local/etc/unbound/unbound.pid'
3631
let(:service) { 'unbound' }
3732
let(:conf_dir) { '/usr/local/etc/unbound' }
38-
let(:purge_unbound_conf_d) { false }
33+
let(:purge_conf_d) { false }
3934
let(:control_path) { '/usr/local/sbin/unbound-control' }
4035
when 'Darwin'
4136
pidfile = '/var/run/unbound.pid'
4237
let(:service) { 'org.macports.unbound' }
4338
let(:conf_dir) { '/opt/local//etc/unbound' }
44-
let(:purge_unbound_conf_d) { false }
39+
let(:purge_conf_d) { false }
4540
else
4641
pidfile = '/var/run/unbound/unbound.pid'
4742
let(:service) { 'unbound' }
4843
let(:conf_dir) { '/etc/unbound' }
49-
let(:purge_unbound_conf_d) { false }
44+
let(:purge_conf_d) { false }
5045
let(:control_path) { '/usr/sbin/unbound-control' }
5146
end
5247

48+
if facts[:os]['family'] == 'Archlinux'
49+
let(:owner) { 'root' }
50+
else
51+
let(:owner) { 'unbound' }
52+
end
53+
if facts[:os]['family'] == 'Debian'
54+
let(:conf_d_dir) { "#{conf_dir}/unbound.conf.d" }
55+
else
56+
let(:conf_d_dir) { "#{conf_dir}/conf.d" }
57+
end
58+
let(:conf_file) { "#{conf_dir}/unbound.conf" }
59+
let(:keys_d_dir) { "#{conf_dir}/keys.d" }
60+
let(:hints_file) { "#{conf_dir}/root.hints" }
61+
5362
context 'with default params' do
5463
it { is_expected.to compile.with_all_deps }
5564
it { is_expected.to contain_class('unbound') }
@@ -58,7 +67,6 @@
5867
it { is_expected.to contain_service(service) }
5968
it { is_expected.to contain_concat(conf_file) }
6069
it { is_expected.to contain_file(conf_dir) }
61-
it { is_expected.to contain_file(conf_d_dir) }
6270
it { is_expected.to contain_file(keys_d_dir) }
6371
it { is_expected.to contain_file(hints_file) }
6472

@@ -67,12 +75,11 @@
6775
end
6876

6977
it do
70-
expect(subject).to contain_file(unbound_conf_d).with(
78+
expect(subject).to contain_file(conf_d_dir).with(
7179
'ensure' => 'directory',
72-
'owner' => 'root',
73-
'group' => '0',
74-
'purge' => purge_unbound_conf_d,
75-
'recurse' => purge_unbound_conf_d
80+
'owner' => owner,
81+
'purge' => purge_conf_d,
82+
'recurse' => purge_conf_d
7683
)
7784
end
7885

0 commit comments

Comments
 (0)