voxpupuli / puppet-staging

⛔️ Deprecated in favor of puppet-archive
https://forge.puppet.com/puppet/archive
Apache License 2.0
51 stars 109 forks source link

staging::file when specifying $target not behaving as documented #51

Closed michaelraz closed 9 years ago

michaelraz commented 9 years ago

Hi guys,

I tried to override the $target path for a call to staging::file. What I found was that nothing was happening until I specified the full path, including filename.

The documentation for staging::file indicates:

$target      = undef, #: the target staging directory, if unspecified ${staging::path}/${caller_module_name}

Looking at the source below from file.pp you can see if the $target is specified, $target_file is set to the submitted value which, in my case, is a folder. If $target is not specified, $target_file is set to ${staging_dir}/${name} (${name} would be the resource title here I would imagine?):

  if $target {
    $target_file = $target
    $staging_dir = staging_parse($target, 'parent')
  } else {
    $staging_dir = "${staging::path}/${subdir}"
    $target_file = "${staging_dir}/${name}"

    if ! defined(File[$staging_dir]) {
      file { $staging_dir:
        ensure=>directory,
      }
    }
  }

The reason nothing was happening (no file copy and no error) was due to your Idempotent check. I was creating the folder in another task. Your check would fire, checking if the "folder" existed, and move on.

Hope this makes sense,

Michael