45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
|
# File 'manifests/rule.pp', line 45
define nftables::rule (
Enum['present','absent'] $ensure = 'present',
Nftables::RuleName $rulename = $title,
Pattern[/^\d\d$/] $order = '50',
String $table = 'inet-filter',
Optional[String] $content = undef,
Optional[Variant[String,Array[String,1]]] $source = undef,
) {
if $ensure == 'present' {
$data = split($rulename, '-')
if $data[2] {
$fragment = "nftables-${table}-chain-${data[0]}-rule-${data[1]}-${data[2]}"
} else {
$fragment = "nftables-${table}-chain-${data[0]}-rule-${data[1]}"
}
concat::fragment { "${fragment}_header":
content => "# Start of fragment order:${order} rulename:${rulename}",
order => "${order}-${fragment}-a",
target => "nftables-${table}-chain-${data[0]}",
}
concat::fragment {
$fragment:
order => "${order}-${fragment}-b",
target => "nftables-${table}-chain-${data[0]}",
}
if $content {
Concat::Fragment[$fragment] {
content => " ${content}",
}
} else {
Concat::Fragment[$fragment] {
source => $source,
}
}
}
}
|