Skip to content

Commit c0e1d39

Browse files
b4ldrCopilot
andcommitted
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 Co-authored-by: Copilot <[email protected]>
1 parent 6d9ba2b commit c0e1d39

File tree

4 files changed

+33
-37
lines changed

4 files changed

+33
-37
lines changed

REFERENCE.md

Lines changed: 3 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -212,7 +212,7 @@ The following parameters are available in the `unbound` class:
212212
* [`username`](#-unbound--username)
213213
* [`package_name`](#-unbound--package_name)
214214
* [`package_ensure`](#-unbound--package_ensure)
215-
* [`purge_unbound_conf_d`](#-unbound--purge_unbound_conf_d)
215+
* [`purge_conf_d`](#-unbound--purge_conf_d)
216216
* [`root_hints_url`](#-unbound--root_hints_url)
217217
* [`runtime_dir`](#-unbound--runtime_dir)
218218
* [`auto_trust_anchor_file`](#-unbound--auto_trust_anchor_file)
@@ -249,7 +249,6 @@ The following parameters are available in the `unbound` class:
249249
* [`redis_server_host`](#-unbound--redis_server_host)
250250
* [`redis_server_port`](#-unbound--redis_server_port)
251251
* [`redis_timeout`](#-unbound--redis_timeout)
252-
* [`unbound_conf_d`](#-unbound--unbound_conf_d)
253252
* [`hints_file`](#-unbound--hints_file)
254253
* [`update_root_hints`](#-unbound--update_root_hints)
255254
* [`hints_file_content`](#-unbound--hints_file_content)
@@ -1576,11 +1575,11 @@ the ensure value for the packages
15761575

15771576
Default value: `'installed'`
15781577

1579-
##### <a name="-unbound--purge_unbound_conf_d"></a>`purge_unbound_conf_d`
1578+
##### <a name="-unbound--purge_conf_d"></a>`purge_conf_d`
15801579

15811580
Data type: `Boolean`
15821581

1583-
if true all unmanaged files in $unbound_conf_d will be purged
1582+
if true purge all unmanaged files in conf_d folder
15841583

15851584
Default value: `false`
15861585

@@ -1872,14 +1871,6 @@ see https://nlnetlabs.nl/documentation/unbound/unbound.conf/
18721871

18731872
Default value: `100`
18741873

1875-
##### <a name="-unbound--unbound_conf_d"></a>`unbound_conf_d`
1876-
1877-
Data type: `Stdlib::Absolutepath`
1878-
1879-
similar to conf_d, will be merged with conf_d version in future
1880-
1881-
Default value: `"${confdir}/unbound.conf.d"`
1882-
18831874
##### <a name="-unbound--hints_file"></a>`hints_file`
18841875

18851876
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, $conf_d]
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: 21 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,10 @@
99
on_supported_os.each do |os, facts|
1010
context "on #{os}" do
1111
let(:facts) { facts.merge(concat_basedir: '/dne') }
12-
let(:package) { 'unbound' }
1312
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" }
1613
let(:keys_d_dir) { "#{conf_dir}/keys.d" }
1714
let(:hints_file) { "#{conf_dir}/root.hints" }
15+
let(:package) { 'unbound' }
1816

1917
pidfile = nil
2018

@@ -23,33 +21,44 @@
2321
pidfile = '/run/unbound.pid'
2422
let(:service) { 'unbound' }
2523
let(:conf_dir) { '/etc/unbound' }
26-
let(:purge_unbound_conf_d) { true }
24+
let(:purge_conf_d) { true }
2725
let(:control_path) { '/usr/sbin/unbound-control' }
2826
when 'OpenBSD'
2927
pidfile = '/var/run/unbound.pid'
3028
let(:service) { 'unbound' }
3129
let(:conf_dir) { '/var/unbound/etc' }
32-
let(:purge_unbound_conf_d) { false }
30+
let(:purge_conf_d) { false }
3331
let(:control_path) { '/usr/sbin/unbound-control' }
3432
when 'FreeBSD'
3533
pidfile = '/usr/local/etc/unbound/unbound.pid'
3634
let(:service) { 'unbound' }
3735
let(:conf_dir) { '/usr/local/etc/unbound' }
38-
let(:purge_unbound_conf_d) { false }
36+
let(:purge_conf_d) { false }
3937
let(:control_path) { '/usr/local/sbin/unbound-control' }
4038
when 'Darwin'
4139
pidfile = '/var/run/unbound.pid'
4240
let(:service) { 'org.macports.unbound' }
4341
let(:conf_dir) { '/opt/local//etc/unbound' }
44-
let(:purge_unbound_conf_d) { false }
42+
let(:purge_conf_d) { false }
4543
else
4644
pidfile = '/var/run/unbound/unbound.pid'
4745
let(:service) { 'unbound' }
4846
let(:conf_dir) { '/etc/unbound' }
49-
let(:purge_unbound_conf_d) { false }
47+
let(:purge_conf_d) { false }
5048
let(:control_path) { '/usr/sbin/unbound-control' }
5149
end
5250

51+
if facts[:os]['family'] == 'Archlinux'
52+
let(:owner) { 'root' }
53+
else
54+
let(:owner) { 'unbound' }
55+
end
56+
if facts[:os]['family'] == 'Debian'
57+
let(:conf_d_dir) { "#{conf_dir}/unbound.conf.d" }
58+
else
59+
let(:conf_d_dir) { "#{conf_dir}/conf.d" }
60+
end
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)