25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
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
85
86
87
|
# File 'manifests/set.pp', line 25
define nftables::set (
Enum['present','absent'] $ensure = 'present',
Pattern[/^[-a-zA-Z0-9_]+$/] $setname = $title,
Pattern[/^\d\d$/] $order = '10',
Optional[Enum['ipv4_addr', 'ipv6_addr', 'ether_addr', 'inet_proto', 'inet_service', 'mark']] $type = undef,
Variant[String, Array[String, 1]] $table = 'inet-filter',
Array[Enum['constant', 'dynamic', 'interval', 'timeout'], 0, 4] $flags = [],
Optional[Integer] $timeout = undef,
Optional[Integer] $gc_interval = undef,
Optional[Array[String]] $elements = undef,
Optional[Integer] $size = undef,
Optional[Enum['performance', 'memory']] $policy = undef,
Boolean $auto_merge = false,
Optional[String] $content = undef,
Optional[Variant[String,Array[String,1]]] $source = undef,
) {
if $size and $elements {
if length($elements) > $size {
fail("Max size of set ${setname} of ${size} is not being respected")
}
}
$_tables = Array($table, true)
if $ensure == 'present' {
$_tables.each |Integer $index, String $_table| {
concat::fragment {
"nftables-${_table}-set-${setname}":
order => $order,
target => "nftables-${_table}",
}
if $content {
Concat::Fragment["nftables-${_table}-set-${setname}"] {
content => " ${content}",
}
} elsif $source {
Concat::Fragment["nftables-${_table}-set-${setname}"] {
source => $source,
}
} else {
if $type == undef {
fail('The way the resource is configured must have a type set')
}
Concat::Fragment["nftables-${_table}-set-${setname}"] {
content => epp('nftables/set.epp',
{
'name' => $setname,
'type' => $type,
'flags' => $flags,
'timeout' => $timeout,
'gc_interval' => $gc_interval,
'elements' => $elements,
'size' => $size,
'policy' => $policy,
'auto_merge' => $auto_merge,
}
)
}
}
}
}
}
|