Révision e4c32222
Use concat for table conf generation
This way other components of the module will be able to add extra stuff
to the table definitions like sets.
manifests/config.pp | ||
---|---|---|
5 | 5 |
Optional[Variant[String,Array[String,1]]] |
6 | 6 |
$source = undef, |
7 | 7 |
){ |
8 |
Package['nftables'] -> file{ |
|
9 |
"/etc/nftables/puppet/${name}.nft": |
|
10 |
ensure => file, |
|
11 |
owner => root, |
|
12 |
group => root, |
|
13 |
mode => '0640', |
|
8 |
$concat_name = "nftables-${name}" |
|
9 |
|
|
10 |
Package['nftables'] -> concat{ |
|
11 |
$concat_name: |
|
12 |
path => "/etc/nftables/puppet/${name}.nft", |
|
13 |
ensure_newline => true, |
|
14 |
owner => root, |
|
15 |
group => root, |
|
16 |
mode => '0640', |
|
14 | 17 |
} ~> Service['nftables'] |
15 | 18 |
|
19 |
$data = split($name, '-') |
|
20 |
|
|
21 |
concat::fragment { |
|
22 |
"${concat_name}-header": |
|
23 |
target => $concat_name, |
|
24 |
order => '00', |
|
25 |
content => "table ${data[0]} ${data[1]} {", |
|
26 |
} |
|
27 |
|
|
16 | 28 |
if $source { |
17 |
File["/etc/nftables/puppet/${name}.nft"]{ |
|
18 |
source => $source, |
|
29 |
concat::fragment { |
|
30 |
"${concat_name}-body": |
|
31 |
target => $concat_name, |
|
32 |
order => 98, |
|
33 |
source => $source, |
|
19 | 34 |
} |
20 | 35 |
} else { |
21 |
File["/etc/nftables/puppet/${name}.nft"]{ |
|
22 |
content => $content, |
|
36 |
concat::fragment { |
|
37 |
"${concat_name}-body": |
|
38 |
target => $concat_name, |
|
39 |
order => '98', |
|
40 |
content => $content, |
|
23 | 41 |
} |
24 | 42 |
} |
43 |
|
|
44 |
concat::fragment { |
|
45 |
"${concat_name}-footer": |
|
46 |
target => $concat_name, |
|
47 |
order => '99', |
|
48 |
content => '}', |
|
49 |
} |
|
25 | 50 |
} |
Formats disponibles : Unified diff