Skip to content

Commit a597671

Browse files
authored
Merge pull request #1095 from ahrefs/main
debian: service: fix `ensure` parameter usage
2 parents 2cc5f02 + 8171cb4 commit a597671

File tree

2 files changed

+72
-4
lines changed

2 files changed

+72
-4
lines changed

manifests/linux/debian.pp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@
3434
# This isn't a real service/daemon. The start action loads rules, so just
3535
# needs to be called on system boot.
3636
service { $service_name:
37-
ensure => undef,
37+
ensure => $ensure,
3838
enable => $enable,
3939
hasstatus => true,
4040
require => Package[$package_name],

spec/unit/classes/firewall_linux_debian_spec.rb

Lines changed: 71 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
}
2020
it {
2121
is_expected.to contain_service('netfilter-persistent').with(
22-
ensure: nil,
22+
ensure: 'running',
2323
enable: 'true',
2424
require: 'Package[iptables-persistent]',
2525
)
@@ -43,6 +43,23 @@
4343
}
4444
end
4545

46+
context 'with Debian 10, ensure => stopped' do
47+
let(:facts) do
48+
{
49+
osfamily: 'Debian',
50+
operatingsystem: 'Debian',
51+
operatingsystemrelease: '10.0',
52+
}
53+
end
54+
let(:params) { { ensure: 'stopped' } }
55+
56+
it {
57+
is_expected.to contain_service('netfilter-persistent').with(
58+
ensure: 'stopped',
59+
)
60+
}
61+
end
62+
4663
context 'with Debian 11' do
4764
let(:facts) do
4865
{
@@ -59,7 +76,7 @@
5976
}
6077
it {
6178
is_expected.to contain_service('netfilter-persistent').with(
62-
ensure: nil,
79+
ensure: 'running',
6380
enable: 'true',
6481
require: 'Package[iptables-persistent]',
6582
)
@@ -83,6 +100,23 @@
83100
}
84101
end
85102

103+
context 'with Debian 11, ensure => stopped' do
104+
let(:facts) do
105+
{
106+
osfamily: 'Debian',
107+
operatingsystem: 'Debian',
108+
operatingsystemrelease: '10.0',
109+
}
110+
end
111+
let(:params) { { ensure: 'stopped' } }
112+
113+
it {
114+
is_expected.to contain_service('netfilter-persistent').with(
115+
ensure: 'stopped',
116+
)
117+
}
118+
end
119+
86120
context 'with Debian unstable' do
87121
let(:facts) do
88122
{
@@ -99,10 +133,44 @@
99133
}
100134
it {
101135
is_expected.to contain_service('netfilter-persistent').with(
102-
ensure: nil,
136+
ensure: 'running',
103137
enable: 'true',
104138
require: 'Package[netfilter-persistent]',
105139
)
106140
}
107141
end
142+
143+
context 'with Debian unstable, enable => false' do
144+
let(:facts) do
145+
{
146+
osfamily: 'Debian',
147+
operatingsystem: 'Debian',
148+
operatingsystemrelease: 'unstable',
149+
}
150+
end
151+
let(:params) { { enable: 'false' } }
152+
153+
it {
154+
is_expected.to contain_service('netfilter-persistent').with(
155+
enable: 'false',
156+
)
157+
}
158+
end
159+
160+
context 'with Debian unstable, ensure => stopped' do
161+
let(:facts) do
162+
{
163+
osfamily: 'Debian',
164+
operatingsystem: 'Debian',
165+
operatingsystemrelease: '10.0',
166+
}
167+
end
168+
let(:params) { { ensure: 'stopped' } }
169+
170+
it {
171+
is_expected.to contain_service('netfilter-persistent').with(
172+
ensure: 'stopped',
173+
)
174+
}
175+
end
108176
end

0 commit comments

Comments
 (0)