Projet

Général

Profil

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

root / manifests / config.pp @ fcb1d356

Historique | Voir | Annoter | Télécharger (1,41 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
    if $content {
42
      $_content = $content
43
    } else {
44
      $_content = "  include \"${name}-chain-*.nft\""
45
    }
46
    concat::fragment {
47
      "${concat_name}-body":
48
        target  => $concat_name,
49
        order   => '98',
50
        content => $_content,
51
    }
52
  }
53

    
54
  concat::fragment {
55
    "${concat_name}-footer":
56
      target  => $concat_name,
57
      order   => '99',
58
      content => '}',
59
  }
60
}