Révision c1bd001d
Added shell provider to execs. Hash generate now in array. Ran rubocop:autocorrect
manifests/init.pp | ||
---|---|---|
235 | 235 |
if $purge_unmanaged_rules { |
236 | 236 |
# Reload the nftables ruleset from the on-disk ruleset if there are differences or it is absent. -s must be used to ignore counters |
237 | 237 |
exec { 'nftables_memory_state_check': |
238 |
command => ['echo', 'reloading_nftables'], |
|
239 |
path => $facts['path'], |
|
240 |
unless => ["test -s ${inmem_rules_hash_file} -a \"$(nft -s list ruleset | sha1sum)\" = \"$(cat ${inmem_rules_hash_file})\""], |
|
241 |
notify => Service['nftables'], |
|
238 |
command => ['echo', 'reloading_nftables'], |
|
239 |
path => $facts['path'], |
|
240 |
provider => shell, |
|
241 |
unless => ["test -s ${inmem_rules_hash_file} -a \"$(nft -s list ruleset | sha1sum)\" = \"$(cat ${inmem_rules_hash_file})\""], |
|
242 |
notify => Service['nftables'], |
|
242 | 243 |
} |
243 | 244 |
|
244 | 245 |
# Generate nftables_hash upon any changes from the nftables service |
245 | 246 |
exec { 'nftables_generate_hash': |
246 |
command => "nft -s list ruleset | sha1sum > ${inmem_rules_hash_file}",
|
|
247 |
command => ["nft -s list ruleset | sha1sum > ${inmem_rules_hash_file}"],
|
|
247 | 248 |
path => $facts['path'], |
249 |
provider => shell, |
|
248 | 250 |
subscribe => Service['nftables'], |
249 | 251 |
refreshonly => true, |
250 | 252 |
} |
spec/classes/nftables_spec.rb | ||
---|---|---|
319 | 319 |
end |
320 | 320 |
|
321 | 321 |
it { is_expected.not_to contain_file('/foo/bar') } |
322 |
|
|
322 | 323 |
it { |
323 | 324 |
is_expected.to contain_exec('nftables_memory_state_check').with( |
324 |
command: ["echo", "reloading_nftables"],
|
|
325 |
command: %w[echo reloading_nftables],
|
|
325 | 326 |
notify: 'Service[nftables]', |
326 |
unless: ["test -s /foo/bar -a \"$(nft -s list ruleset | sha1sum)\" = \"$(cat /foo/bar)\""]
|
|
327 |
unless: ['test -s /foo/bar -a "$(nft -s list ruleset | sha1sum)" = "$(cat /foo/bar)"']
|
|
327 | 328 |
) |
328 | 329 |
} |
330 |
|
|
329 | 331 |
it { |
330 | 332 |
is_expected.to contain_exec('nftables_generate_hash').with( |
331 |
command: %r{^nft -s list ruleset \| sha1sum > /foo/bar$},
|
|
333 |
command: ['nft -s list ruleset | sha1sum > /foo/bar'],
|
|
332 | 334 |
subscribe: 'Service[nftables]', |
333 |
refreshonly: true,
|
|
335 |
refreshonly: true |
|
334 | 336 |
) |
335 | 337 |
} |
336 | 338 |
end |
Formats disponibles : Unified diff