Skip to content

Commit 75d15a6

Browse files
authored
Merge pull request #724 from puppetlabs/amazon-2-aarch64
(PA-6677) Restore AL2 x86_64 install task and manifest
2 parents 5f9362a + 3f9ea74 commit 75d15a6

File tree

4 files changed

+39
-27
lines changed

4 files changed

+39
-27
lines changed

manifests/osfamily/redhat.pp

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,11 @@
1919
}
2020
'Amazon': {
2121
$major_version = $facts['os']['release']['major']
22-
$amz_el_version = "${major_version}" ? {
23-
/^(2017|2018)$/ => '6',
22+
$arch = $facts['os']['architecture']
23+
$amz_el_version = "${major_version}-${arch}" ? {
24+
'2-aarch64' => '2',
25+
'2-x86_64' => '7',
26+
/^(2017|2018)-/ => '6',
2427
default => $major_version,
2528
}
2629

@@ -36,10 +39,16 @@
3639
# lint:endignore
3740
if ($puppet_agent::is_pe and (!$puppet_agent::use_alternate_sources)) {
3841
$pe_server_version = pe_build_version()
39-
# Treat Amazon Linux just like Enterprise Linux
40-
$pe_repo_dir = ($facts['os']['name'] == 'Amazon') ? {
41-
true => "el-${amz_el_version}-${facts['os']['architecture']}",
42-
default => $facts['platform_tag'],
42+
# Install amazon packages on AL2 (only aarch64) and 2023 and up (all arch)
43+
if $facts['os']['name'] == 'Amazon' {
44+
# lint:ignore:only_variable_string
45+
$pe_repo_dir = "${amz_el_version}" ? {
46+
/^(6|7)$/ => "el-${amz_el_version}-${facts['os']['architecture']}",
47+
default => $facts['platform_tag'],
48+
}
49+
# lint:endignore
50+
} else {
51+
$pe_repo_dir = $facts['platform_tag']
4352
}
4453
if $puppet_agent::source {
4554
$source = "${puppet_agent::source}/packages/${pe_server_version}/${pe_repo_dir}"

metadata.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,9 @@
6767
},
6868
{
6969
"operatingsystem": "Rocky"
70+
},
71+
{
72+
"operatingsystem": "AmazonLinux"
7073
}
7174
],
7275
"requirements": [

spec/classes/puppet_agent_osfamily_redhat_spec.rb

Lines changed: 16 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -22,19 +22,21 @@
2222
end
2323

2424
[
25-
['Rocky', 'el/8', 8],
26-
['AlmaLinux', 'el/8', 8],
27-
['AlmaLinux', 'el/9', 9],
28-
['Fedora', 'fedora/f36', 36],
29-
['CentOS', 'el/7', 7],
30-
['Amazon', 'el/6', 2017],
31-
['Amazon', 'el/6', 2018],
32-
['Amazon', 'amazon/2', 2],
33-
['Amazon', 'amazon/2023', 2023],
34-
].each do |os, urlbit, osmajor|
25+
['Rocky', 'el/8', '8', 'x86_64'],
26+
['AlmaLinux', 'el/8', '8', 'x86_64'],
27+
['AlmaLinux', 'el/9', '9', 'x86_64'],
28+
['Fedora', 'fedora/f36', '36', 'x86_64'],
29+
['CentOS', 'el/7', '7', 'x86_64'],
30+
['Amazon', 'el/6', '2017', 'x86_64'],
31+
['Amazon', 'el/6', '2018', 'x86_64'],
32+
['Amazon', 'el/7', '2', 'x86_64'],
33+
['Amazon', 'amazon/2', '2', 'aarch64'],
34+
['Amazon', 'amazon/2023', '2023', 'x86_64'],
35+
['Amazon', 'amazon/2023', '2023', 'aarch64'],
36+
].each do |os, urlbit, osmajor, arch|
3537
context "with #{os} and #{urlbit}" do
3638
let(:facts) do
37-
override_facts(super(), os: { name: os, release: { major: osmajor, }, })
39+
override_facts(super(), os: { name: os, release: { major: osmajor }, architecture: arch })
3840
end
3941

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

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

173-
[['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|
175+
[['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|
174176
context "when PE on #{os}" do
175177
before(:each) do
176178
# Need to mock the PE functions

tasks/install_shell.sh

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -284,11 +284,6 @@ case $platform in
284284
"SLES")
285285
platform_version=$major_version
286286
;;
287-
"Amzn"|"Amazon Linux")
288-
case $platform_version in
289-
"2") platform_version="2";;
290-
esac
291-
;;
292287
esac
293288

294289
# Find which version of puppet is currently installed if any
@@ -662,8 +657,11 @@ case $platform in
662657
info "Amazon platform! Lets get you an RPM..."
663658
filetype="rpm"
664659
platform_package="el"
665-
# For Amazon Linux 2023 and onwards we can use the 'amazon' packages created instead of 'el' packages
666-
if (( $platform_version == 2023 || $platform_version == 2 )); then
660+
arch="$(uname -p)"
661+
# Install amazon packages on AL2 (only aarch64) and 2003 and up (all arch)
662+
if [[ $platform_version == 2 && $arch == 'x86_64' ]]; then
663+
platform_version="7"
664+
elif (( platform_version == 2 || platform_version >= 2023 )); then
667665
platform_package="amazon"
668666
fi
669667
filename="${collection}-release-${platform_package}-${platform_version}.noarch.rpm"

0 commit comments

Comments
 (0)