Skip to content
This repository was archived by the owner on Jan 8, 2020. It is now read-only.
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 10 additions & 3 deletions manifests/extract.pp
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@
$strip_components=0,
$purge=false,
$user=undef,
$same_permissions=false,
) {

if $root_dir {
Expand All @@ -49,13 +50,19 @@
$extract_dir = "${target}/${name}"
}

if $same_permissions {
$_same_permissions="--same-permissions"
} else {
$_same_permissions="--no-same-permissions"
}

case $ensure {
'present': {

$extract_zip = "unzip -o ${src_target}/${name}.${extension} -d ${target}"
$extract_targz = "tar --no-same-owner --no-same-permissions --strip-components=${strip_components} -xzf ${src_target}/${name}.${extension} -C ${target}"
$extract_tarbz2 = "tar --no-same-owner --no-same-permissions --strip-components=${strip_components} -xjf ${src_target}/${name}.${extension} -C ${target}"
$extract_tarxz = "tar --no-same-owner --no-same-permissions --strip-components=${strip_components} -xpf ${src_target}/${name}.${extension} -C ${target}"
$extract_targz = "tar --no-same-owner ${_same_permissions} --strip-components=${strip_components} -xzf ${src_target}/${name}.${extension} -C ${target}"
$extract_tarbz2 = "tar --no-same-owner ${_same_permissions} --strip-components=${strip_components} -xjf ${src_target}/${name}.${extension} -C ${target}"
$extract_tarxz = "tar --no-same-owner ${_same_permissions} --strip-components=${strip_components} -xpf ${src_target}/${name}.${extension} -C ${target}"

$purge_command = $purge ? {
true => "rm -rf ${target} && ",
Expand Down
3 changes: 3 additions & 0 deletions manifests/init.pp
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
# - *$strip_components: Default value 0
# - *$proxy_server: Default value undef
# - *$user: User used to do the download and the extraction. The final directory will be used by him/her.
# - *$same_permissions: Use permissions from tar archive instead of local umask.
#
# Example usage:
#
Expand Down Expand Up @@ -49,6 +50,7 @@
$proxy_server=undef,
$purge_target=false,
$user=undef,
$same_permissions=false,
) {

archive::download {"${name}.${extension}":
Expand Down Expand Up @@ -78,5 +80,6 @@
strip_components => $strip_components,
require => Archive::Download["${name}.${extension}"],
user => $user,
same_permissions => $same_permissions,
}
}
15 changes: 14 additions & 1 deletion spec/defines/archive_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
:target => '/opt',
}
end

it { expect { is_expected.to compile.with_all_deps }.to raise_error(/Must pass url/) }
end

Expand Down Expand Up @@ -67,6 +67,19 @@

it { is_expected.to compile.with_all_deps }
end

context 'with url, target and same_permissions' do
let(:params) do
{
:url => 'http://archive.apache.org/dist/tomcat/tomcat-6/v6.0.26/bin/apache-tomcat-6.0.26.tar.gz',
:target => '/opt',
:same_permissions => true,
}
end

it { is_expected.to compile.with_all_deps }
end

end
end
end