root / manifests / init.pp @ ac0af4aa
Historique | Voir | Annoter | Télécharger (2,48 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 |
# @param log_prefix |
30 |
# String that will be used as prefix when logging packets. It can contain |
31 |
# two variables using standard sprintf() string-formatting: |
32 |
# * chain: Will be replaced by the name of the chain. |
33 |
# * comment: Allows chains to add extra comments. |
34 |
# |
35 |
# @param reject_with |
36 |
# How to discard packets not matching any rule. If `false`, the |
37 |
# fate of the packet will be defined by the chain policy (normally |
38 |
# drop), otherwise the packet will be rejected with the REJECT_WITH |
39 |
# policy indicated by the value of this parameter. |
40 |
# |
41 |
class nftables ( |
42 |
Boolean $in_ssh = true, |
43 |
Boolean $out_ntp = true, |
44 |
Boolean $out_dns = true, |
45 |
Boolean $out_http = true, |
46 |
Boolean $out_https = true, |
47 |
Boolean $out_all = false, |
48 |
Hash $rules = {}, |
49 |
String $log_prefix = '[nftables] %<chain>s %<comment>s', |
50 |
Variant[Boolean[false], Pattern[ |
51 |
/icmp(v6|x)? type .+|tcp reset/]] |
52 |
$reject_with = 'icmpx type port-unreachable', |
53 |
) { |
54 |
|
55 |
package{'nftables': |
56 |
ensure => installed, |
57 |
} -> file_line{ |
58 |
'enable_nftables': |
59 |
line => 'include "/etc/nftables/puppet.nft"', |
60 |
path => '/etc/sysconfig/nftables.conf', |
61 |
notify => Service['nftables'], |
62 |
} -> file{ |
63 |
default: |
64 |
owner => 'root', |
65 |
group => 'root', |
66 |
mode => '0640'; |
67 |
'/etc/nftables/puppet.nft': |
68 |
ensure => file, |
69 |
source => 'puppet:///modules/nftables/config/puppet.nft'; |
70 |
'/etc/nftables/puppet': |
71 |
ensure => directory, |
72 |
mode => '0750', |
73 |
purge => true, |
74 |
force => true, |
75 |
recurse => true; |
76 |
} ~> service{'nftables': |
77 |
ensure => running, |
78 |
enable => true, |
79 |
} |
80 |
|
81 |
service{'firewalld': |
82 |
ensure => stopped, |
83 |
enable => mask, |
84 |
} |
85 |
|
86 |
include nftables::inet_filter |
87 |
include nftables::ip_nat |
88 |
|
89 |
# inject custom rules e.g. from hiera |
90 |
$rules.each |$n,$v| { |
91 |
nftables::rule{ |
92 |
$n: |
93 |
* => $v |
94 |
} |
95 |
} |
96 |
} |