root / manifests / helper.pp @ 8f4434ed
Historique | Voir | Annoter | Télécharger (1,54 ko)
1 | baad986e | Vadym Chepkov | # @summary manage a conntrack helper |
---|---|---|---|
2 | # |
||
3 | # @example FTP helper |
||
4 | # nftables::helper { 'ftp-standard': |
||
5 | # content => 'type "ftp" protocol tcp;', |
||
6 | # } |
||
7 | # |
||
8 | # @param content |
||
9 | # Conntrack helper definition. |
||
10 | # @param table |
||
11 | # The name of the table to add this helper to. |
||
12 | # @param helper |
||
13 | # The symbolic name for the helper. |
||
14 | define nftables::helper ( |
||
15 | String $content, |
||
16 | Pattern[/^(ip|ip6|inet)-[a-zA-Z0-9_]+$/] $table = 'inet-filter', |
||
17 | Pattern[/^[a-zA-Z0-9_][A-z0-9_-]*$/] $helper = $title, |
||
18 | ) { |
||
19 | $concat_name = "nftables-${table}-helper-${helper}" |
||
20 | |||
21 | concat { |
||
22 | $concat_name: |
||
23 | path => "/etc/nftables/puppet-preflight/${table}-helper-${helper}.nft", |
||
24 | owner => root, |
||
25 | group => root, |
||
26 | mode => $nftables::default_config_mode, |
||
27 | ensure_newline => true, |
||
28 | require => Package['nftables'], |
||
29 | } ~> Exec['nft validate'] -> file { |
||
30 | "/etc/nftables/puppet/${table}-helper-${helper}.nft": |
||
31 | ensure => file, |
||
32 | source => "/etc/nftables/puppet-preflight/${table}-helper-${helper}.nft", |
||
33 | owner => root, |
||
34 | group => root, |
||
35 | mode => $nftables::default_config_mode, |
||
36 | } ~> Service['nftables'] |
||
37 | |||
38 | concat::fragment { |
||
39 | default: |
||
40 | target => $concat_name; |
||
41 | "${concat_name}-header": |
||
42 | order => '00', |
||
43 | content => "# Start of fragment order:00 ${helper} header\nct helper ${helper} {"; |
||
44 | "${concat_name}-body": |
||
45 | order => '98', |
||
46 | content => $content; |
||
47 | "${concat_name}-footer": |
||
48 | order => '99', |
||
49 | content => "# Start of fragment order:99 ${helper} footer\n}"; |
||
50 | } |
||
51 | } |