- validate_string($target)
- validate_string($content)
- if !(is_string($source) or is_array($source)) {
- fail('$source is not a string or an Array.')
- }
- if !(is_string($order) or is_integer($order)) {
- fail('$order is not a string or integer.')
- } elsif (is_string($order) and $order =~ /[:\n\/]/) {
- fail("Order cannot contain '/', ':', or '\n'.")
- }
- if $mode {
- warning('The $mode parameter to concat::fragment is deprecated and has no effect')
- }
- if $owner {
- warning('The $owner parameter to concat::fragment is deprecated and has no effect')
- }
- if $group {
- warning('The $group parameter to concat::fragment is deprecated and has no effect')
- }
- if $backup {
- warning('The $backup parameter to concat::fragment is deprecated and has no effect')
- }
-
- $my_backup = concat_getparam(Concat[$target], 'backup')
- $_backup = $my_backup ? {
- '' => undef,
- default => $my_backup
- }
-
- if $ensure == undef {
- $my_ensure = concat_getparam(Concat[$target], 'ensure')
- } else {
- if ! ($ensure in [ 'present', 'absent' ]) {
- warning('Passing a value other than \'present\' or \'absent\' as the $ensure parameter to concat::fragment is deprecated. If you want to use the content of a file as a fragment please use the $source parameter.')
- }
- $my_ensure = $ensure
- }
-
- include concat::setup
-
- $safe_name = regsubst($name, '[/:\n]', '_', 'GM')
- $safe_target_name = regsubst($target, '[/:\n]', '_', 'GM')
- $concatdir = $concat::setup::concatdir
- $fragdir = "${concatdir}/${safe_target_name}"
- $fragowner = $concat::setup::fragment_owner
- $fraggroup = $concat::setup::fragment_group
- $fragmode = $concat::setup::fragment_mode
-
- # The file type's semantics are problematic in that ensure => present will
- # not over write a pre-existing symlink. We are attempting to provide
- # backwards compatiblity with previous concat::fragment versions that
- # supported the file type's ensure => /target syntax
-
- # be paranoid and only allow the fragment's file resource's ensure param to
- # be file, absent, or a file target
- $safe_ensure = $my_ensure ? {
- '' => 'file',
- undef => 'file',
- 'file' => 'file',
- 'present' => 'file',
- 'absent' => 'absent',
- default => $my_ensure,
- }