Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

(MODULES-8720) Update source calculation to prefer source user param #394

Merged
merged 2 commits into from
Mar 5, 2019
Merged
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
6 changes: 5 additions & 1 deletion manifests/osfamily/aix.pp
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,11 @@
$aix_ver_number = '6.1'
}
}
$source = "puppet:///pe_packages/${pe_server_version}/aix-${aix_ver_number}-power/${::puppet_agent::package_name}-${::puppet_agent::package_version}-1.aix${aix_ver_number}.ppc.rpm"
if $::puppet_agent::source {
$source = $::puppet_agent::source
} else {
$source = "puppet:///pe_packages/${pe_server_version}/aix-${aix_ver_number}-power/${::puppet_agent::package_name}-${::puppet_agent::package_version}-1.aix${aix_ver_number}.ppc.rpm"
}

class { '::puppet_agent::prepare::package':
source => $source,
Expand Down
4 changes: 3 additions & 1 deletion manifests/osfamily/darwin.pp
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
class puppet_agent::osfamily::darwin{
assert_private()

if $::puppet_agent::is_pe {
if $::puppet_agent::source {
$source = $::puppet_agent::source
} elsif $::puppet_agent::is_pe {
$pe_server_version = pe_build_version()
$source = "puppet:///pe_packages/${pe_server_version}/${::platform_tag}/${puppet_agent::package_name}-${puppet_agent::package_version}-1.osx${$::macosx_productversion_major}.dmg"
} else {
Expand Down
12 changes: 10 additions & 2 deletions manifests/osfamily/debian.pp
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,11 @@

if getvar('::puppet_agent::is_pe') == true {
$pe_server_version = pe_build_version()
$source = "https://${::servername}:8140/packages/${pe_server_version}/${::platform_tag}"
if $::puppet_agent::source {
$source = $::puppet_agent::source
} else {
$source = "https://${::servername}:8140/packages/${pe_server_version}/${::platform_tag}"
}
# In Puppet Enterprise, agent packages are served by the same server
# as the master, which can be using either a self signed CA, or an external CA.
# In order for apt to authenticate to the repo on the PE Master, it will need
Expand Down Expand Up @@ -55,7 +59,11 @@
content => '',
}
} else {
$source = 'https://apt.puppet.com'
if $::puppet_agent::source {
$source = $::puppet_agent::source
} else {
$source = 'https://apt.puppet.com'
}
}

$legacy_keyname = 'GPG-KEY-puppetlabs'
Expand Down
12 changes: 10 additions & 2 deletions manifests/osfamily/redhat.pp
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,11 @@
true => "el-6-${::architecture}",
default => $::platform_tag,
}
$source = "https://${::servername}:8140/packages/${pe_server_version}/${pe_repo_dir}"
if $::puppet_agent::source {
$source = $::puppet_agent::source
} else {
$source = "https://${::servername}:8140/packages/${pe_server_version}/${pe_repo_dir}"
}
# In Puppet Enterprise, agent packages are served by the same server
# as the master, which can be using either a self signed CA, or an external CA.
# In order for yum to authenticate to the yumrepo on the PE Master, it will need
Expand Down Expand Up @@ -39,7 +43,11 @@
$platform_and_version = "el/${::operatingsystemmajrelease}"
}
}
$source = "http://yum.puppet.com/${::puppet_agent::collection}/${platform_and_version}/${::puppet_agent::arch}"
if $::puppet_agent::source {
$source = $::puppet_agent::source
} else {
$source = "http://yum.puppet.com/${::puppet_agent::collection}/${platform_and_version}/${::puppet_agent::arch}"
}
$_sslcacert_path = undef
$_sslclientcert_path = undef
$_sslclientkey_path = undef
Expand Down
12 changes: 10 additions & 2 deletions manifests/osfamily/solaris.pp
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,11 @@
case $::operatingsystemmajrelease {
'10': {
$package_file_name = "${::puppet_agent::package_name}-${::puppet_agent::prepare::package_version}-1.${pkg_arch}.pkg.gz"
$source = "puppet:///pe_packages/${pe_server_version}/${::platform_tag}/${package_file_name}"
if $::puppet_agent::source {
$source = $::puppet_agent::source
} else {
$source = "puppet:///pe_packages/${pe_server_version}/${::platform_tag}/${package_file_name}"
}
class { '::puppet_agent::prepare::package':
source => $source,
}
Expand All @@ -44,7 +48,11 @@
'11': {
if $::puppet_agent::manage_repo {
$package_file_name = "${::puppet_agent::package_name}@${::puppet_agent::prepare::package_version},5.11-1.${pkg_arch}.p5p"
$source = "puppet:///pe_packages/${pe_server_version}/${::platform_tag}/${package_file_name}"
if $::puppet_agent::source {
$source = $::puppet_agent::source
} else {
$source = "puppet:///pe_packages/${pe_server_version}/${::platform_tag}/${package_file_name}"
}
class { '::puppet_agent::prepare::package':
source => $source,
}
Expand Down
4 changes: 3 additions & 1 deletion manifests/osfamily/suse.pp
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,9 @@
fail("${::operatingsystem} not supported")
}

if $::puppet_agent::is_pe {
if $::puppet_agent::source {
$source = $::puppet_agent::source
} elsif $::puppet_agent::is_pe {
$pe_server_version = pe_build_version()
$source = "https://${::servername}:8140/packages/${pe_server_version}/${::platform_tag}"
} else {
Expand Down
4 changes: 3 additions & 1 deletion manifests/osfamily/windows.pp
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
class puppet_agent::osfamily::windows{
assert_private()
if $::puppet_agent::is_pe {
if $::puppet_agent::source {
$source = $::puppet_agent::source
} elsif $::puppet_agent::is_pe {
$pe_server_version = pe_build_version()
$tag = $::puppet_agent::arch ? {
'x64' => 'windows-x86_64',
Expand Down
7 changes: 6 additions & 1 deletion manifests/prepare/package.pp
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,12 @@
ensure => directory,
}

$package_file_name = basename($source)
# In order for the 'basename' function to work correctly we need to change
# any \s to /s (even for windows UNC paths) so that it will correctly pull off
# the filename. Since this operation is only grabbing the base filename and not
# any part of the path this should be safe, since the source will simply remain
# what it was before and we can still pull off the filename.
$package_file_name = basename(regsubst($source, "\\\\", '/', 'G'))
if $::osfamily =~ /windows/ {
$local_package_file_path = windows_native_path("${::puppet_agent::params::local_packages_dir}/${package_file_name}")
$mode = undef
Expand Down
24 changes: 24 additions & 0 deletions spec/classes/puppet_agent_osfamily_aix_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,30 @@
}
end

context 'with a user specified source' do
let(:facts) {
common_facts.merge({
architecture: "PowerPC_POWER8",
platform_tag: "aix-7.2-power",
})
}
let(:params) {
{
package_version: '5.10.100.1',
collection: 'puppet5',
source: 'https://fake-source.com/aix/packages/puppet-agent-5.10.100.1-1.aix6.1.ppc.rpm',
}
}
before(:each) do
Puppet::Parser::Functions.newfunction(:pe_build_version, type: :rvalue) { |_args| '2000.0.0' }
Puppet::Parser::Functions.newfunction(:pe_compiling_server_aio_build, type: :rvalue) { |_args| '1.10.100' }
end

it {
is_expected.to contain_file('/opt/puppetlabs/packages/puppet-agent-5.10.100.1-1.aix6.1.ppc.rpm').with_source('https://fake-source.com/aix/packages/puppet-agent-5.10.100.1-1.aix6.1.ppc.rpm')
}
end

context 'with a PC1 collection' do
let(:params) {
{
Expand Down
21 changes: 20 additions & 1 deletion spec/classes/puppet_agent_osfamily_darwin_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
end

package_version = '1.10.100'
let(:params) {{ package_version: package_version }}

facts = {
:is_pe => true,
Expand All @@ -29,6 +28,7 @@
}

describe 'supported environment' do
let(:params) {{ package_version: package_version }}
context "when running a supported OSX" do
["osx-10.12-x86_64", "osx-10.13-x86_64", "osx-10.14-x86_64"].each do |tag|
context "on #{tag} with no aio_version" do
Expand Down Expand Up @@ -66,4 +66,23 @@
end
end
end

describe 'when using a user defined source' do
let(:params) {
{
package_version: '5.10.100.1',
collection: 'puppet5',
source: 'https://fake-source.com/aix/packages/puppet-agent-5.10.100.1-1.osx10.13.dmg',
}
}
let(:facts) do
facts.merge({
:is_pe => true,
:aio_agent_version => '1.10.99',
:platform_tag => 'osx-10.13-x86_64',
:macosx_productversion_major => '10.13'
})
end
it { is_expected.to contain_file("/opt/puppetlabs/packages/puppet-agent-5.10.100.1-1.osx10.13.dmg").with_source('https://fake-source.com/aix/packages/puppet-agent-5.10.100.1-1.osx10.13.dmg') }
end
end
39 changes: 39 additions & 0 deletions spec/classes/puppet_agent_osfamily_debian_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,25 @@
}) }
end

context "when managing PE apt repo settings and using a custom source" do
let(:params) {
{
:manage_repo => true,
:package_version => package_version,
:source => 'https://fake-apt-mirror.com/packages/debian-7-x86_64'
}
}

it { is_expected.to contain_apt__source('pc_repo').with({
'location' => 'https://fake-apt-mirror.com/packages/debian-7-x86_64',
'repos' => 'PC1',
'key' => {
'id' => '6F6B15509CF8E59E6E469F327F438280EF8D349F',
'source' => '/etc/pki/deb-gpg/GPG-KEY-puppet',
},
}) }
end

context "when not managing PE apt repo settings" do
let(:params) {
{
Expand Down Expand Up @@ -234,6 +253,26 @@
}) }
end

context "when managing FOSS apt repo and using a custom source" do
let(:params) {
{
:manage_repo => true,
:package_version => package_version,
:collection => 'puppet5',
:source => 'https://fake-apt-mirror.com/packages/debian-7-x86_64'
}
}

it { is_expected.to contain_apt__source('pc_repo').with({
'location' => 'https://fake-apt-mirror.com/packages/debian-7-x86_64',
'repos' => 'puppet5',
'key' => {
'id' => '6F6B15509CF8E59E6E469F327F438280EF8D349F',
'source' => '/etc/pki/deb-gpg/GPG-KEY-puppet',
},
}) }
end

context "when not managing FOSS apt repo" do
let(:params) {
{
Expand Down
23 changes: 23 additions & 0 deletions spec/classes/puppet_agent_osfamily_redhat_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,17 @@
'gpgkey' => "file:///etc/pki/rpm-gpg/RPM-GPG-KEY-puppetlabs\n file:///etc/pki/rpm-gpg/RPM-GPG-KEY-puppet",
}) }
end

context 'when using a custom source' do
let(:params) {
{
:package_version => '5.2.0',
:collection => 'puppet5',
:source => "http://fake-yum.com/#{urlbit.gsub('/f','/')}/x64"
}
}
it { is_expected.to contain_yumrepo('pc_repo').with_baseurl("http://fake-yum.com/#{urlbit.gsub('/f','/')}/x64") }
end
end
end

Expand All @@ -143,6 +154,18 @@
)
end

context 'when using a custom source' do
let(:params) {
{
:package_version => '5.2.0',
:manage_repo => true,
:source => "http://fake-yum.com/#{repodir}/x64"
}
}
it { is_expected.to contain_yumrepo('pc_repo').with_baseurl("http://fake-yum.com/#{repodir}/x64") }
end


context 'with manage_repo enabled' do
let(:params) {
{
Expand Down
44 changes: 44 additions & 0 deletions spec/classes/puppet_agent_osfamily_solaris_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,28 @@
pkg.stubs(:defaultprovider).returns(pkg.provider(:pkg))
end

context "when Solaris 11 i386 and a custom source" do
let(:facts) do
facts.merge({
:is_pe => true,
:platform_tag => "solaris-11-i386",
:operatingsystemmajrelease => '11',
})
end
let(:params) do
{
:package_version => package_version,
:source => "http://fake-solaris-source.com/packages/puppet-agent@#{sol11_package_version},5.11-1.i386.p5p"
}
end
it do
is_expected.to contain_file("/opt/puppetlabs/packages/puppet-agent@#{sol11_package_version},5.11-1.i386.p5p").with({
'ensure' => 'present',
'source' => "http://fake-solaris-source.com/packages/puppet-agent@#{sol11_package_version},5.11-1.i386.p5p",
})
end
end

context "when Solaris 11 i386" do
let(:facts) do
facts.merge({
Expand Down Expand Up @@ -176,6 +198,28 @@
end
end

context "when Solaris 10 i386 and a custom source" do
let(:facts) do
facts.merge({
:is_pe => true,
:platform_tag => "solaris-10-i386",
:operatingsystemmajrelease => '10',
})
end
let(:params) do
{
:package_version => package_version,
:source => "http://fake-solaris-source.com/packages/puppet-agent-#{package_version}-1.i386.pkg.gz"
}
end
it do
is_expected.to contain_file("/opt/puppetlabs/packages/puppet-agent-#{package_version}-1.i386.pkg.gz").with({
'ensure' => 'present',
'source' => "http://fake-solaris-source.com/packages/puppet-agent-#{package_version}-1.i386.pkg.gz",
})
end
end

context "when Solaris 10 i386" do
let(:facts) do
facts.merge({
Expand Down
16 changes: 16 additions & 0 deletions spec/classes/puppet_agent_osfamily_suse_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,22 @@
end
end

context "with manage_repo enabled and custom source" do
let(:params) {
{
:manage_repo => true,
:package_version => package_version,
:source => "https://fake-sles-source.com/packages/sles-#{os_version}-x86_64",
}
}
it { is_expected.to contain_ini_setting("zypper pc_repo baseurl").with({
'path' => '/etc/zypp/repos.d/pc_repo.repo',
'section' => 'pc_repo',
'setting' => 'baseurl',
'value' => "https://fake-sles-source.com/packages/sles-#{os_version}-x86_64?ssl_verify=no",
}) }
end

it do
is_expected.to contain_package('puppet-agent')
end
Expand Down
Loading