Added option to preserve permissions to util::extract::tar
This commit is contained in:
parent
c2e18283a8
commit
f64c9540ca
1 changed files with 10 additions and 2 deletions
|
@ -9,6 +9,8 @@
|
|||
# $strip:
|
||||
# Remove the specified number of leading path elements.
|
||||
# Defaults to 0.
|
||||
# $preserve:
|
||||
# Preserve owner and permissions. Defaults to false.
|
||||
#
|
||||
# === Sample usage
|
||||
#
|
||||
|
@ -17,7 +19,7 @@
|
|||
# source => "/usr/local/src/moin-1.8.8.tar.gz",
|
||||
#}
|
||||
#
|
||||
define util::extract::tar($source, $strip=0) {
|
||||
define util::extract::tar($source, $strip=0, $preserve=false) {
|
||||
|
||||
file { "${name}":
|
||||
ensure => directory,
|
||||
|
@ -32,9 +34,15 @@ define util::extract::tar($source, $strip=0) {
|
|||
bz2, tbz: { $cat = "bzcat" }
|
||||
}
|
||||
|
||||
if $preserve {
|
||||
$command = "${cat} ${source} | tar xf - --strip-components=${strip} -C ${name}"
|
||||
} else {
|
||||
$command = "${cat} ${source} | tar xf - --strip-components=${strip} -C ${name} --no-same-owner --no-same-permissions"
|
||||
}
|
||||
|
||||
exec { "extract-tar-${name}":
|
||||
path => "/bin:/usr/bin:/sbin:/usr/sbin",
|
||||
command => "${cat} ${source} | tar xf - --strip-components=${strip} -C ${name}",
|
||||
command => $command,
|
||||
require => [ File["${name}"], ],
|
||||
unless => "test -n \"$(ls -A ${name})\"",
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue