diff --git a/util/manifests/init.pp b/util/manifests/init.pp index 7c3ed40..4a9ca2b 100644 --- a/util/manifests/init.pp +++ b/util/manifests/init.pp @@ -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})\"", }