root / manifests / simplerule.pp @ aaa37172
Historique | Voir | Annoter | Télécharger (1,43 ko)
1 |
# This class is meant to be useful to ease the migration from the Firewall type |
---|---|
2 |
# for simple use cases. The coverage of all the casuistry is rather low so for |
3 |
# any case not covered by nftables::simplerule please just use nftables::rule. |
4 |
define nftables::simplerule( |
5 |
Enum['present','absent'] |
6 |
$ensure = 'present', |
7 |
Pattern[/^[-a-zA-Z0-9_]+$/] |
8 |
$rulename = $title, |
9 |
Pattern[/^\d\d$/] |
10 |
$order = '50', |
11 |
String |
12 |
$chain = 'default_in', |
13 |
Optional[String] |
14 |
$table = 'inet-filter', |
15 |
Enum['accept', 'drop'] |
16 |
$action = 'accept', |
17 |
Optional[String] |
18 |
$comment = undef, |
19 |
Optional[Variant[Array[Stdlib::Port, 1], Stdlib::Port, Pattern[/\d+-\d+/]]] |
20 |
$dport = undef, |
21 |
Optional[Enum['tcp', 'tcp4', 'tcp6', 'udp', 'udp4', 'udp6']] |
22 |
$proto = undef, |
23 |
Optional[Variant[Stdlib::IP::Address::V6, Stdlib::IP::Address::V4, Pattern[/^@[-a-zA-Z0-9_]+$/]]] |
24 |
$daddr = undef, |
25 |
Enum['ip', 'ip6'] |
26 |
$set_type = 'ip6', |
27 |
){ |
28 |
|
29 |
if $dport and !$proto { |
30 |
fail('Specifying a transport protocol via $proto is mandatory when passing a port') |
31 |
} |
32 |
|
33 |
if $ensure == 'present' { |
34 |
nftables::rule{"${chain}-${rulename}": |
35 |
content => epp('nftables/simplerule.epp', |
36 |
{ |
37 |
'action' => $action, |
38 |
'comment' => $comment, |
39 |
'dport' => $dport, |
40 |
'proto' => $proto, |
41 |
'daddr' => $daddr, |
42 |
'set_type' => $set_type, |
43 |
} |
44 |
), |
45 |
order => $order, |
46 |
table => $table, |
47 |
} |
48 |
} |
49 |
} |