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
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
|
# File 'manifests/simplerule.pp', line 60
define nftables::simplerule (
Enum['present','absent'] $ensure = 'present',
Nftables::SimpleRuleName $rulename = $title,
Pattern[/^\d\d$/] $order = '50',
String $chain = 'default_in',
String $table = 'inet-filter',
Enum['accept', 'continue', 'drop', 'queue', 'return'] $action = 'accept',
Optional[String] $comment = undef,
Optional[Nftables::Port] $dport = undef,
Optional[Enum['tcp', 'tcp4', 'tcp6', 'udp', 'udp4', 'udp6']] $proto = undef,
Optional[Nftables::Addr] $daddr = undef,
Enum['ip', 'ip6'] $set_type = 'ip6',
Optional[Nftables::Port] $sport = undef,
Optional[Nftables::Addr] $saddr = undef,
Boolean $counter = false,
Variant[Array[String[1]],String[1]] $iifname = [],
Variant[Array[String[1]],String[1]] $oifname = [],
) {
if $dport and !$proto {
fail('Specifying a transport protocol via $proto is mandatory when passing a $dport')
}
if $sport and !$proto {
fail('Specifying a transport protocol via $proto is mandatory when passing a $sport')
}
if $ensure == 'present' {
nftables::rule { "${chain}-${rulename}":
content => epp('nftables/simplerule.epp',
{
'action' => $action,
'comment' => $comment,
'counter' => $counter,
'daddr' => $daddr,
'dport' => $dport,
'proto' => $proto,
'saddr' => $saddr,
'set_type' => $set_type,
'sport' => $sport,
'iifname' => [$iifname].flatten,
'oifname' => [$oifname].flatten,
}
),
order => $order,
table => $table,
}
}
}
|