root / manifests / config.pp @ bbc93ede
Historique | Voir | Annoter | Télécharger (1,29 ko)
1 |
# manage a config snippet |
---|---|
2 |
define nftables::config( |
3 |
Optional[String] |
4 |
$content = undef, |
5 |
Optional[Variant[String,Array[String,1]]] |
6 |
$source = undef, |
7 |
){ |
8 |
$concat_name = "nftables-${name}" |
9 |
|
10 |
Package['nftables'] -> concat{ |
11 |
$concat_name: |
12 |
path => "/etc/nftables/puppet-preflight/${name}.nft", |
13 |
ensure_newline => true, |
14 |
owner => root, |
15 |
group => root, |
16 |
mode => '0640', |
17 |
} ~> Exec['nft validate'] -> file{ |
18 |
"/etc/nftables/puppet/${name}.nft": |
19 |
ensure => file, |
20 |
source => "/etc/nftables/puppet-preflight/${name}.nft", |
21 |
owner => root, |
22 |
group => root, |
23 |
mode => '0640', |
24 |
} ~> Service['nftables'] |
25 |
|
26 |
$data = split($name, '-') |
27 |
|
28 |
concat::fragment { |
29 |
"${concat_name}-header": |
30 |
target => $concat_name, |
31 |
order => '00', |
32 |
content => "table ${data[0]} ${data[1]} {", |
33 |
} |
34 |
|
35 |
if $source { |
36 |
concat::fragment { |
37 |
"${concat_name}-body": |
38 |
target => $concat_name, |
39 |
order => 98, |
40 |
source => $source, |
41 |
} |
42 |
} else { |
43 |
concat::fragment { |
44 |
"${concat_name}-body": |
45 |
target => $concat_name, |
46 |
order => '98', |
47 |
content => $content, |
48 |
} |
49 |
} |
50 |
|
51 |
concat::fragment { |
52 |
"${concat_name}-footer": |
53 |
target => $concat_name, |
54 |
order => '99', |
55 |
content => '}', |
56 |
} |
57 |
} |