From 169e33289c1535e6df1f6a05e3696be845101b5f Mon Sep 17 00:00:00 2001 From: fred-vogt-dod Date: Wed, 12 Oct 2022 15:28:41 -0700 Subject: [PATCH] Use a 5.10 kernel version that supports live patching --- amazon-eks-al2.pkr.hcl | 7 +++++++ scripts/kernel.sh | 25 +++++++++++++++++++++++++ 2 files changed, 32 insertions(+) create mode 100755 scripts/kernel.sh diff --git a/amazon-eks-al2.pkr.hcl b/amazon-eks-al2.pkr.hcl index fc6dd8e..fd6f554 100644 --- a/amazon-eks-al2.pkr.hcl +++ b/amazon-eks-al2.pkr.hcl @@ -122,6 +122,13 @@ build { script = "scripts/update.sh" } + provisioner "shell" { + execute_command = "echo 'packer' | {{ .Vars }} sudo -S -E bash -eux '{{ .Path }}'" + expect_disconnect = true + pause_after = "15s" + script = "scripts/kernel.sh" + } + provisioner "shell" { execute_command = "echo 'packer' | {{ .Vars }} sudo -S -E bash -eux '{{ .Path }}'" environment_vars = [ diff --git a/scripts/kernel.sh b/scripts/kernel.sh new file mode 100755 index 0000000..6d87530 --- /dev/null +++ b/scripts/kernel.sh @@ -0,0 +1,25 @@ +#!/usr/bin/env bash + +set -o pipefail +set -o nounset +set -o errexit + +echo "linux kernel info" +uname -r +rpm -qa | grep kernel +amazon-linux-extras | grep kernel + +case $(uname -r) in + 5.10.*) + echo "already using a 5.10 kernel version" + ;; + *) + echo "use linux kernel 5.10" + amazon-linux-extras disable kernel-5.4 + amazon-linux-extras install kernel-5.10 -y + rpm -qa | grep kernel + + echo "rebooting the instance" + reboot + ;; +esac