voxpupuli / puppet-wget

A puppet recipe for wget, a useful tool to download arbitary files from the web
Apache License 2.0
41 stars 114 forks source link

wget idempotency issue on Windows #103

Open danielserrao opened 5 years ago

danielserrao commented 5 years ago

How to reproduce (e.g Puppet code you use)

wget::fetch { 'package.msi':
  source             => "https://api-host.com/packages/package.msi",
  destination        => "C:\\Program Files\\package.msi",
  user               => $api_user,
  password           => $api_password,
  nocheckcertificate => true,
}

What are you seeing

The resource is being executed on every puppet run even when the package.msi already is in the correct directory.

What behaviour did you expect instead

Only execute the resource when the package is not in the directory.

Any additional information you'd like to impart

In the wget module, this problem seems to be happening in the manifests/fetch.pp on the code:

if ($::operatingsystem == 'windows') {
  $exec_path = $::path
  $unless_test = "cmd.exe /c \"dir ${_destination}\""
} else {
...
}

Suggestion

The problem seems to be related to the path space, I think one possible solution could be something like:

 $unless_test = 'cmd /c IF exist "${_destination}" (exit 0) ELSE (exit 1)'

or simply allow the user to define is own unless command on Windows.