root / manifests / simplerule.pp @ d43ced4d
Historique | Voir | Annoter | Télécharger (1,49 ko)
1 | 83382bb5 | Nacho Barrientos | # 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 | fb65734d | Nacho Barrientos | $rulename = $title, |
9 | 83382bb5 | Nacho Barrientos | 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 | 3a52fb41 | Nacho Barrientos | Optional[Variant[Array[Stdlib::Port, 1], Stdlib::Port, Pattern[/\d+-\d+/]]] |
20 | 83382bb5 | Nacho Barrientos | $dport = undef, |
21 | 316bc3f8 | Nacho Barrientos | Optional[Enum['tcp', 'tcp4', 'tcp6', 'udp', 'udp4', 'udp6']] |
22 | 83382bb5 | Nacho Barrientos | $proto = undef, |
23 | aaa37172 | Nacho Barrientos | 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 | d43ced4d | Nacho Barrientos | Boolean |
28 | $counter = false, |
||
29 | 83382bb5 | Nacho Barrientos | ){ |
30 | |||
31 | 3a52fb41 | Nacho Barrientos | if $dport and !$proto { |
32 | fail('Specifying a transport protocol via $proto is mandatory when passing a port') |
||
33 | } |
||
34 | |||
35 | 83382bb5 | Nacho Barrientos | if $ensure == 'present' { |
36 | fb65734d | Nacho Barrientos | nftables::rule{"${chain}-${rulename}": |
37 | 83382bb5 | Nacho Barrientos | content => epp('nftables/simplerule.epp', |
38 | { |
||
39 | aaa37172 | Nacho Barrientos | 'action' => $action, |
40 | 'comment' => $comment, |
||
41 | d43ced4d | Nacho Barrientos | 'counter' => $counter, |
42 | aaa37172 | Nacho Barrientos | 'dport' => $dport, |
43 | 'proto' => $proto, |
||
44 | 'daddr' => $daddr, |
||
45 | 'set_type' => $set_type, |
||
46 | 83382bb5 | Nacho Barrientos | } |
47 | ), |
||
48 | order => $order, |
||
49 | table => $table, |
||
50 | } |
||
51 | } |
||
52 | } |