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

(PA-6677) Restore AL2 x86_64 install task and manifest #724

Merged
merged 4 commits into from
Jun 27, 2024
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
21 changes: 15 additions & 6 deletions manifests/osfamily/redhat.pp
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,11 @@
}
'Amazon': {
$major_version = $facts['os']['release']['major']
$amz_el_version = "${major_version}" ? {
/^(2017|2018)$/ => '6',
$arch = $facts['os']['architecture']
$amz_el_version = "${major_version}-${arch}" ? {
'2-aarch64' => '2',
'2-x86_64' => '7',
/^(2017|2018)-/ => '6',
default => $major_version,
}

Expand All @@ -36,10 +39,16 @@
# lint:endignore
if ($puppet_agent::is_pe and (!$puppet_agent::use_alternate_sources)) {
$pe_server_version = pe_build_version()
# Treat Amazon Linux just like Enterprise Linux
$pe_repo_dir = ($facts['os']['name'] == 'Amazon') ? {
true => "el-${amz_el_version}-${facts['os']['architecture']}",
default => $facts['platform_tag'],
# Install amazon packages on AL2 (only aarch64) and 2023 and up (all arch)
if $facts['os']['name'] == 'Amazon' {
# lint:ignore:only_variable_string
$pe_repo_dir = "${amz_el_version}" ? {
/^(6|7)$/ => "el-${amz_el_version}-${facts['os']['architecture']}",
default => $facts['platform_tag'],
}
# lint:endignore
} else {
$pe_repo_dir = $facts['platform_tag']
}
if $puppet_agent::source {
$source = "${puppet_agent::source}/packages/${pe_server_version}/${pe_repo_dir}"
Expand Down
3 changes: 3 additions & 0 deletions metadata.json
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,9 @@
},
{
"operatingsystem": "Rocky"
},
{
"operatingsystem": "AmazonLinux"
}
],
"requirements": [
Expand Down
30 changes: 16 additions & 14 deletions spec/classes/puppet_agent_osfamily_redhat_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -22,19 +22,21 @@
end

[
['Rocky', 'el/8', 8],
['AlmaLinux', 'el/8', 8],
['AlmaLinux', 'el/9', 9],
['Fedora', 'fedora/f36', 36],
['CentOS', 'el/7', 7],
['Amazon', 'el/6', 2017],
['Amazon', 'el/6', 2018],
['Amazon', 'amazon/2', 2],
['Amazon', 'amazon/2023', 2023],
].each do |os, urlbit, osmajor|
['Rocky', 'el/8', '8', 'x86_64'],
['AlmaLinux', 'el/8', '8', 'x86_64'],
['AlmaLinux', 'el/9', '9', 'x86_64'],
['Fedora', 'fedora/f36', '36', 'x86_64'],
['CentOS', 'el/7', '7', 'x86_64'],
['Amazon', 'el/6', '2017', 'x86_64'],
['Amazon', 'el/6', '2018', 'x86_64'],
['Amazon', 'el/7', '2', 'x86_64'],
['Amazon', 'amazon/2', '2', 'aarch64'],
['Amazon', 'amazon/2023', '2023', 'x86_64'],
['Amazon', 'amazon/2023', '2023', 'aarch64'],
].each do |os, urlbit, osmajor, arch|
joshcooper marked this conversation as resolved.
Show resolved Hide resolved
context "with #{os} and #{urlbit}" do
let(:facts) do
override_facts(super(), os: { name: os, release: { major: osmajor, }, })
override_facts(super(), os: { name: os, release: { major: osmajor }, architecture: arch })
end

script = <<-SCRIPT
Expand Down Expand Up @@ -148,7 +150,7 @@
is_expected.to contain_yumrepo('pc_repo')
.with({
# We no longer expect the 'f' in fedora repos
'baseurl' => "http://yum.puppet.com/puppet5/#{urlbit.gsub('/f', '/')}/x64",
'baseurl' => "http://yum.puppet.com/puppet5/#{urlbit.gsub('/f', '/')}/#{arch}",
'enabled' => 'true',
'gpgcheck' => '1',
'gpgkey' => "file:///etc/pki/rpm-gpg/RPM-GPG-KEY-puppet\n file:///etc/pki/rpm-gpg/RPM-GPG-KEY-puppet-20250406",
Expand All @@ -165,12 +167,12 @@
}
end

it { is_expected.to contain_yumrepo('pc_repo').with_baseurl("http://fake-yum.com/puppet5/#{urlbit.gsub('/f', '/')}/x64") }
it { is_expected.to contain_yumrepo('pc_repo').with_baseurl("http://fake-yum.com/puppet5/#{urlbit.gsub('/f', '/')}/#{arch}") }
end
end
end

[['RedHat', 'el-7-x86_64', 'el-7-x86_64', 7], ['RedHat', 'el-8-x86_64', 'el-8-x86_64', 8], ['Amazon', '', 'el-6-x64', 6]].each do |os, tag, repodir, osmajor|
[['RedHat', 'el-7-x86_64', 'el-7-x86_64', '7'], ['RedHat', 'el-8-x86_64', 'el-8-x86_64', '8'], ['Amazon', '', 'el-6-x64', '6']].each do |os, tag, repodir, osmajor|
context "when PE on #{os}" do
before(:each) do
# Need to mock the PE functions
Expand Down
12 changes: 5 additions & 7 deletions tasks/install_shell.sh
Original file line number Diff line number Diff line change
Expand Up @@ -284,11 +284,6 @@ case $platform in
"SLES")
platform_version=$major_version
;;
"Amzn"|"Amazon Linux")
case $platform_version in
"2") platform_version="2";;
esac
;;
esac

# Find which version of puppet is currently installed if any
Expand Down Expand Up @@ -662,8 +657,11 @@ case $platform in
info "Amazon platform! Lets get you an RPM..."
filetype="rpm"
platform_package="el"
# For Amazon Linux 2023 and onwards we can use the 'amazon' packages created instead of 'el' packages
if (( $platform_version == 2023 || $platform_version == 2 )); then
arch="$(uname -p)"
# Install amazon packages on AL2 (only aarch64) and 2003 and up (all arch)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit, but this says 2003 instead of 2023.

if [[ $platform_version == 2 && $arch == 'x86_64' ]]; then
platform_version="7"
elif (( platform_version == 2 || platform_version >= 2023 )); then
platform_package="amazon"
fi
filename="${collection}-release-${platform_package}-${platform_version}.noarch.rpm"
Expand Down
Loading