Skip to content
This repository has been archived by the owner on May 5, 2023. It is now read-only.

Commit

Permalink
Merge c3018af into d11073b
Browse files Browse the repository at this point in the history
  • Loading branch information
FunFR committed Dec 19, 2017
2 parents d11073b + c3018af commit 3216bb4
Show file tree
Hide file tree
Showing 4 changed files with 67 additions and 1 deletion.
2 changes: 2 additions & 0 deletions manifests/deploy.pp
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
$password = undef, #: https or ftp user password or https certificate password
$environment = undef, #: environment variable for settings such as http_proxy
$strip = undef, #: extract file with the --strip=X option. Only works with GNU tar.
$use_7zip = false, #: alternative to unzip command on Windows
$unzip_opts = '', #: additional options to pass the unzip command.
$timeout = undef, #: the time to wait for the file transfer to complete
$user = undef, #: extract file as this user
Expand Down Expand Up @@ -48,6 +49,7 @@
group => $group,
environment => $environment,
strip => $strip,
use_7zip => $use_7zip,
unzip_opts => $unzip_opts,
subdir => $caller_module_name,
creates => $creates,
Expand Down
7 changes: 6 additions & 1 deletion manifests/extract.pp
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
$group = undef, #: extract file as this group.
$environment = undef, #: environment variables.
$strip = undef, #: extract file with the --strip=X option. Only works with GNU tar.
$use_7zip = false, #: alternative to unzip command on Windows
$unzip_opts = '', #: additional options to pass the unzip command.
$subdir = $caller_module_name #: subdir per module in staging directory.
) {
Expand Down Expand Up @@ -96,7 +97,11 @@
}

/.zip$/: {
$command = "unzip ${unzip_opts} ${source_path}"
if $use_7zip {
$command = "7z x ${source_path} ${unzip_opts}"
} else {
$command = "unzip ${unzip_opts} ${source_path}"
}
}

/(.war|.jar)$/: {
Expand Down
20 changes: 20 additions & 0 deletions spec/defines/staging_deploy_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -102,4 +102,24 @@
creates: '/usr/local/sample')
end
end

describe 'when deploying zip file with 7zip and unzip_opts' do
let(:title) { 'sample.zip' }
let(:params) do
{ source: 'puppet:///modules/staging/sample.zip',
target: '/usr/local',
use_7zip: true,
unzip_opts: '-r' }
end

it { is_expected.to compile.with_all_deps }
it { is_expected.to contain_file('/opt/staging') }
it { is_expected.to contain_file('/opt/staging/sample.zip') }
it do
is_expected.to contain_exec('extract sample.zip').with(command: '7z x /opt/staging/sample.zip -r',
path: '/usr/local/bin:/usr/bin:/bin',
cwd: '/usr/local',
creates: '/usr/local/sample')
end
end
end
39 changes: 39 additions & 0 deletions spec/defines/staging_extract_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,45 @@
end
end

describe 'when deploying zip with 7zip' do
let(:title) { 'sample.zip' }
let(:params) do
{
target: '/opt',
use_7zip: true
}
end

it { is_expected.to compile.with_all_deps }
it do
is_expected.to contain_file('/opt/staging')
is_expected.to contain_exec('extract sample.zip').with(command: '7z x /opt/staging/sample.zip ',
path: '/usr/local/bin:/usr/bin:/bin',
cwd: '/opt',
creates: '/opt/sample')
end
end

describe 'when deploying zip with 7zip and unzip_opts' do
let(:title) { 'sample.zip' }
let(:params) do
{
target: '/opt',
use_7zip: true,
unzip_opts: '-r'
}
end

it { is_expected.to compile.with_all_deps }
it do
is_expected.to contain_file('/opt/staging')
is_expected.to contain_exec('extract sample.zip').with(command: '7z x /opt/staging/sample.zip -r',
path: '/usr/local/bin:/usr/bin:/bin',
cwd: '/opt',
creates: '/opt/sample')
end
end

describe 'when deploying war' do
let(:title) { 'sample.war' }
let(:params) { { target: '/opt' } }
Expand Down

0 comments on commit 3216bb4

Please sign in to comment.