Added support for "ensure => latest" to util::extract::tar
This commit is contained in:
parent
edebb3dda3
commit
33be443516
1 changed files with 17 additions and 3 deletions
|
@ -4,6 +4,8 @@
|
|||
#
|
||||
# $name:
|
||||
# Destination directory.
|
||||
# $ensure:
|
||||
# If 'latest', remove target and re-extract when source file changes.
|
||||
# $source:
|
||||
# File to extract.
|
||||
# $strip:
|
||||
|
@ -19,7 +21,19 @@
|
|||
# source => "/usr/local/src/moin-1.8.8.tar.gz",
|
||||
#}
|
||||
#
|
||||
define util::extract::tar($source, $strip=0, $preserve=false) {
|
||||
define util::extract::tar($source, $ensure=present, $strip=0, $preserve=false) {
|
||||
|
||||
case $ensure {
|
||||
latest: {
|
||||
exec { "tar-rmdir-${name}":
|
||||
path => "/bin:/usr/bin:/sbin:/usr/sbin",
|
||||
command => "rm -fr ${name}",
|
||||
before => File["${name}"],
|
||||
subscribe => File["${source}"],
|
||||
refreshonly => true,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
file { "${name}":
|
||||
ensure => directory,
|
||||
|
@ -40,10 +54,10 @@ define util::extract::tar($source, $strip=0, $preserve=false) {
|
|||
$command = "${cat} ${source} | tar xf - --strip-components=${strip} -C ${name} --no-same-owner --no-same-permissions"
|
||||
}
|
||||
|
||||
exec { "extract-tar-${name}":
|
||||
exec { "tar-extract-${name}":
|
||||
path => "/bin:/usr/bin:/sbin:/usr/sbin",
|
||||
command => $command,
|
||||
require => [ File["${name}"], ],
|
||||
require => File["${name}"],
|
||||
unless => "test -n \"$(ls -A ${name})\"",
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue