root / manifests / init.pp @ 2c00d766
Historique | Voir | Annoter | Télécharger (1,65 ko)
1 |
# @summary Configure nftables |
---|---|
2 |
# |
3 |
# @example |
4 |
# class{'nftables: |
5 |
# out_ntp = false, |
6 |
# out_dns = true, |
7 |
# } |
8 |
# |
9 |
# @param out_all |
10 |
# Allow all outbound connections. If `true` then all other |
11 |
# out parameters `out_ntp`, `out_dns`, ... will be assuemed |
12 |
# false. |
13 |
# |
14 |
# @param out_ntp |
15 |
# Allow outbound to ntp servers. |
16 |
# |
17 |
# @param out_http |
18 |
# Allow outbound to http servers. |
19 |
# |
20 |
# @param out_https |
21 |
# Allow outbound to https servers. |
22 |
# |
23 |
# @param out_https |
24 |
# Allow outbound to https servers. |
25 |
# |
26 |
# @param in_ssh |
27 |
# Allow inbound to ssh servers. |
28 |
# |
29 |
class nftables ( |
30 |
Boolean $in_ssh = true, |
31 |
Boolean $out_ntp = true, |
32 |
Boolean $out_dns = true, |
33 |
Boolean $out_http = true, |
34 |
Boolean $out_https = true, |
35 |
Boolean $out_all = false, |
36 |
Hash $rules = {}, |
37 |
) { |
38 |
|
39 |
package{'nftables': |
40 |
ensure => installed, |
41 |
} -> file_line{ |
42 |
'enable_nftables': |
43 |
line => 'include "/etc/nftables/puppet.nft"', |
44 |
path => '/etc/sysconfig/nftables.conf', |
45 |
notify => Service['nftables'], |
46 |
} -> file{ |
47 |
default: |
48 |
owner => 'root', |
49 |
group => 'root', |
50 |
mode => '0640'; |
51 |
'/etc/nftables/puppet.nft': |
52 |
ensure => file, |
53 |
source => 'puppet:///modules/nftables/config/puppet.nft'; |
54 |
'/etc/nftables/puppet': |
55 |
ensure => directory, |
56 |
mode => '0750', |
57 |
purge => true, |
58 |
force => true, |
59 |
recurse => true; |
60 |
} ~> service{'nftables': |
61 |
ensure => running, |
62 |
enable => true, |
63 |
} |
64 |
|
65 |
service{'firewalld': |
66 |
ensure => stopped, |
67 |
enable => mask, |
68 |
} |
69 |
|
70 |
include nftables::inet_filter |
71 |
include nftables::ip_nat |
72 |
|
73 |
# inject custom rules e.g. from hiera |
74 |
$rules.each |$n,$v| { |
75 |
nftables::rule{ |
76 |
$n: |
77 |
* => $v |
78 |
} |
79 |
} |
80 |
} |