Skip to content

Commit 0c13c42

Browse files
committed
fix: permissions on pdns.conf
On rocky9 the default configuration does not allow the authoritative server to actually read its own configuration file. This ensures it is readable. Also fixes some bugs in the spec.
1 parent 9958bd3 commit 0c13c42

File tree

2 files changed

+24
-4
lines changed

2 files changed

+24
-4
lines changed

manifests/authoritative.pp

+12
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
# powerdns::authoritative
2+
#
3+
# @param group
4+
# Name of the group associated with the pdns authoritative service - needed to ensure the config file can be read.
25
class powerdns::authoritative (
6+
String $group = 'pdns',
37
) inherits powerdns {
48
# install the powerdns package
59
package { $powerdns::authoritative_package_name:
@@ -10,6 +14,14 @@
1014

1115
include "powerdns::backends::${powerdns::backend}"
1216

17+
file { $powerdns::authoritative_config:
18+
ensure => 'file',
19+
owner => 'root',
20+
group => $group,
21+
mode => '0640',
22+
before => Service['pdns'],
23+
}
24+
1325
service { 'pdns':
1426
ensure => running,
1527
name => $powerdns::authoritative_service_name,

spec/classes/powerdns_init_spec.rb

+12-4
Original file line numberDiff line numberDiff line change
@@ -133,19 +133,19 @@
133133
}
134134
end
135135
when '9'
136-
it { is_expected.to contain_yumrepo('CRB') }
136+
it { is_expected.to contain_yumrepo('crb') }
137137
if facts[:operatingsystem] == 'Rocky'
138138
it {
139139
is_expected.to contain_yumrepo('crb').with(
140140
'mirrorlist' => 'http://mirrorlist.rockylinux.org/mirrorlist?arch=$basearch&repo=CRB-$releasever',
141-
'descr' => 'Rocky Linux $releasever - CRB',
141+
'descr' => "#{facts[:operatingsystem]} Linux $releasever - CRB",
142142
)
143143
}
144144
else
145145
it {
146-
is_expected.to contain_yumrepo('crvb').with(
146+
is_expected.to contain_yumrepo('crb').with(
147147
'mirrorlist' => 'http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=CRB&infra=$infra',
148-
'descr' => 'CentOS Linux $releasever - CRB',
148+
'descr' => "#{facts[:operatingsystem]} Linux $releasever - CRB",
149149
)
150150
}
151151
end
@@ -178,6 +178,14 @@
178178
it { is_expected.to contain_service('pdns').with('enable' => 'true') }
179179
it { is_expected.to contain_service('pdns').with('name' => authoritative_service_name) }
180180
it { is_expected.to contain_service('pdns').that_requires("Package[#{authoritative_package_name}]") }
181+
it 'creates the pdns.conf file' do
182+
is_expected.to contain_file(authoritative_config).with(
183+
ensure: 'file',
184+
owner: 'root',
185+
group: 'pdns',
186+
mode: '0640',
187+
).that_comes_before('Service[pdns]')
188+
end
181189
end
182190

183191
context 'powerdns class with epel' do

0 commit comments

Comments
 (0)