Skip to content

Commit a6d66c9

Browse files
committed
Add parameter "tag" to concat
allow a user defined tag or list of tags for fragments to build the concat_file out of
1 parent a2d61e1 commit a6d66c9

File tree

1 file changed

+12
-2
lines changed

1 file changed

+12
-2
lines changed

manifests/init.pp

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,9 @@
8282
# @param create_empty_file
8383
# Specifies whether to create an empty file if no fragments are defined. Defaults to true.
8484
#
85+
# @param tag
86+
# Specifies a custom tag or list of custom tags for gatherinng the fragments to combine.
87+
#
8588
define concat (
8689
Enum['present', 'absent'] $ensure = 'present',
8790
Stdlib::Absolutepath $path = $name,
@@ -103,6 +106,7 @@
103106
Boolean $force = false,
104107
Boolean $create_empty_file = true,
105108
Enum['plain', 'yaml', 'json', 'json-array', 'json-pretty', 'json-array-pretty'] $format = 'plain',
109+
Optional[Variant[String[1], Array[String[1], 1]]] $tag = undef,
106110
) {
107111
$safe_name = regsubst($name, '[\\\\/:~\n\s\+\*\(\)@]', '_', 'G')
108112
$default_warn_message = "# This file is managed by Puppet. DO NOT EDIT.\n"
@@ -122,9 +126,15 @@
122126
}
123127
}
124128

129+
if $tag =~ Undef {
130+
$safe_names = $safe_name
131+
} else {
132+
$safe_names = flatten($safe_name, $tag)
133+
}
134+
125135
if $ensure == 'present' {
126136
concat_file { $name:
127-
tag => $safe_name,
137+
tag => $safe_names,
128138
path => $path,
129139
owner => $owner,
130140
group => $group,
@@ -156,7 +166,7 @@
156166
} else {
157167
concat_file { $name:
158168
ensure => $ensure,
159-
tag => $safe_name,
169+
tag => $safe_names,
160170
path => $path,
161171
backup => $backup,
162172
}

0 commit comments

Comments
 (0)