Skip to content

Commit

Permalink
Changed path to use fact. Partial conversion of execs to arrays
Browse files Browse the repository at this point in the history
  • Loading branch information
canihavethisone committed Aug 3, 2024
1 parent 3016d42 commit c00bcf2
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
8 changes: 4 additions & 4 deletions manifests/init.pp
Original file line number Diff line number Diff line change
Expand Up @@ -235,16 +235,16 @@
if $purge_unmanaged_rules {
# Reload the nftables ruleset from the on-disk ruleset if there are differences or it is absent. -s must be used to ignore counters
exec { 'nftables_memory_state_check':
command => 'echo "reloading nftables"',
path => ['/usr/sbin', '/sbin', '/usr/bin', '/bin'],
unless => "/usr/bin/test -s ${inmem_rules_hash_file} -a \"$(nft -s list ruleset | sha1sum)\" = \"$(cat ${inmem_rules_hash_file})\"",
command => ['echo', 'reloading_nftables'],
path => $facts['path'],
unless => ["test -s ${inmem_rules_hash_file} -a \"$(nft -s list ruleset | sha1sum)\" = \"$(cat ${inmem_rules_hash_file})\""],
notify => Service['nftables'],
}

# Generate nftables_hash upon any changes from the nftables service
exec { 'nftables_generate_hash':
command => "nft -s list ruleset | sha1sum > ${inmem_rules_hash_file}",
path => ['/usr/sbin', '/sbin', '/usr/bin', '/bin'],
path => $facts['path'],
subscribe => Service['nftables'],
refreshonly => true,
}
Expand Down
4 changes: 2 additions & 2 deletions spec/classes/nftables_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -321,9 +321,9 @@
it { is_expected.not_to contain_file('/foo/bar') }
it {
is_expected.to contain_exec('nftables_memory_state_check').with(
command: %r{^echo "reloading nftables"$},
command: ["echo", "reloading_nftables"],
notify: 'Service[nftables]',
unless: %r{^/usr/bin/test -s /foo/bar -a "\$\(nft -s list ruleset \| sha1sum\)" = "\$\(cat /foo/bar\)"$}
unless: ["test -s /foo/bar -a \"$(nft -s list ruleset | sha1sum)\" = \"$(cat /foo/bar)\""]
)
}
it {
Expand Down

0 comments on commit c00bcf2

Please sign in to comment.