root / spec / acceptance / all_rules_spec.rb @ 9d1ee648
Historique | Voir | Annoter | Télécharger (5,36 ko)
1 | c82b960a | Steve Traylen | # frozen_string_literal: true
|
---|---|---|---|
2 | |||
3 | cfcafde5 | Steve Traylen | require 'spec_helper_acceptance'
|
4 | |||
5 | describe 'nftables class' do |
||
6 | context 'configure all nftables rules' 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 | # Disable all default rules and include below explicitly
|
||
12 | class { 'nftables':
|
||
13 | firewalld_enable => false,
|
||
14 | out_ntp => false,
|
||
15 | out_http => false,
|
||
16 | out_https => false,
|
||
17 | out_icmp => false,
|
||
18 | in_ssh => false,
|
||
19 | in_icmp => false,
|
||
20 | }
|
||
21 | include nftables::rules::icmp
|
||
22 | include nftables::rules::dns
|
||
23 | include nftables::rules::node_exporter
|
||
24 | include nftables::rules::nfs3
|
||
25 | include nftables::rules::ssh
|
||
26 | include nftables::rules::dhcpv6_client
|
||
27 | include nftables::rules::afs3_callback
|
||
28 | include nftables::rules::ospf
|
||
29 | 08b9f1d0 | Steve Traylen | include nftables::rules::podman
|
30 | cfcafde5 | Steve Traylen | include nftables::rules::http
|
31 | include nftables::rules::puppet
|
||
32 | 7f74df2e | Tim Meusel | include nftables::rules::pxp_agent
|
33 | cfcafde5 | Steve Traylen | include nftables::rules::icinga2
|
34 | ea29e235 | Simon Hoenscheid | include nftables::rules::ldap
|
35 | cfcafde5 | Steve Traylen | include nftables::rules::tor
|
36 | include nftables::rules::ospf3
|
||
37 | include nftables::rules::ceph_mon
|
||
38 | include nftables::rules::smtp_submission
|
||
39 | include nftables::rules::https
|
||
40 | include nftables::rules::nfs
|
||
41 | include nftables::rules::smtps
|
||
42 | include nftables::rules::smtp
|
||
43 | include nftables::rules::ceph
|
||
44 | 1ee2f66b | Giuseppe Lo Presti | include nftables::rules::samba
|
45 | 771b3256 | Nacho Barrientos | include nftables::rules::activemq
|
46 | 6be2adf7 | Luis Fernández Álvarez | include nftables::rules::docker_ce
|
47 | cd2a3cbf | Nacho Barrientos | include nftables::rules::qemu
|
48 | cfcafde5 | Steve Traylen | include nftables::rules::out::postgres
|
49 | include nftables::rules::out::icmp
|
||
50 | include nftables::rules::out::dns
|
||
51 | include nftables::rules::out::nfs3
|
||
52 | include nftables::rules::out::ssh
|
||
53 | include nftables::rules::out::kerberos
|
||
54 | include nftables::rules::out::dhcpv6_client
|
||
55 | include nftables::rules::out::ospf
|
||
56 | include nftables::rules::out::openafs_client
|
||
57 | include nftables::rules::out::http
|
||
58 | include nftables::rules::out::ssh::remove
|
||
59 | a1f09048 | Tim Meusel | include nftables::rules::out::hkp
|
60 | cfcafde5 | Steve Traylen | class{'nftables::rules::out::puppet':
|
61 | 04176b0e | mh | puppetserver => '127.0.0.1',
|
62 | cfcafde5 | Steve Traylen | }
|
63 | 194e05d5 | Tim Meusel | class{'nftables::rules::out::pxp_agent':
|
64 | broker => '127.0.0.1',
|
||
65 | }
|
||
66 | ea29e235 | Simon Hoenscheid | class{'nftables::rules::out::ldap':
|
67 | ldapserver => '127.0.0.1',
|
||
68 | }
|
||
69 | class{'nftables::rules::out::active_directory':
|
||
70 | adserver => '127.0.0.1',
|
||
71 | }
|
||
72 | cfcafde5 | Steve Traylen | include nftables::rules::out::all
|
73 | include nftables::rules::out::tor
|
||
74 | include nftables::rules::out::ospf3
|
||
75 | include nftables::rules::out::mysql
|
||
76 | include nftables::rules::out::ceph_client
|
||
77 | include nftables::rules::out::https
|
||
78 | include nftables::rules::out::dhcp
|
||
79 | include nftables::rules::out::nfs
|
||
80 | include nftables::rules::out::smtp
|
||
81 | 19908f41 | mh | include nftables::rules::out::smtp_client
|
82 | include nftables::rules::out::imap
|
||
83 | include nftables::rules::out::pop3
|
||
84 | cfcafde5 | Steve Traylen | include nftables::rules::out::chrony
|
85 | include nftables::rules::out::wireguard
|
||
86 | 2b1896c1 | Tim Meusel | include nftables::rules::out::whois
|
87 | cfcafde5 | Steve Traylen | include nftables::rules::wireguard
|
88 | 80b384c8 | Tim Meusel | include nftables::rules::multicast
|
89 | 8b131276 | Tim Meusel | include nftables::rules::spotify
|
90 | 3b26826f | Tim Meusel | include nftables::rules::llmnr
|
91 | 50a5be8b | Tim Meusel | include nftables::rules::ssdp
|
92 | 5ffd0328 | Tim Meusel | include nftables::rules::mdns
|
93 | 020842af | Tim Meusel | include nftables::rules::igmp
|
94 | ffc8b86f | Tim Meusel | include nftables::rules::wsd
|
95 | baad986e | Vadym Chepkov | include nftables::rules::ftp
|
96 | 020842af | Tim Meusel | include nftables::rules::out::igmp
|
97 | e499cece | Tim Meusel | include nftables::rules::out::mldv2
|
98 | 6b350264 | Tim Meusel | include nftables::rules::out::mdns
|
99 | 50a5be8b | Tim Meusel | include nftables::rules::out::ssdp
|
100 | cfcafde5 | Steve Traylen | include nftables::services::dhcpv6_client
|
101 | include nftables::services::openafs_client
|
||
102 | c94658e1 | Nacho Barrientos | nftables::set{'my_test_set':
|
103 | type => 'ipv4_addr',
|
||
104 | elements => ['192.168.0.1', '10.0.0.2'],
|
||
105 | table => ['inet-filter', 'ip-nat'],
|
||
106 | }
|
||
107 | 8842a597 | Tim Meusel | $config_path = $facts['os']['family'] ? {
|
108 | 'Archlinux' => '/etc/nftables.conf',
|
||
109 | 008c95d7 | Kienan Stewart | 'Debian' => '/etc/nftables.conf',
|
110 | 8842a597 | Tim Meusel | default => '/etc/sysconfig/nftables.conf',
|
111 | }
|
||
112 | $nft_path = $facts['os']['family'] ? {
|
||
113 | 'Archlinux' => '/usr/bin/nft',
|
||
114 | default => '/usr/sbin/nft',
|
||
115 | 0c9bc308 | hashworks | }
|
116 | cfcafde5 | Steve Traylen | # nftables cannot be started in docker so replace service with a validation only.
|
117 | systemd::dropin_file{"zzz_docker_nft.conf":
|
||
118 | ensure => present,
|
||
119 | unit => "nftables.service",
|
||
120 | content => [
|
||
121 | "[Service]",
|
||
122 | "ExecStart=",
|
||
123 | 8842a597 | Tim Meusel | "ExecStart=${nft_path} -c -I /etc/nftables/puppet -f ${config_path}",
|
124 | cfcafde5 | Steve Traylen | "ExecReload=",
|
125 | 8842a597 | Tim Meusel | "ExecReload=${nft_path} -c -I /etc/nftables/puppet -f ${config_path}",
|
126 | cfcafde5 | Steve Traylen | "",
|
127 | ].join("\n"),
|
||
128 | notify => Service["nftables"],
|
||
129 | }
|
||
130 | EOS
|
||
131 | # Run it twice and test for idempotency
|
||
132 | apply_manifest(pp, catch_failures: true) |
||
133 | apply_manifest(pp, catch_changes: true) |
||
134 | end
|
||
135 | |||
136 | describe package('nftables') do |
||
137 | it { is_expected.to be_installed } |
||
138 | end
|
||
139 | |||
140 | describe service('nftables') do |
||
141 | it { is_expected.to be_running } |
||
142 | it { is_expected.to be_enabled } |
||
143 | end
|
||
144 | |||
145 | b5874974 | Steve Traylen | describe file('/etc/nftables/puppet.nft', '/etc/systemd/system/nftables.service.d/puppet_nft.conf') do |
146 | cfcafde5 | Steve Traylen | it { is_expected.to be_file } |
147 | end
|
||
148 | |||
149 | describe file('/etc/nftables/puppet') do |
||
150 | it { is_expected.to be_directory } |
||
151 | end
|
||
152 | end
|
||
153 | end |