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