Skip to content

Commit 2a44ef0

Browse files
committedMar 25, 2024
Fixed: enable correct service for restoring IPv4 rules on EL8/EL9
nftables.service loads nft rules from /etc/sysconfig/nftables.conf, but this module generates classic iptables rules which are stored in /etc/sysconfig/iptables. The service to load these on boot is simply and only "iptables.service". If both nftables.service and iptables.service are enabled, left over rules from /etc/sysconfig/nftables.conf may be inadvertently loaded. IPv6 rules are loaded correctly by ip6tables.service.
1 parent 6620ad2 commit 2a44ef0

File tree

2 files changed

+5
-15
lines changed

2 files changed

+5
-15
lines changed
 

‎manifests/params.pp

+2-2
Original file line numberDiff line numberDiff line change
@@ -30,14 +30,14 @@
3030
}
3131
default: {
3232
if versioncmp($facts['os']['release']['full'], '9') >= 0 {
33-
$service_name = ['nftables','iptables']
33+
$service_name = 'iptables'
3434
$service_name_v6 = 'ip6tables'
3535
$package_name = ['iptables-services', 'nftables', 'iptables-nft-services']
3636
$iptables_name = 'iptables-nft'
3737
$sysconfig_manage = false
3838
$firewalld_manage = true
3939
} elsif versioncmp($facts['os']['release']['full'], '8.0') >= 0 {
40-
$service_name = ['iptables', 'nftables']
40+
$service_name = ['iptables']
4141
$service_name_v6 = 'ip6tables'
4242
$package_name = ['iptables-services', 'nftables']
4343
$iptables_name = 'iptables'

‎spec/unit/classes/firewall_linux_redhat_spec.rb

+3-13
Original file line numberDiff line numberDiff line change
@@ -147,10 +147,6 @@
147147
end
148148

149149
it {
150-
expect(subject).to contain_service('nftables').with(
151-
ensure: 'running',
152-
enable: 'true',
153-
)
154150
expect(subject).to contain_service('iptables').with(
155151
ensure: 'running',
156152
enable: 'true',
@@ -161,9 +157,6 @@
161157
let(:params) { { ensure: 'stopped' } }
162158

163159
it {
164-
expect(subject).to contain_service('nftables').with(
165-
ensure: 'stopped',
166-
)
167160
expect(subject).to contain_service('iptables').with(
168161
ensure: 'stopped',
169162
)
@@ -174,9 +167,6 @@
174167
let(:params) { { enable: 'false' } }
175168

176169
it {
177-
expect(subject).to contain_service('nftables').with(
178-
enable: 'false',
179-
)
180170
expect(subject).to contain_service('iptables').with(
181171
enable: 'false',
182172
)
@@ -187,21 +177,21 @@
187177
expect(subject).to contain_service('firewalld').with(
188178
ensure: 'stopped',
189179
enable: false,
190-
before: ['Package[iptables-services]', 'Package[nftables]', 'Service[iptables]', 'Service[nftables]'],
180+
before: ['Package[iptables-services]', 'Package[nftables]', 'Service[iptables]'],
191181
)
192182
}
193183

194184
it {
195185
expect(subject).to contain_package('iptables-services').with(
196186
ensure: 'installed',
197-
before: ['Service[iptables]', 'Service[nftables]'],
187+
before: ['Service[iptables]'],
198188
)
199189
}
200190

201191
it {
202192
expect(subject).to contain_package('nftables').with(
203193
ensure: 'installed',
204-
before: ['Service[iptables]', 'Service[nftables]'],
194+
before: ['Service[iptables]'],
205195
)
206196
}
207197

0 commit comments

Comments
 (0)