Projet

Général

Profil

Paste
Télécharger au format
Statistiques
| Branche: | Révision:

root / manifests / config.pp @ ac0af4aa

Historique | Voir | Annoter | Télécharger (1,07 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/${name}.nft",
13
      ensure_newline => true,
14
      owner          => root,
15
      group          => root,
16
      mode           => '0640',
17
  } ~> Service['nftables']
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

    
28
  if $source {
29
    concat::fragment {
30
      "${concat_name}-body":
31
        target => $concat_name,
32
        order  => 98,
33
        source => $source,
34
    }
35
  } else {
36
    concat::fragment {
37
      "${concat_name}-body":
38
        target  => $concat_name,
39
        order   => '98',
40
        content => $content,
41
    }
42
  }
43

    
44
  concat::fragment {
45
    "${concat_name}-footer":
46
      target  => $concat_name,
47
      order   => '99',
48
      content => '}',
49
  }
50
}