mkrakowitzer/puppet-deploy — pull request #14 by hamidnazari (2014-07-31 06:23:02+00:00)
Title: Added 'onlyif' and 'unless' parameters

I'm only proposing this fix I quickly put together as a solution to a problem I was facing. This is going to produce different behaviour as I have changed a default value. So, perhaps you would want to tweak it or rewrite it in a more backward-compatible way.

*The Problem*
The first `puppet apply` worked just fine, but the second run would fail as it tried to uncompress a file that didn't exist anymore. The archive file gets removed at the end of the first run, `file.pp:174 exec { "cleanup_${file}":`.

Then the second run would not download the package because of `file.pp:133 unless => "test -d ${target}",`. Clearly the `$target` now exists from the previous run. After this, the uncompression commands start failing.

*Easier Solution*
Make sure `untar` and `unzip` resources also check for existence of `$target` in their corresponding resource files.

*Better Solution*
Allow user to decide when the code should ignore the commands and when it should not. In my case, I needed the package redownloaded and reextracted.

*Another Possible Nicety*
Perhaps we can introduce a `cache` or `allow_redownload` parameter that check for or ignore existence of the archive file on the system.