2 # Manages a fragment of text to be compiled into a file.
5 # Supplies the content of the fragment. Note: You must supply either a content parameter or a source parameter.
8 # Reorders your fragments within the destination file. Fragments that share the same order number are ordered by name. The string
9 # option is recommended.
12 # Specifies a file to read into the content of the fragment. Note: You must supply either a content parameter or a source parameter.
13 # Valid options: a string or an array, containing one or more Puppet URLs.
16 # Specifies the destination file of the fragment. Valid options: a string containing the path or title of the parent concat resource.
18 define concat::fragment(
20 Optional[String] $content = undef,
21 Optional[Variant[String, Array]] $source = undef,
22 Variant[String, Integer] $order = '10',
24 $resource = 'Concat::Fragment'
26 if ($order =~ String and $order =~ /[:\n\/]/) {
27 fail(translate("%{_resource}['%{_title}']: 'order' cannot contain '/', ':', or '\\n'.", {'_resource' => $resource, '_title' => $title}))
30 if ! ($content or $source) {
31 crit('No content, source or symlink specified')
32 } elsif ($content and $source) {
33 fail(translate("%{_resource}['%{_title}']: Can't use 'source' and 'content' at the same time.", {'_resource' => $resource, '_title' => $title}))
36 $safe_target_name = regsubst($target, '[\\\\/:~\n\s\+\*\(\)@]', '_', 'GM')
38 concat_fragment { $name:
40 tag => $safe_target_name,