root / manifests / rule.pp @ a074dec2
Historique | Voir | Annoter | Télécharger (920 octets)
1 |
# manage a chain rule |
---|---|
2 |
# Name should be: |
3 |
# CHAIN_NAME-rulename |
4 |
define nftables::rule( |
5 |
Enum['present','absent'] |
6 |
$ensure = 'present', |
7 |
Pattern[/^[a-zA-Z0-9_]+-[a-zA-Z0-9_]+(-\d+)?$/] |
8 |
$rulename = $title, |
9 |
Pattern[/^\d\d$/] |
10 |
$order = '50', |
11 |
Optional[String] |
12 |
$table = 'inet-filter', |
13 |
Optional[String] |
14 |
$content = undef, |
15 |
Optional[Variant[String,Array[String,1]]] |
16 |
$source = undef, |
17 |
){ |
18 |
|
19 |
if $ensure == 'present' { |
20 |
$data = split($rulename, '-') |
21 |
|
22 |
concat::fragment{ |
23 |
"nftables-${table}-chain-${data[0]}-rule-${data[1]}": |
24 |
order => $order, |
25 |
target => "nftables-${table}-chain-${data[0]}", |
26 |
} |
27 |
|
28 |
if $content { |
29 |
Concat::Fragment["nftables-${table}-chain-${data[0]}-rule-${data[1]}"]{ |
30 |
content => " ${content}", |
31 |
} |
32 |
} else { |
33 |
Concat::Fragment["nftables-${table}-chain-${data[0]}-rule-${data[1]}"]{ |
34 |
source => $source, |
35 |
} |
36 |
} |
37 |
} |
38 |
} |