root / manifests / rule.pp @ 19908f41
Historique | Voir | Annoter | Télécharger (1,21 ko)
1 |
# manage a chain rule |
---|---|
2 |
# Name should be: |
3 |
# CHAIN_NAME-rulename |
4 |
define nftables::rule ( |
5 |
# lint:ignore:parameter_documentation |
6 |
Enum['present','absent'] $ensure = 'present', |
7 |
Nftables::RuleName $rulename = $title, |
8 |
Pattern[/^\d\d$/] $order = '50', |
9 |
Optional[String] $table = 'inet-filter', |
10 |
Optional[String] $content = undef, |
11 |
Optional[Variant[String,Array[String,1]]] $source = undef, |
12 |
# lint:endignore |
13 |
) { |
14 |
if $ensure == 'present' { |
15 |
$data = split($rulename, '-') |
16 |
|
17 |
if $data[2] { |
18 |
$fragment = "nftables-${table}-chain-${data[0]}-rule-${data[1]}-${data[2]}" |
19 |
} else { |
20 |
$fragment = "nftables-${table}-chain-${data[0]}-rule-${data[1]}" |
21 |
} |
22 |
|
23 |
concat::fragment { "${fragment}_header": |
24 |
content => "# Start of fragment order:${order} rulename:${rulename}", |
25 |
order => "${order}-${fragment}-a", |
26 |
target => "nftables-${table}-chain-${data[0]}", |
27 |
} |
28 |
|
29 |
concat::fragment { |
30 |
$fragment: |
31 |
order => "${order}-${fragment}-b", |
32 |
target => "nftables-${table}-chain-${data[0]}", |
33 |
} |
34 |
|
35 |
if $content { |
36 |
Concat::Fragment[$fragment] { |
37 |
content => " ${content}", |
38 |
} |
39 |
} else { |
40 |
Concat::Fragment[$fragment] { |
41 |
source => $source, |
42 |
} |
43 |
} |
44 |
} |
45 |
} |