From 682d3b8c760625bfb2409ac718f27e5cfa493eda Mon Sep 17 00:00:00 2001 From: Joshua Spence Date: Tue, 7 Apr 2015 21:56:45 +1000 Subject: [PATCH] Add support for `ensure => latest` Currently it is not possible to update the extracted tarball once it exists. Specifically, the following does not work: ``` s3file { '/tmp/my_archive.tar.gz': ensure => 'latest', bucket => 'my_s3_bucket', key => 'my_archive.tar.gz', notify => Archive::Extract['my_archive'], } archive::extract { 'my_archive': ensure => 'present', target => '/mnt/my_archive', src_target => '/tmp', } ``` This change allows `ensure => latest`, which removes the target directory and extracts the latest tarball. --- manifests/extract.pp | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/manifests/extract.pp b/manifests/extract.pp index 16a4888..50ee0ca 100644 --- a/manifests/extract.pp +++ b/manifests/extract.pp @@ -44,7 +44,7 @@ } case $ensure { - present: { + present, latest: { $extract_zip = "unzip -o ${src_target}/${name}.${extension} -d ${extract_dir}" $extract_tar = "tar --no-same-owner --no-same-permissions --strip-components=${strip_components} -xf ${src_target}/${name}.${extension} -C ${extract_dir}" @@ -65,6 +65,16 @@ fail("Unknown extension value '${extension}'") } + if $ensure == 'latest' { + exec { "Remove ${name}": + command => "rm -rf ${extract_dir}", + path => $exec_path, + timeout => $timeout, + refreshonly => true, + before => Exec["Unpack ${name}"] + } + } + exec {"Unpack ${name}": command => $unpack_command, path => $exec_path,