diff --git a/cli/src/pcluster/resources/imagebuilder/update_and_reboot.yaml b/cli/src/pcluster/resources/imagebuilder/update_and_reboot.yaml index 0adb04e831..70f61c99f0 100644 --- a/cli/src/pcluster/resources/imagebuilder/update_and_reboot.yaml +++ b/cli/src/pcluster/resources/imagebuilder/update_and_reboot.yaml @@ -206,7 +206,7 @@ phases: fi if [[ ${!OS} == "rocky8" ]] ; then - yum versionlock rocky-release + yum versionlock rocky-release rocky-repos elif [[ ${!OS} == "rhel8" ]] ; then yum versionlock redhat-release fi @@ -234,7 +234,6 @@ phases: set -v OS='{{ build.OperatingSystemName.outputs.stdout }}' PLATFORM='{{ build.PlatformName.outputs.stdout }}' - DISABLE_KERNEL_UPDATE='{{ build.DisableKernelUpdate.outputs.stdout }}' if [[ ${!PLATFORM} == RHEL ]]; then yum -y update @@ -256,15 +255,44 @@ phases: else package-cleanup -y --oldkernels --count=1 fi - # Install kernel-devel during OS update, so that headers are aligned with new kernel. - # The same is done for Debian through `apt-get -y install linux-aws` - yum -y install kernel-devel elif [[ ${!PLATFORM} == DEBIAN ]]; then DEBIAN_FRONTEND=noninteractive apt-get -y update DEBIAN_FRONTEND=noninteractive apt-get -y -o Dpkg::Options::="--force-confdef" -o Dpkg::Options::="--force-confold" --with-new-pkgs upgrade apt-get --purge autoremove -y + fi + + - name: InstallAdditionalKernelPackages + action: ExecuteBash + inputs: + commands: + - | + set -v + OS='{{ build.OperatingSystemName.outputs.stdout }}' + PLATFORM='{{ build.PlatformName.outputs.stdout }}' + DISABLE_KERNEL_UPDATE='{{ build.DisableKernelUpdate.outputs.stdout }}' + if [[ ${!PLATFORM} == RHEL ]]; then + # Install kernel-devel during OS update, so that headers are aligned with new kernel. + # The same is done for Debian through `apt-get -y install linux-aws` + if [[ ${!OS} == "rocky8" ]]; then + PACKAGE="kernel-devel-$(uname -r)" + RELEASE_VERSION=$(source /etc/os-release && echo ${!VERSION_ID}) + + # try to install kernel source for a specific release version + yum install -y ${!PACKAGE} --releasever ${!RELEASE_VERSION} + if [ $? -ne 0 ]; then + yum install -y wget + # Previous releases are moved into a vault area once a new minor release version is available for at least a week. + # https://wiki.rockylinux.org/rocky/repo/#notes-on-devel + wget https://dl.rockylinux.org/vault/rocky/${!RELEASE_VERSION}/BaseOS/$(uname -m)/os/Packages/k/${!PACKAGE}.rpm + yum install -y ./${!PACKAGE}.rpm + fi + else + yum -y install kernel-devel + fi + + elif [[ ${!PLATFORM} == DEBIAN ]]; then if [[ ${!DISABLE_KERNEL_UPDATE} != true ]]; then # already installed to LTS version apt-get -y install linux-aws linux-headers-aws linux-image-aws