Defined Type: nftables::config
- Defined in:
- manifests/config.pp
Overview
manage a config snippet
2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 |
# File 'manifests/config.pp', line 2
define nftables::config (
# lint:ignore:parameter_documentation
Pattern[/^\w+-\w+$/] $tablespec = $title,
Optional[String] $content = undef,
Optional[Variant[String,Array[String,1]]] $source = undef,
String $prefix = 'custom-',
# lint:endignore
) {
if $content and $source {
fail('Please pass only $content or $source, not both.')
}
$concat_name = "nftables-${name}"
Package['nftables'] -> concat {
$concat_name:
path => "/etc/nftables/puppet-preflight/${prefix}${name}.nft",
ensure_newline => true,
owner => root,
group => root,
mode => $nftables::default_config_mode,
} ~> Exec['nft validate'] -> file {
"/etc/nftables/puppet/${prefix}${name}.nft":
ensure => file,
source => "/etc/nftables/puppet-preflight/${prefix}${name}.nft",
owner => root,
group => root,
mode => $nftables::default_config_mode,
} ~> Service['nftables']
$data = split($name, '-')
concat::fragment {
"${concat_name}-header":
target => $concat_name,
order => '00',
content => "table ${data[0]} ${data[1]} {",
}
if $source {
concat::fragment {
"${concat_name}-body":
target => $concat_name,
order => 98,
source => $source,
}
} else {
if $content {
$_content = $content
} else {
$_content = " include \"${name}-chain-*.nft\""
}
concat::fragment {
"${concat_name}-body":
target => $concat_name,
order => '98',
content => $_content,
}
}
concat::fragment {
"${concat_name}-footer":
target => $concat_name,
order => '99',
content => '}',
}
}
|