Skip to content

Commit

Permalink
(PE-37302) Update puppet_agent module for recent AIX changes in PE
Browse files Browse the repository at this point in the history
  • Loading branch information
amitkarsale committed Dec 14, 2023
1 parent 2920159 commit a13603f
Show file tree
Hide file tree
Showing 2 changed files with 62 additions and 5 deletions.
15 changes: 12 additions & 3 deletions manifests/osfamily/aix.pp
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,11 @@
# * AIX version 6.1 < aix-7.1-power package
# * AIX version 7.1 < aix-7.1-power package
# * AIX version 7.2 < aix-7.1-power package
# * AIX version 7.3 < aix-7.1-power package
#
# puppet 8:
# * AIX version 7.2 < aix-7.2-power package
# * AIX version 7.3 < aix-7.2-power package
#
# All other versions will now _only_ use the aix-7.1-power packages (i.e. we now only ship
# one package to support all aix versions).
Expand All @@ -41,21 +43,28 @@
$aix_ver_number = '7.1'
} else {
# 6.19.1 is the last puppet6 release that ships AIX 6.1 packages

$aix_ver_number = versioncmp($puppet_agent::prepare::package_version, '6.19.1') ? {
1 => '7.1',
default => '6.1'
}
}
}

$aix_class_name = if (versioncmp($pe_server_version, '2021.7.7') < 0) or (versioncmp($pe_server_version, '2023.0') >= 0 and versioncmp($pe_server_version, '2023.6') < 0) {
"aix-${aix_ver_number}-power"
} else {
'aix-power'
}

if $puppet_agent::absolute_source {
$source = $puppet_agent::absolute_source
} elsif $puppet_agent::alternate_pe_source {
$source = "${puppet_agent::alternate_pe_source}/packages/${pe_server_version}/aix-${aix_ver_number}-power/${puppet_agent::package_name}-${puppet_agent::prepare::package_version}-1.aix${aix_ver_number}.ppc.rpm"
$source = "${puppet_agent::alternate_pe_source}/packages/${pe_server_version}/${aix_class_name}/${puppet_agent::package_name}-${puppet_agent::prepare::package_version}-1.aix${aix_ver_number}.ppc.rpm"
} elsif $puppet_agent::source {
$source = "${puppet_agent::source}/packages/${pe_server_version}/aix-${aix_ver_number}-power/${puppet_agent::package_name}-${puppet_agent::prepare::package_version}-1.aix${aix_ver_number}.ppc.rpm"
$source = "${puppet_agent::source}/packages/${pe_server_version}/${aix_class_name}/${puppet_agent::package_name}-${puppet_agent::prepare::package_version}-1.aix${aix_ver_number}.ppc.rpm"
} else {
$source = "${puppet_agent::aix_source}/${pe_server_version}/aix-${aix_ver_number}-power/${puppet_agent::package_name}-${puppet_agent::prepare::package_version}-1.aix${aix_ver_number}.ppc.rpm"
$source = "${puppet_agent::aix_source}/${pe_server_version}/${aix_class_name}/${puppet_agent::package_name}-${puppet_agent::prepare::package_version}-1.aix${aix_ver_number}.ppc.rpm"
}

class { 'puppet_agent::prepare::package':
Expand Down
52 changes: 50 additions & 2 deletions spec/classes/puppet_agent_osfamily_aix_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,30 @@
end

context 'with a user specified source' do
let(:facts) do
common_facts.merge({
architecture: 'PowerPC_POWER8',
platform_tag: 'aix-6.1-power',
})
end
let(:params) do
{
package_version: '6.10.100.1',
collection: 'puppet6',
source: 'https://fake-pe-master.com',
}
end

before(:each) do
Puppet::Parser::Functions.newfunction(:pe_build_version, type: :rvalue) { |_args| '2000.0.0' }
end

it {
is_expected.to contain_file('/opt/puppetlabs/packages/puppet-agent-6.10.100.1-1.aix6.1.ppc.rpm').with_source('https://fake-pe-master.com/packages/2000.0.0/aix-6.1-power/puppet-agent-6.10.100.1-1.aix6.1.ppc.rpm')
}
end

context 'with a user specified source for puppet 7' do
let(:facts) do
common_facts.merge({
architecture: 'PowerPC_POWER8',
Expand All @@ -72,11 +96,35 @@
end

before(:each) do
Puppet::Parser::Functions.newfunction(:pe_build_version, type: :rvalue) { |_args| '2000.0.0' }
Puppet::Parser::Functions.newfunction(:pe_build_version, type: :rvalue) { |_args| '2021.7.7' }
end

it {
is_expected.to contain_file('/opt/puppetlabs/packages/puppet-agent-7.10.100.1-1.aix7.1.ppc.rpm').with_source('https://fake-pe-master.com/packages/2021.7.7/aix-power/puppet-agent-7.10.100.1-1.aix7.1.ppc.rpm')
}
end

context 'with a user specified source for puppet 8' do
let(:facts) do
common_facts.merge({
architecture: 'PowerPC_POWER8',
platform_tag: 'aix-7.2-power',
})
end
let(:params) do
{
package_version: '8.10.100.1',
collection: 'puppet8',
source: 'https://fake-pe-master.com',
}
end

before(:each) do
Puppet::Parser::Functions.newfunction(:pe_build_version, type: :rvalue) { |_args| '2023.6.0' }
end

it {
is_expected.to contain_file('/opt/puppetlabs/packages/puppet-agent-7.10.100.1-1.aix7.1.ppc.rpm').with_source('https://fake-pe-master.com/packages/2000.0.0/aix-7.1-power/puppet-agent-7.10.100.1-1.aix7.1.ppc.rpm')
is_expected.to contain_file('/opt/puppetlabs/packages/puppet-agent-8.10.100.1-1.aix7.2.ppc.rpm').with_source('https://fake-pe-master.com/packages/2023.6.0/aix-power/puppet-agent-8.10.100.1-1.aix7.2.ppc.rpm')
}
end

Expand Down

0 comments on commit a13603f

Please sign in to comment.