From 7f46eb7a7f55d6af40598f3b6d68719b82f230fa Mon Sep 17 00:00:00 2001 From: Helena Greebe Date: Fri, 13 Dec 2024 13:25:34 -0500 Subject: [PATCH] Lock kernel minor version during image build --- .../imagebuilder/update_and_reboot.yaml | 26 ++++++++++++++++--- 1 file changed, 23 insertions(+), 3 deletions(-) diff --git a/cli/src/pcluster/resources/imagebuilder/update_and_reboot.yaml b/cli/src/pcluster/resources/imagebuilder/update_and_reboot.yaml index c5e1a43e80..8da21b6b6b 100644 --- a/cli/src/pcluster/resources/imagebuilder/update_and_reboot.yaml +++ b/cli/src/pcluster/resources/imagebuilder/update_and_reboot.yaml @@ -57,6 +57,21 @@ phases: fi echo ${!OS} + - name: OperatingSystemVersion + action: ExecuteBash + inputs: + commands: + - | + set -v + FILE=/etc/os-release + if [ -e ${!FILE} ]; then + . ${!FILE} + echo "${!VERSION_ID}" + else + echo "The file '${!FILE}' does not exist. Failing build." + exit {{ FailExitCode }} + fi + # Get platform name - name: PlatformName @@ -151,6 +166,11 @@ phases: set -v OS='{{ build.OperatingSystemName.outputs.stdout }}' PLATFORM='{{ build.PlatformName.outputs.stdout }}' + VERSION='{{ build.OperatingSystemVersion.outputs.stdout }}' + if [[ ${!OS} == rhel9 ]]; then + echo ${!VERSION} > /etc/yum/vars/releasever + yum clean all + fi if [[ ${!PLATFORM} == RHEL ]]; then yum -y install jq @@ -192,7 +212,7 @@ phases: set -v OS='{{ build.OperatingSystemName.outputs.stdout }}' PLATFORM='{{ build.PlatformName.outputs.stdout }}' - DISABLE_KERNEL_UPDATE='{{ build.DisableKernelUpdate.outputs.stdout }}' + DISABLE_KERNEL_UPDATE='true' if [[ ${!DISABLE_KERNEL_UPDATE} == true ]]; then if [[ ${!PLATFORM} == RHEL ]]; then @@ -223,9 +243,9 @@ phases: set -v OS='{{ build.OperatingSystemName.outputs.stdout }}' PLATFORM='{{ build.PlatformName.outputs.stdout }}' - DISABLE_KERNEL_UPDATE='{{ build.DisableKernelUpdate.outputs.stdout }}' + DISABLE_KERNEL_UPDATE='true' - if [[ ${!PLATFORM} == RHEL ]]; then + if [[ ${!PLATFORM} == RHEL ]] && [[ ${!DISABLE_KERNEL_UPDATE} == true ]]; then yum -y update if [[ ${!OS} == "rhel8" ]] || [[ ${!OS} == "rocky8" ]] || [[ ${!OS} == "rhel9" ]] || [[ ${!OS} == "rocky9" ]] || [[ ${!OS} == "alinux2023" ]] ; then