Defined Type: concat

Defined in:
vendor_modules/concat/manifests/init.pp

Summary

Manages a file, compiled from one or more text fragments.

Overview

Examples:

concat { '/tmp/concat':
  ensure => present,
  owner  => 'root',
  group  => 'root',
  mode   => '0644',
}

Parameters:

  • backup (Variant[Boolean, String]) (defaults to: 'puppet')

    Specifies whether (and how) to back up the destination file before overwriting it. Your value gets passed on to Puppet's native file resource for execution. Valid options: true, false, or a string representing either a target filebucket or a filename extension beginning with “.”.

  • ensure (Enum['present', 'absent']) (defaults to: 'present')

    Specifies whether the destination file should exist. Setting to 'absent' tells Puppet to delete the destination file if it exists, and negates the effect of any other parameters.

  • ensure_newline (Boolean) (defaults to: false)

    Specifies whether to add a line break at the end of each fragment that doesn't already end in one.

  • format (Optional[String]) (defaults to: 'plain')

    Specify what data type to merge the fragments as. Valid options: 'plain', 'yaml', 'json', 'json-array', 'json-pretty', 'json-array-pretty'.

  • force (Optional[Boolean]) (defaults to: false)

    Specifies whether to merge data structures, keeping the values with higher order. Used when format is specified as a value other than 'plain'.

  • group (Optional[Variant[String, Integer]]) (defaults to: undef)

    Specifies a permissions group for the destination file. Valid options: a string containing a group name or integer containing a gid.

  • mode (String) (defaults to: '0644')

    Specifies the permissions mode of the destination file. Valid options: a string containing a permission mode value in octal notation.

  • order (Enum['alpha','numeric']) (defaults to: 'alpha')

    Specifies a method for sorting your fragments by name within the destination file. You can override this setting for individual fragments by adjusting the order parameter in their concat::fragment declarations.

  • owner (Optional[Variant[String, Integer]]) (defaults to: undef)

    Specifies the owner of the destination file. Valid options: a string containing a username or integer containing a uid.

  • path (Stdlib::Absolutepath) (defaults to: $name)

    Specifies a destination file for the combined fragments.

  • replace (Boolean) (defaults to: true)

    Specifies whether to overwrite the destination file if it already exists.

  • selinux_ignore_defaults (Optional[Boolean]) (defaults to: undef)

    See the file type's selinux_ignore_defaults documentention: docs.puppetlabs.com/references/latest/type.html#file-attribute-selinux_ignore_defaults

  • selrange (Optional[String]) (defaults to: undef)
  • selrole (Optional[String]) (defaults to: undef)
  • seltype (Optional[String]) (defaults to: undef)
  • seluser (Optional[String]) (defaults to: undef)
  • show_diff (Boolean) (defaults to: true)

    Specifies whether to set the show_diff parameter for the file resource. Useful for hiding secrets stored in hiera from insecure reporting methods.

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

    Specifies a validation command to apply to the destination file.

  • warn (Variant[Boolean, String]) (defaults to: false)

    Specifies whether to add a header message at the top of the destination file. Valid options: the booleans true and false, or a string to serve as the header. If you set 'warn' to true, concat adds the following line with an order of 0: `# This file is managed by Puppet. DO NOT EDIT.` Before 2.0.0, this parameter would add a newline at the end of the warn message. To improve flexibilty, this was removed. Please add it explicitly if you need it.



82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
# File 'vendor_modules/concat/manifests/init.pp', line 82

define concat (
  Enum['present', 'absent']          $ensure                  = 'present',
  Stdlib::Absolutepath               $path                    = $name,
  Optional[Variant[String, Integer]] $owner                   = undef,
  Optional[Variant[String, Integer]] $group                   = undef,
  String                             $mode                    = '0644',
  Variant[Boolean, String]           $warn                    = false,
  Boolean                            $show_diff               = true,
  Variant[Boolean, String]           $backup                  = 'puppet',
  Boolean                            $replace                 = true,
  Enum['alpha','numeric']            $order                   = 'alpha',
  Boolean                            $ensure_newline          = false,
  Optional[String]                   $validate_cmd            = undef,
  Optional[Boolean]                  $selinux_ignore_defaults = undef,
  Optional[String]                   $selrange                = undef,
  Optional[String]                   $selrole                 = undef,
  Optional[String]                   $seltype                 = undef,
  Optional[String]                   $seluser                 = undef,
  Optional[String]                   $format                  = 'plain',
  Optional[Boolean]                  $force                   = false,
) {
  $safe_name            = regsubst($name, '[\\\\/:~\n\s\+\*\(\)@]', '_', 'G')
  $default_warn_message = "# This file is managed by Puppet. DO NOT EDIT.\n"

  case $warn {
    true: {
      $warn_message = $default_warn_message
      $_append_header = true
    }
    false: {
      $warn_message = ''
      $_append_header = false
    }
    default: {
      $warn_message = $warn
      $_append_header = true
    }
  }

  if $ensure == 'present' {
    concat_file { $name:
      tag                     => $safe_name,
      path                    => $path,
      owner                   => $owner,
      group                   => $group,
      mode                    => $mode,
      selinux_ignore_defaults => $selinux_ignore_defaults,
      selrange                => $selrange,
      selrole                 => $selrole,
      seltype                 => $seltype,
      seluser                 => $seluser,
      replace                 => $replace,
      backup                  => $backup,
      show_diff               => $show_diff,
      order                   => $order,
      ensure_newline          => $ensure_newline,
      validate_cmd            => $validate_cmd,
      format                  => $format,
      force                   => $force,
    }

    if $_append_header {
      concat_fragment { "${name}_header":
        target  => $name,
        tag     => $safe_name,
        content => $warn_message,
        order   => '0',
      }
    }
  } else {
    concat_file { $name:
      ensure => $ensure,
      tag    => $safe_name,
      path   => $path,
      backup => $backup,
    }
  }
}