Defined Type: concat::fragment

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

Summary

Manages a fragment of text to be compiled into a file.

Overview

Parameters:

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

    Supplies the content of the fragment. Note: You must supply either a content parameter or a source parameter. Allows a String or a Deferred function which returns a String.

  • order (Variant[String, Integer]) (defaults to: '10')

    Reorders your fragments within the destination file. Fragments that share the same order number are ordered by name. The string option is recommended.

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

    Specifies a file to read into the content of the fragment. Note: You must supply either a content parameter or a source parameter. Valid options: a string or an array, containing one or more Puppet URLs.

  • target (String)

    Specifies the destination file of the fragment. Valid options: a string containing the path or title of the parent concat resource.



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
45
46
47
48
49
50
51
52
53
54
55
56
57
# File 'vendor_modules/concat/manifests/fragment.pp', line 19

define concat::fragment (
  String                             $target,
  Optional[Any]                      $content = undef,
  Optional[Variant[String, Array]]   $source  = undef,
  Variant[String, Integer]           $order   = '10',
) {
  $resource = 'Concat::Fragment'

  if ($order =~ String and $order =~ /[:\n\/]/) {
    fail("${resource}['${title}']: 'order' cannot contain '/', ':', or '\\n'.")
  }

  if ! ($content or $source) {
    crit('No content, source or symlink specified')
  } elsif ($content and $source) {
    fail("${resource}['${title}']: Can't use 'source' and 'content' at the same time.")
  }

  # $serverversion is empty on 'puppet apply' runs. Just use clientversion.
  $_serverversion    = getvar('serverversion') ? {
    undef   => $clientversion,
    default => $serverversion,
  }
  if versioncmp($clientversion, '6.0') >= 0 and versioncmp($_serverversion, '6.0') >= 0 {
    assert_type(Optional[Variant[String, Deferred]], $content)
  } else {
    assert_type(Optional[String], $content)
  }

  $safe_target_name = regsubst($target, '[\\\\/:~\n\s\+\*\(\)@]', '_', 'GM')

  concat_fragment { $name:
    target  => $target,
    tag     => $safe_target_name,
    order   => $order,
    content => $content,
    source  => $source,
  }
}