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:
|
# $name:
|
||||||
# Destination directory.
|
# Destination directory.
|
||||||
|
# $ensure:
|
||||||
|
# If 'latest', remove target and re-extract when source file changes.
|
||||||
# $source:
|
# $source:
|
||||||
# File to extract.
|
# File to extract.
|
||||||
# $strip:
|
# $strip:
|
||||||
|
@ -19,7 +21,19 @@
|
||||||
# source => "/usr/local/src/moin-1.8.8.tar.gz",
|
# 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}":
|
file { "${name}":
|
||||||
ensure => directory,
|
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"
|
$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",
|
path => "/bin:/usr/bin:/sbin:/usr/sbin",
|
||||||
command => $command,
|
command => $command,
|
||||||
require => [ File["${name}"], ],
|
require => File["${name}"],
|
||||||
unless => "test -n \"$(ls -A ${name})\"",
|
unless => "test -n \"$(ls -A ${name})\"",
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue