root / manifests / rules / snat4.pp @ e499cece
Historique | Voir | Annoter | Télécharger (1,13 ko)
1 | 09cba182 | Steve Traylen | # @summary manage a ipv4 snat rule |
---|---|---|---|
2 | 11bf7237 | Steve Traylen | define nftables::rules::snat4 ( |
3 | 09cba182 | Steve Traylen | # lint:ignore:parameter_documentation |
4 | 31b17627 | Steve Traylen | String[1] $snat, |
5 | Pattern[/^[a-zA-Z0-9_]+$/] $rulename = $title, |
||
6 | Pattern[/^\d\d$/] $order = '70', |
||
7 | String[1] $chain = 'POSTROUTING', |
||
8 | Optional[String[1]] $oif = undef, |
||
9 | Optional[String[1]] $saddr = undef, |
||
10 | Optional[Enum['tcp','udp']] $proto = undef, |
||
11 | 94a80621 | Steve Traylen | Optional[Variant[String,Stdlib::Port]] $dport = undef, |
12 | 31b17627 | Steve Traylen | Enum['present','absent'] $ensure = 'present', |
13 | 09cba182 | Steve Traylen | # lint:endignore |
14 | 3d29a6eb | tr | ) { |
15 | $oifname = $oif ? { |
||
16 | undef => '', |
||
17 | default => "oifname ${oif} ", |
||
18 | } |
||
19 | $src = $saddr ? { |
||
20 | undef => '', |
||
21 | default => "ip saddr ${saddr} ", |
||
22 | } |
||
23 | |||
24 | if $proto and $dport { |
||
25 | $protocol = '' |
||
26 | $port = "${proto} dport ${dport} " |
||
27 | } elsif $proto { |
||
28 | $protocol = "${proto} " |
||
29 | $port = '' |
||
30 | } elsif $dport { |
||
31 | $protocol = '' |
||
32 | $port = "tcp dport ${dport} " |
||
33 | } else { |
||
34 | $protocol = '' |
||
35 | $port = '' |
||
36 | } |
||
37 | |||
38 | 11bf7237 | Steve Traylen | nftables::rule { |
39 | 3d29a6eb | tr | "${chain}-${rulename}": |
40 | ensure => $ensure, |
||
41 | fcb79d73 | Ben Morrice | table => "ip-${nftables::nat_table_name}", |
42 | 3d29a6eb | tr | order => $order, |
43 | content => "${oifname}${src}${protocol}${port}snat ${snat}"; |
||
44 | } |
||
45 | } |