Merged in oherrala/puppet (pull request #26)
Add support to extract only specified pattern of files from tar archive.
This commit is contained in:
commit
be7b1ecafe
1 changed files with 7 additions and 3 deletions
|
@ -14,6 +14,10 @@
|
||||||
# $preserve:
|
# $preserve:
|
||||||
# Preserve owner and permissions. Defaults to false.
|
# Preserve owner and permissions. Defaults to false.
|
||||||
#
|
#
|
||||||
|
# $pattern:
|
||||||
|
# The pathnames or shell-style globbing patterns indicate which
|
||||||
|
# items in the archive should be processed.
|
||||||
|
#
|
||||||
# === Sample usage
|
# === Sample usage
|
||||||
#
|
#
|
||||||
#util::extract::tar { "/usr/local/src/moin-1.8.8":
|
#util::extract::tar { "/usr/local/src/moin-1.8.8":
|
||||||
|
@ -21,7 +25,7 @@
|
||||||
# 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, $ensure=present, $strip=0, $preserve=false) {
|
define util::extract::tar($source, $ensure=present, $strip=0, $preserve=false, $pattern="") {
|
||||||
|
|
||||||
include gnu::tar
|
include gnu::tar
|
||||||
|
|
||||||
|
@ -59,9 +63,9 @@ define util::extract::tar($source, $ensure=present, $strip=0, $preserve=false) {
|
||||||
}
|
}
|
||||||
|
|
||||||
if $preserve {
|
if $preserve {
|
||||||
$command = "/bin/sh -c 'umask 022; ${cat} ${source} | ${tar} xf - --strip-components=${strip} -C ${name}'"
|
$command = "/bin/sh -c 'umask 022; ${cat} ${source} | ${tar} xf - --strip-components=${strip} -C ${name} ${pattern}'"
|
||||||
} else {
|
} else {
|
||||||
$command = "/bin/sh -c 'umask 022; ${cat} ${source} | ${tar} xf - --strip-components=${strip} -C ${name} --no-same-owner --no-same-permissions'"
|
$command = "/bin/sh -c 'umask 022; ${cat} ${source} | ${tar} xf - --strip-components=${strip} -C ${name} ${pattern} --no-same-owner --no-same-permissions'"
|
||||||
}
|
}
|
||||||
|
|
||||||
exec { "tar-extract-${name}":
|
exec { "tar-extract-${name}":
|
||||||
|
|
Loading…
Add table
Reference in a new issue