Skip to content

Commit

Permalink
Merge pull request voxpupuli#34 from traylenator/dedupe_flush
Browse files Browse the repository at this point in the history
Remove duplicate flush on reload
  • Loading branch information
duritong committed Dec 9, 2020
2 parents 354a3ea + ce22630 commit f0bd879
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 32 deletions.
7 changes: 7 additions & 0 deletions files/systemd/puppet_nft.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# Puppet Deployed
[Service]
ExecStart=
ExecStart=/sbin/nft -I /etc/nftables/puppet -f /etc/sysconfig/nftables.conf
ExecReload=
ExecReload=/sbin/nft -I /etc/nftables/puppet -f /etc/sysconfig/nftables.conf

2 changes: 1 addition & 1 deletion manifests/init.pp
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@
systemd::dropin_file { 'puppet_nft.conf':
ensure => present,
unit => 'nftables.service',
content => epp('nftables/systemd/puppet_nft.conf.epp', { 'noflush' => $noflush_tables }),
content => file('nftables/systemd/puppet_nft.conf'),
notify => Service['nftables'],
}

Expand Down
4 changes: 4 additions & 0 deletions spec/acceptance/default_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,10 @@ class { 'nftables':
it { is_expected.to be_file }
end

describe file('/etc/systemd/system/nftables.service.d/puppet_nft.conf') do
it { is_expected.to be_file }
end

describe file('/etc/nftables/puppet') do
it { is_expected.to be_directory }
end
Expand Down
18 changes: 6 additions & 12 deletions spec/classes/nftables_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,12 @@
)
}

it {
is_expected.to contain_systemd__dropin_file('puppet_nft.conf').with(
content: %r{^ExecReload=/sbin/nft -I /etc/nftables/puppet -f /etc/sysconfig/nftables.conf$},
)
}

it {
is_expected.to contain_service('firewalld').with(
ensure: 'stopped',
Expand Down Expand Up @@ -176,10 +182,6 @@
end

context 'with no nftables fact' do
it {
is_expected.to contain_systemd__dropin_file('puppet_nft.conf').
with_content(%r{^ExecReload.*flush ruleset; include.*$})
}
it { is_expected.to contain_file('/etc/nftables/puppet-preflight.nft').with_content(%r{^flush ruleset$}) }
end

Expand All @@ -188,10 +190,6 @@
super().merge(nftables: { tables: ['inet-abc', 'inet-f2b-table'] })
end

it {
is_expected.to contain_systemd__dropin_file('puppet_nft.conf').
with_content(%r{^ExecReload.*flush table inet abc; include.*$})
}
it {
is_expected.to contain_file('/etc/nftables/puppet-preflight.nft').
with_content(%r{^flush table inet abc$})
Expand All @@ -202,10 +200,6 @@
super().merge(nftables: { tables: ['inet-abc', 'inet-ijk'] })
end

it {
is_expected.to contain_systemd__dropin_file('puppet_nft.conf').
with_content(%r{^ExecReload.*flush table inet abc; flush table inet ijk; include.*$})
}
it {
is_expected.to contain_file('/etc/nftables/puppet-preflight.nft').
with_content(%r{^flush table inet abc; flush table inet ijk$})
Expand Down
19 changes: 0 additions & 19 deletions templates/systemd/puppet_nft.conf.epp

This file was deleted.

0 comments on commit f0bd879

Please sign in to comment.