-
Notifications
You must be signed in to change notification settings - Fork 55
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Make $pe_installer_source more flexible
This makes the peadm::install plan more flexible. Previously the variable $pe_installer_source could point to an absolute URL directly to the desired .tar.gz. Now it can also point to a web directory. Then peadm will calculate the .tar.gz name and fetch it from the web directory. This applies for the peadm::upgrade and peadm::install plan.
- Loading branch information
1 parent
68329f0
commit 1d2736f
Showing
7 changed files
with
168 additions
and
42 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
# | ||
# @summary calculates the PE installer URL and archive name | ||
# | ||
# @param pe_installer_source | ||
# The URL to download the Puppet Enterprise installer media from. If not | ||
# specified, PEAdm will attempt to download PE installation media from its | ||
# standard public source. When specified, PEAdm will download directly from the | ||
# URL given. Can be an URL, that ends with a /, to a web directory that | ||
# contains the original archives or an absolute URL to the .tar.gz archive. | ||
# | ||
# @param version | ||
# The desired version for PE. This is optional for custom provided absolute URLs. | ||
# | ||
# @param platform | ||
# The platform we're on, for example el-9-x86_64 (osfamily short name - version - arch) | ||
# | ||
# @author Tim Meusel <[email protected]> | ||
# | ||
function peadm::pe_installer_source ( | ||
Optional[Stdlib::HTTPSUrl] $pe_installer_source = undef, | ||
Optional[Peadm::Pe_version] $version = undef, | ||
Optional[String[1]] $platform = undef, | ||
) >> Hash[String[1],String[1]] { | ||
if $pe_installer_source { | ||
# custom URL ends with /, so we assume it's a webdir with the original installer | ||
if $pe_installer_source[-1] == '/' { | ||
assert_type(Peadm::Pe_version, $version) | ||
assert_type(String[1], $platform) | ||
$_version = $version | ||
$pe_tarball_name = "puppet-enterprise-${version}-${platform}.tar.gz" | ||
$pe_tarball_source = "${pe_installer_source}${pe_tarball_name}" | ||
} else { | ||
$pe_tarball_name = $pe_installer_source.split('/')[-1] | ||
$pe_tarball_source = $pe_installer_source | ||
$_version = $pe_tarball_name.split('-')[2] | ||
} | ||
$data = { 'url' => $pe_tarball_source, 'filename' => $pe_tarball_name, 'version' => pick($_version,$version), } | ||
} else { | ||
assert_type(Peadm::Pe_version, $version) | ||
assert_type(String[1], $platform) | ||
$pe_tarball_name = "puppet-enterprise-${version}-${platform}.tar.gz" | ||
$pe_tarball_source = "https://s3.amazonaws.com/pe-builds/released/${version}/${pe_tarball_name}" | ||
$data = { 'url' => $pe_tarball_source, 'filename' => $pe_tarball_name, 'version' => $version } | ||
} | ||
$data | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
# frozen_string_literal: true | ||
|
||
require 'spec_helper' | ||
|
||
describe 'peadm::pe_installer_source' do | ||
it 'exists' do | ||
is_expected.not_to be_nil | ||
end | ||
|
||
context 'when called with no parameters' do | ||
it { is_expected.to run.with_params.and_raise_error(Puppet::PreformattedError) } | ||
end | ||
context 'when called with absolute url and version' do | ||
result = { | ||
'url' => 'https://url/puppet-enterprise-2019.8.12-el-8-x86_64.tar.gz', | ||
'filename' => 'puppet-enterprise-2019.8.12-el-8-x86_64.tar.gz', | ||
'version' => '2019.8.12' | ||
} | ||
it { is_expected.to run.with_params('https://url/puppet-enterprise-2019.8.12-el-8-x86_64.tar.gz', '2019.8.12').and_return(result) } | ||
end | ||
context 'when called with absolute url' do | ||
result = { | ||
'url' => 'https://url/puppet-enterprise-2019.8.12-el-8-x86_64.tar.gz', | ||
'filename' => 'puppet-enterprise-2019.8.12-el-8-x86_64.tar.gz', | ||
'version' => '2019.8.12' | ||
} | ||
it { is_expected.to run.with_params('https://url/puppet-enterprise-2019.8.12-el-8-x86_64.tar.gz').and_return(result) } | ||
end | ||
context 'when called with url and version and platform' do | ||
result = { | ||
'url' => 'https://url/puppet-enterprise-2019.8.12-el-8-x86_64.tar.gz', | ||
'filename' => 'puppet-enterprise-2019.8.12-el-8-x86_64.tar.gz', | ||
'version' => '2019.8.12' | ||
} | ||
it { is_expected.to run.with_params('https://url/', '2019.8.12', 'el-8-x86_64').and_return(result) } | ||
end | ||
context 'when called without url and with version and platform' do | ||
result = { | ||
'url' => 'https://s3.amazonaws.com/pe-builds/released/2019.8.12/puppet-enterprise-2019.8.12-el-8-x86_64.tar.gz', | ||
'filename' => 'puppet-enterprise-2019.8.12-el-8-x86_64.tar.gz', | ||
'version' => '2019.8.12' | ||
} | ||
it do | ||
is_expected.to run.with_params(nil, '2019.8.12', 'el-8-x86_64').and_return(result) | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters