root / spec / acceptance / all_rules_spec.rb @ c94658e1
Historique | Voir | Annoter | Télécharger (4,21 ko)
1 | cfcafde5 | Steve Traylen | require 'spec_helper_acceptance'
|
---|---|---|---|
2 | |||
3 | describe 'nftables class' do |
||
4 | context 'configure all nftables rules' do |
||
5 | it 'works idempotently with no errors' do |
||
6 | pp = <<-EOS |
||
7 | # default mask of firewalld service fails if service is not installed.
|
||
8 | # https://tickets.puppetlabs.com/browse/PUP-10814
|
||
9 | # Disable all default rules and include below explicitly
|
||
10 | class { 'nftables':
|
||
11 | firewalld_enable => false,
|
||
12 | out_ntp => false,
|
||
13 | out_http => false,
|
||
14 | out_https => false,
|
||
15 | out_icmp => false,
|
||
16 | in_ssh => false,
|
||
17 | in_icmp => false,
|
||
18 | }
|
||
19 | include nftables::rules::icmp
|
||
20 | include nftables::rules::dns
|
||
21 | include nftables::rules::node_exporter
|
||
22 | include nftables::rules::nfs3
|
||
23 | include nftables::rules::ssh
|
||
24 | include nftables::rules::dhcpv6_client
|
||
25 | include nftables::rules::afs3_callback
|
||
26 | include nftables::rules::ospf
|
||
27 | include nftables::rules::http
|
||
28 | include nftables::rules::puppet
|
||
29 | include nftables::rules::icinga2
|
||
30 | include nftables::rules::tor
|
||
31 | include nftables::rules::ospf3
|
||
32 | include nftables::rules::ceph_mon
|
||
33 | include nftables::rules::smtp_submission
|
||
34 | include nftables::rules::https
|
||
35 | include nftables::rules::nfs
|
||
36 | include nftables::rules::smtps
|
||
37 | include nftables::rules::smtp
|
||
38 | include nftables::rules::ceph
|
||
39 | 1ee2f66b | Giuseppe Lo Presti | include nftables::rules::samba
|
40 | 771b3256 | Nacho Barrientos | include nftables::rules::activemq
|
41 | 6be2adf7 | Luis Fernández Álvarez | include nftables::rules::docker_ce
|
42 | cd2a3cbf | Nacho Barrientos | include nftables::rules::qemu
|
43 | cfcafde5 | Steve Traylen | include nftables::rules::out::postgres
|
44 | include nftables::rules::out::icmp
|
||
45 | include nftables::rules::out::dns
|
||
46 | include nftables::rules::out::nfs3
|
||
47 | include nftables::rules::out::ssh
|
||
48 | include nftables::rules::out::kerberos
|
||
49 | include nftables::rules::out::dhcpv6_client
|
||
50 | include nftables::rules::out::ospf
|
||
51 | include nftables::rules::out::openafs_client
|
||
52 | include nftables::rules::out::http
|
||
53 | include nftables::rules::out::ssh::remove
|
||
54 | class{'nftables::rules::out::puppet':
|
||
55 | 04176b0e | mh | puppetserver => '127.0.0.1',
|
56 | cfcafde5 | Steve Traylen | }
|
57 | include nftables::rules::out::all
|
||
58 | include nftables::rules::out::tor
|
||
59 | include nftables::rules::out::ospf3
|
||
60 | include nftables::rules::out::mysql
|
||
61 | include nftables::rules::out::ceph_client
|
||
62 | include nftables::rules::out::https
|
||
63 | include nftables::rules::out::dhcp
|
||
64 | include nftables::rules::out::nfs
|
||
65 | include nftables::rules::out::smtp
|
||
66 | 19908f41 | mh | include nftables::rules::out::smtp_client
|
67 | include nftables::rules::out::imap
|
||
68 | include nftables::rules::out::pop3
|
||
69 | cfcafde5 | Steve Traylen | include nftables::rules::out::chrony
|
70 | include nftables::rules::out::wireguard
|
||
71 | include nftables::rules::wireguard
|
||
72 | include nftables::services::dhcpv6_client
|
||
73 | include nftables::services::openafs_client
|
||
74 | c94658e1 | Nacho Barrientos | nftables::set{'my_test_set':
|
75 | type => 'ipv4_addr',
|
||
76 | elements => ['192.168.0.1', '10.0.0.2'],
|
||
77 | table => ['inet-filter', 'ip-nat'],
|
||
78 | }
|
||
79 | cfcafde5 | Steve Traylen | # nftables cannot be started in docker so replace service with a validation only.
|
80 | systemd::dropin_file{"zzz_docker_nft.conf":
|
||
81 | ensure => present,
|
||
82 | unit => "nftables.service",
|
||
83 | content => [
|
||
84 | "[Service]",
|
||
85 | "ExecStart=",
|
||
86 | "ExecStart=/sbin/nft -c -I /etc/nftables/puppet -f /etc/sysconfig/nftables.conf",
|
||
87 | "ExecReload=",
|
||
88 | "ExecReload=/sbin/nft -c -I /etc/nftables/puppet -f /etc/sysconfig/nftables.conf",
|
||
89 | "",
|
||
90 | ].join("\n"),
|
||
91 | notify => Service["nftables"],
|
||
92 | }
|
||
93 | EOS
|
||
94 | # Run it twice and test for idempotency
|
||
95 | apply_manifest(pp, catch_failures: true) |
||
96 | apply_manifest(pp, catch_changes: true) |
||
97 | end
|
||
98 | |||
99 | describe package('nftables') do |
||
100 | it { is_expected.to be_installed } |
||
101 | end
|
||
102 | |||
103 | describe service('nftables') do |
||
104 | it { is_expected.to be_running } |
||
105 | it { is_expected.to be_enabled } |
||
106 | end
|
||
107 | |||
108 | describe file('/etc/nftables/puppet.nft') do |
||
109 | it { is_expected.to be_file } |
||
110 | end
|
||
111 | |||
112 | describe file('/etc/systemd/system/nftables.service.d/puppet_nft.conf') do |
||
113 | it { is_expected.to be_file } |
||
114 | end
|
||
115 | |||
116 | describe file('/etc/nftables/puppet') do |
||
117 | it { is_expected.to be_directory } |
||
118 | end
|
||
119 | end
|
||
120 | end |