Projet

Général

Profil

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

root / manifests / rule.pp @ fcb1d356

Historique | Voir | Annoter | Télécharger (1,18 ko)

1
# manage a chain rule
2
# Name should be:
3
#   CHAIN_NAME-rulename
4
define nftables::rule (
5
  Enum['present','absent'] $ensure = 'present',
6
  Pattern[/^[a-zA-Z0-9_]+-[a-zA-Z0-9_]+(-\d+)?$/] $rulename = $title,
7
  Pattern[/^\d\d$/] $order = '50',
8
  Optional[String] $table = 'inet-filter',
9
  Optional[String] $content = undef,
10
  Optional[Variant[String,Array[String,1]]] $source = undef,
11
) {
12
  if $ensure == 'present' {
13
    $data = split($rulename, '-')
14

    
15
    if $data[2] {
16
      $fragment = "nftables-${table}-chain-${data[0]}-rule-${data[1]}-${data[2]}"
17
    } else {
18
      $fragment = "nftables-${table}-chain-${data[0]}-rule-${data[1]}"
19
    }
20

    
21
    concat::fragment { "${fragment}_header":
22
      content => "#   Start of fragment order:${order} rulename:${rulename}",
23
      order   => "${order}-${fragment}-a",
24
      target  => "nftables-${table}-chain-${data[0]}",
25
    }
26

    
27
    concat::fragment {
28
      $fragment:
29
        order  => "${order}-${fragment}-b",
30
        target => "nftables-${table}-chain-${data[0]}",
31
    }
32

    
33
    if $content {
34
      Concat::Fragment[$fragment] {
35
        content => "  ${content}",
36
      }
37
    } else {
38
      Concat::Fragment[$fragment] {
39
        source => $source,
40
      }
41
    }
42
  }
43
}