Defined Type: nftables::file

Defined in:
manifests/file.pp

Summary

Insert a file into the nftables configuration

Overview

Examples:

Include a file that includes other files

nftables::file{'geoip':
  content => @(EOT)
    include "/var/local/geoipsets/dbip/nftset/ipv4/*.ipv4"
    include "/var/local/geoipsets/dbip/nftset/ipv6/*.ipv6"
    |EOT,
}

Parameters:

  • label (String[1]) (defaults to: $title)

    Unique name to include in filename.

  • content (Optional[String]) (defaults to: undef)

    The content to place in the file.

  • source (Optional[Variant[String,Array[String,1]]]) (defaults to: undef)

    A source to obtain the file content from.

  • prefix (String) (defaults to: 'file-')

    Prefix of file name to be created, if left as ‘file-` it will be auto included in the main nft configuration



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
# File 'manifests/file.pp', line 17

define nftables::file (
  String[1] $label = $title,
  Optional[String] $content = undef,
  Optional[Variant[String,Array[String,1]]] $source = undef,
  String $prefix = 'file-',
) {
  if $content and $source {
    fail('Please pass only $content or $source, not both.')
  }

  $concat_name = "nftables-${name}"

  Package['nftables'] -> file { "/etc/nftables/puppet-preflight/${prefix}${label}.nft":
    ensure  => file,
    owner   => root,
    group   => root,
    mode    => $nftables::default_config_mode,
    content => $content,
    source  => $source,
  } ~> Exec['nft validate'] -> file { "/etc/nftables/puppet/${prefix}${label}.nft":
    ensure  => file,
    owner   => root,
    group   => root,
    mode    => $nftables::default_config_mode,
    content => $content,
    source  => $source,
  } ~> Service['nftables']
}