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