root / spec / acceptance / zz_destroy_spec.rb @ c00bcf2d
Historique | Voir | Annoter | Télécharger (1,91 ko)
1 |
# frozen_string_literal: true
|
---|---|
2 |
|
3 |
require 'spec_helper_acceptance'
|
4 |
|
5 |
describe 'nftables class' do |
6 |
context 'configure defaults destroyed nftables service' do |
7 |
it 'works idempotently with no errors' do |
8 |
pp = <<-EOS |
9 |
# default mask of firewalld service fails if service is not installed.
|
10 |
# https://tickets.puppetlabs.com/browse/PUP-10814
|
11 |
class { 'nftables':
|
12 |
firewalld_enable => false,
|
13 |
clobber_default_config => true,
|
14 |
}
|
15 |
$config_path = $facts['os']['family'] ? {
|
16 |
'Archlinux' => '/etc/nftables.conf',
|
17 |
'Debian' => '/etc/nftables.conf',
|
18 |
default => '/etc/sysconfig/nftables.conf',
|
19 |
}
|
20 |
$nft_path = $facts['os']['family'] ? {
|
21 |
'Archlinux' => '/usr/bin/nft',
|
22 |
default => '/usr/sbin/nft',
|
23 |
}
|
24 |
# nftables cannot be started in docker so replace service with a validation only.
|
25 |
systemd::dropin_file{"zzz_docker_nft.conf":
|
26 |
ensure => present,
|
27 |
unit => "nftables.service",
|
28 |
content => [
|
29 |
"[Service]",
|
30 |
"ExecStart=",
|
31 |
"ExecStart=${nft_path} -c -I /etc/nftables/puppet -f ${config_path}",
|
32 |
"ExecReload=",
|
33 |
"ExecReload=${nft_path} -c -I /etc/nftables/puppet -f ${config_path}",
|
34 |
"",
|
35 |
].join("\n"),
|
36 |
notify => Service["nftables"],
|
37 |
}
|
38 |
EOS
|
39 |
# Run it twice and test for idempotency
|
40 |
apply_manifest(pp, catch_failures: true) |
41 |
apply_manifest(pp, catch_changes: true) |
42 |
end
|
43 |
|
44 |
describe package('nftables') do |
45 |
it { is_expected.to be_installed } |
46 |
end
|
47 |
|
48 |
describe service('nftables') do |
49 |
it { is_expected.to be_running } |
50 |
it { is_expected.to be_enabled } |
51 |
end
|
52 |
|
53 |
describe file('/etc/nftables/puppet.nft', '/etc/systemd/system/nftables.service.d/puppet_nft.conf') do |
54 |
it { is_expected.to be_file } |
55 |
end
|
56 |
|
57 |
describe file('/etc/nftables/puppet') do |
58 |
it { is_expected.to be_directory } |
59 |
end
|
60 |
end
|
61 |
end
|