2 # Manages a file, compiled from one or more text fragments.
5 # concat { '/tmp/concat':
13 # Specifies whether (and how) to back up the destination file before overwriting it. Your value gets passed on to Puppet's native file
14 # resource for execution. Valid options: true, false, or a string representing either a target filebucket or a filename extension
18 # Specifies whether the destination file should exist. Setting to 'absent' tells Puppet to delete the destination file if it exists, and
19 # negates the effect of any other parameters.
21 # @param ensure_newline
22 # Specifies whether to add a line break at the end of each fragment that doesn't already end in one.
25 # Specify what data type to merge the fragments as. Valid options: 'plain', 'yaml', 'json', 'json-array', 'json-pretty',
26 # 'json-array-pretty'.
29 # Specifies whether to merge data structures, keeping the values with higher order. Used when format is specified as a value other than
33 # Specifies a permissions group for the destination file. Valid options: a string containing a group name or integer containing a gid.
36 # Specifies the permissions mode of the destination file. Valid options: a string containing a permission mode value in octal notation.
39 # Specifies a method for sorting your fragments by name within the destination file. You can override this setting for individual
40 # fragments by adjusting the order parameter in their concat::fragment declarations.
43 # Specifies the owner of the destination file. Valid options: a string containing a username or integer containing a uid.
46 # Specifies a destination file for the combined fragments.
49 # Specifies whether to overwrite the destination file if it already exists.
51 # @param selinux_ignore_defaults
52 # See the file type's selinux_ignore_defaults documentention:
53 # https://docs.puppetlabs.com/references/latest/type.html#file-attribute-selinux_ignore_defaults
56 # See the file type's selrange documentention: https://docs.puppetlabs.com/references/latest/type.html#file-attribute-selrange
59 # See the file type's selrole documentention: https://docs.puppetlabs.com/references/latest/type.html#file-attribute-selrole
62 # See the file type's seltype documentention: https://docs.puppetlabs.com/references/latest/type.html#file-attribute-seltype
65 # See the file type's seluser documentention: https://docs.puppetlabs.com/references/latest/type.html#file-attribute-seluser
68 # Specifies whether to set the show_diff parameter for the file resource. Useful for hiding secrets stored in hiera from insecure
72 # Specifies a validation command to apply to the destination file.
75 # Specifies whether to add a header message at the top of the destination file. Valid options: the booleans true and false, or a string
76 # to serve as the header.
77 # If you set 'warn' to true, concat adds the following line with an order of 0:
78 # `# This file is managed by Puppet. DO NOT EDIT.`
79 # 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
80 # it explicitly if you need it.
83 Enum['present', 'absent'] $ensure = 'present',
84 Stdlib::Absolutepath $path = $name,
85 Optional[Variant[String, Integer]] $owner = undef,
86 Optional[Variant[String, Integer]] $group = undef,
87 String $mode = '0644',
88 Variant[Boolean, String] $warn = false,
89 Boolean $show_diff = true,
90 Variant[Boolean, String] $backup = 'puppet',
91 Boolean $replace = true,
92 Enum['alpha','numeric'] $order = 'alpha',
93 Boolean $ensure_newline = false,
94 Optional[String] $validate_cmd = undef,
95 Optional[Boolean] $selinux_ignore_defaults = undef,
96 Optional[String] $selrange = undef,
97 Optional[String] $selrole = undef,
98 Optional[String] $seltype = undef,
99 Optional[String] $seluser = undef,
100 Optional[String] $format = 'plain',
101 Optional[Boolean] $force = false,
104 $safe_name = regsubst($name, '[\\\\/:~\n\s\+\*\(\)@]', '_', 'G')
105 $default_warn_message = "# This file is managed by Puppet. DO NOT EDIT.\n"
109 $warn_message = $default_warn_message
110 $_append_header = true
114 $_append_header = false
117 $warn_message = $warn
118 $_append_header = true
122 if $ensure == 'present' {
129 selinux_ignore_defaults => $selinux_ignore_defaults,
130 selrange => $selrange,
136 show_diff => $show_diff,
138 ensure_newline => $ensure_newline,
139 validate_cmd => $validate_cmd,
145 concat_fragment { "${name}_header":
148 content => $warn_message,