@@ -19,15 +19,41 @@ REGION="$(get_instance_region)"
1919
2020source /etc/os-release
2121OS=" ${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
2428echo " [INFO] Starting: instance configuration for US isolated region"
2529
2630echo " [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+ echo " sslverify=0" >> /etc/dnf/dnf.conf
48+ echo -n " " | sudo tee /etc/dnf/vars/dualstack
49+ if [[ ${REGION} == us-isob* ]]; then
50+ dnf install -y amazon-linux-repo-iso ca-certificates-isob
51+ else
52+ dnf install -y amazon-linux-repo-iso ca-certificates-iso
53+ fi
54+ sed -i " s/sslverify=0//g" /etc/dnf/dnf.conf
55+ else
56+ cat > ${REPOSITORY_DEFINITION_FILE} << REPO_DEFINITION
3157[amzn2-iso]
3258name=Amazon Linux 2 isolated region repository
3359mirrorlist=http://amazonlinux.\$ awsregion.\$ awsdomain/\$ releasever/core-\$ awsregion/latest/\$ basearch/mirror.list
@@ -39,30 +65,35 @@ mirrorlist_expire=300
3965report_instanceid=yes
4066REPO_DEFINITION
4167
42- yum --disablerepo=" *" --enablerepo=" amzn2-iso" install -y " *-${REGION} "
68+ yum --disablerepo=" *" --enablerepo=" ${OS} -iso" install -y " *-${REGION} "
69+ fi
70+
4371rm -f ${REPOSITORY_DEFINITION_FILE}
4472
45- echo " [INFO] Complete: installation of packages from amazon Linux 2 repository for US isolated region"
73+ echo " [INFO] Complete: installation of packages from ${OS} repository for US isolated region"
4674
4775echo " [INFO] Starting: CA bundle configuration for AWS CLI in US isolated region"
4876
49- USERS=(< %= @users %> )
5077CA_BUNDLE=" /etc/pki/${REGION} /certs/ca-bundle.pem"
5178
52- for user in " ${USERS[@]} " ; do
53- echo " [INFO] Setting CA bundle ${CA_BUNDLE} for user ${user} "
54- sudo mkhomedir_helper $user
55- sudo -u $user aws configure set ca_bundle " $CA_BUNDLE "
56- done
79+ sudo aws configure set ca_bundle " $CA_BUNDLE "
5780
5881echo " [INFO] Complete: CA bundle configuration for AWS CLI in US isolated region"
5982
6083echo " [INFO] Starting: Setting system-wide environment variables for AWS CLI in US isolated region"
6184
85+ echo " export AWS_CA_BUNDLE=/etc/pki/${REGION} /certs/ca-bundle.pem" >> /etc/profile.d/aws-cli-default-config.sh
86+
6287echo " export AWS_DEFAULT_REGION=${REGION} " >> /etc/profile.d/aws-cli-default-config.sh
6388
64- echo " Defaults env_keep += \" AWS_DEFAULT_REGION AWS_CA_BUNDLE\" " > /etc/sudoers .d/pcluster- aws-cli-envkeep
89+ echo " export REQUESTS_CA_BUNDLE= ${ AWS_CA_BUNDLE} " >> /etc/profile .d/aws-cli-default-config.sh
6590
66- echo " [INFO] Complete: Setting system-wide environment variables for AWS CLI in US isolated region"
91+ echo " export SSL_CERT_FILE=${AWS_CA_BUNDLE} " >> /etc/profile.d/aws-cli-default-config.sh
92+
93+ echo " Defaults env_keep += \" AWS_DEFAULT_REGION AWS_CA_BUNDLE REQUESTS_CA_BUNDLE SSL_CERT_FILE\" " > /etc/sudoers.d/pcluster-aws-cli-envkeep
6794
68- echo " [INFO] Complete: instance configuration for US isolated region"
95+ source /etc/profile.d/aws-cli-default-config.sh
96+
97+ sudo aws configure set ca_bundle " $CA_BUNDLE "
98+
99+ echo " [INFO] Complete: Setting system-wide environment variables for AWS CLI in US isolated region"
0 commit comments