Skip to content

Commit eca9929

Browse files
committed
Add logic to pattch al2023 amis in ADC
1 parent b53aec2 commit eca9929

File tree

1 file changed

+26
-4
lines changed

1 file changed

+26
-4
lines changed

cookbooks/aws-parallelcluster-environment/templates/isolated/patch-iso-instance.sh.erb

Lines changed: 26 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,15 +19,35 @@ REGION="$(get_instance_region)"
1919

2020
source /etc/os-release
2121
OS="${ID}${VERSION_ID}"
22-
[[ "${OS}" != "amzn2" ]] && echo "[ERROR] Unsupported OS '${OS}'. Configuration supported only on Amazon Linux 2." && exit 1
22+
23+
if [[ "${OS}" != "amzn2" && "${OS}" != "amzn2023" ]]; then
24+
echo "[ERROR] Unsupported OS '${OS}'. Configuration supported only on Amazon Linux 2 and Amazon Linux 2023."
25+
exit 1
26+
fi
2327

2428
echo "[INFO] Starting: instance configuration for US isolated region"
2529

2630
echo "[INFO] Starting: installation of packages from amazon Linux 2 repository for US isolated region"
2731

28-
REPOSITORY_DEFINITION_FILE="/etc/yum.repos.d/tmp-amzn2-iso.repo"
32+
REPOSITORY_DEFINITION_FILE="/etc/yum.repos.d/tmp-${OS}-iso.repo"
33+
34+
if [[ "${OS}" == "amzn2023" ]]; then
35+
cat > ${REPOSITORY_DEFINITION_FILE} <<REPO_DEFINITION
36+
[amzn2023-iso]
37+
name=Amazon Linux 2023 isolated Region repository
38+
mirrorlist=http://al2023-repos-$awsregion-de612dc2.s3.$awsregion.$awsdomain/core-iso/mirrors/$releasever/$basearch/mirror.list
39+
priority=10
40+
enabled=1
41+
repo_gpgcheck=0
42+
type=rpm
43+
gpgcheck=0
44+
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-amazon-linux-2023
45+
REPO_DEFINITION
2946

30-
cat > ${REPOSITORY_DEFINITION_FILE} <<REPO_DEFINITION
47+
dnf install -y amazon-linux-repo-iso ca-certificates-iso
48+
echo -n "" > sudo tee /etc/dnf/vars/dualstack
49+
else
50+
cat > ${REPOSITORY_DEFINITION_FILE} <<REPO_DEFINITION
3151
[amzn2-iso]
3252
name=Amazon Linux 2 isolated region repository
3353
mirrorlist=http://amazonlinux.\$awsregion.\$awsdomain/\$releasever/core-\$awsregion/latest/\$basearch/mirror.list
@@ -39,7 +59,9 @@ mirrorlist_expire=300
3959
report_instanceid=yes
4060
REPO_DEFINITION
4161

42-
yum --disablerepo="*" --enablerepo="amzn2-iso" install -y "*-${REGION}"
62+
yum --disablerepo="*" --enablerepo="${OS}-iso" install -y "*-${REGION}"
63+
fi
64+
4365
rm -f ${REPOSITORY_DEFINITION_FILE}
4466

4567
echo "[INFO] Complete: installation of packages from amazon Linux 2 repository for US isolated region"

0 commit comments

Comments
 (0)