root / spec / acceptance / all_rules_spec.rb @ 8842a597
Historique | Voir | Annoter | Télécharger (4,42 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 | include nftables::rules::http
|
||
30 | include nftables::rules::puppet
|
||
31 | include nftables::rules::icinga2
|
||
32 | include nftables::rules::tor
|
||
33 | include nftables::rules::ospf3
|
||
34 | include nftables::rules::ceph_mon
|
||
35 | include nftables::rules::smtp_submission
|
||
36 | include nftables::rules::https
|
||
37 | include nftables::rules::nfs
|
||
38 | include nftables::rules::smtps
|
||
39 | include nftables::rules::smtp
|
||
40 | include nftables::rules::ceph
|
||
41 | 1ee2f66b | Giuseppe Lo Presti | include nftables::rules::samba
|
42 | 771b3256 | Nacho Barrientos | include nftables::rules::activemq
|
43 | 6be2adf7 | Luis Fernández Álvarez | include nftables::rules::docker_ce
|
44 | cd2a3cbf | Nacho Barrientos | include nftables::rules::qemu
|
45 | cfcafde5 | Steve Traylen | include nftables::rules::out::postgres
|
46 | include nftables::rules::out::icmp
|
||
47 | include nftables::rules::out::dns
|
||
48 | include nftables::rules::out::nfs3
|
||
49 | include nftables::rules::out::ssh
|
||
50 | include nftables::rules::out::kerberos
|
||
51 | include nftables::rules::out::dhcpv6_client
|
||
52 | include nftables::rules::out::ospf
|
||
53 | include nftables::rules::out::openafs_client
|
||
54 | include nftables::rules::out::http
|
||
55 | include nftables::rules::out::ssh::remove
|
||
56 | class{'nftables::rules::out::puppet':
|
||
57 | 04176b0e | mh | puppetserver => '127.0.0.1',
|
58 | cfcafde5 | Steve Traylen | }
|
59 | include nftables::rules::out::all
|
||
60 | include nftables::rules::out::tor
|
||
61 | include nftables::rules::out::ospf3
|
||
62 | include nftables::rules::out::mysql
|
||
63 | include nftables::rules::out::ceph_client
|
||
64 | include nftables::rules::out::https
|
||
65 | include nftables::rules::out::dhcp
|
||
66 | include nftables::rules::out::nfs
|
||
67 | include nftables::rules::out::smtp
|
||
68 | 19908f41 | mh | include nftables::rules::out::smtp_client
|
69 | include nftables::rules::out::imap
|
||
70 | include nftables::rules::out::pop3
|
||
71 | cfcafde5 | Steve Traylen | include nftables::rules::out::chrony
|
72 | include nftables::rules::out::wireguard
|
||
73 | include nftables::rules::wireguard
|
||
74 | include nftables::services::dhcpv6_client
|
||
75 | include nftables::services::openafs_client
|
||
76 | c94658e1 | Nacho Barrientos | nftables::set{'my_test_set':
|
77 | type => 'ipv4_addr',
|
||
78 | elements => ['192.168.0.1', '10.0.0.2'],
|
||
79 | table => ['inet-filter', 'ip-nat'],
|
||
80 | }
|
||
81 | 8842a597 | Tim Meusel | $config_path = $facts['os']['family'] ? {
|
82 | 'Archlinux' => '/etc/nftables.conf',
|
||
83 | default => '/etc/sysconfig/nftables.conf',
|
||
84 | }
|
||
85 | $nft_path = $facts['os']['family'] ? {
|
||
86 | 'Archlinux' => '/usr/bin/nft',
|
||
87 | default => '/usr/sbin/nft',
|
||
88 | 0c9bc308 | hashworks | }
|
89 | cfcafde5 | Steve Traylen | # nftables cannot be started in docker so replace service with a validation only.
|
90 | systemd::dropin_file{"zzz_docker_nft.conf":
|
||
91 | ensure => present,
|
||
92 | unit => "nftables.service",
|
||
93 | content => [
|
||
94 | "[Service]",
|
||
95 | "ExecStart=",
|
||
96 | 8842a597 | Tim Meusel | "ExecStart=${nft_path} -c -I /etc/nftables/puppet -f ${config_path}",
|
97 | cfcafde5 | Steve Traylen | "ExecReload=",
|
98 | 8842a597 | Tim Meusel | "ExecReload=${nft_path} -c -I /etc/nftables/puppet -f ${config_path}",
|
99 | cfcafde5 | Steve Traylen | "",
|
100 | ].join("\n"),
|
||
101 | notify => Service["nftables"],
|
||
102 | }
|
||
103 | EOS
|
||
104 | # Run it twice and test for idempotency
|
||
105 | apply_manifest(pp, catch_failures: true) |
||
106 | apply_manifest(pp, catch_changes: true) |
||
107 | end
|
||
108 | |||
109 | describe package('nftables') do |
||
110 | it { is_expected.to be_installed } |
||
111 | end
|
||
112 | |||
113 | describe service('nftables') do |
||
114 | it { is_expected.to be_running } |
||
115 | it { is_expected.to be_enabled } |
||
116 | end
|
||
117 | |||
118 | b5874974 | Steve Traylen | describe file('/etc/nftables/puppet.nft', '/etc/systemd/system/nftables.service.d/puppet_nft.conf') do |
119 | cfcafde5 | Steve Traylen | it { is_expected.to be_file } |
120 | end
|
||
121 | |||
122 | describe file('/etc/nftables/puppet') do |
||
123 | it { is_expected.to be_directory } |
||
124 | end
|
||
125 | end
|
||
126 | end |