From d9a3ea3ce93f1a5ce1e50ff8c36dca0d4dcf9899 Mon Sep 17 00:00:00 2001 From: Tim Wright Date: Wed, 18 Dec 2024 02:55:01 +0000 Subject: [PATCH 1/3] change hard coded image versions to using the latest versions --- .../.vsts-vhd-builder-release-windows.yaml | 2 +- vhdbuilder/packer/init-variables.sh | 5 +-- ...windows-image.env => windows-image.env.sh} | 19 ++++------- .../scripts/windows/automate_version_bump.sh | 33 ++++++++++++------- 4 files changed, 31 insertions(+), 28 deletions(-) rename vhdbuilder/packer/{windows-image.env => windows-image.env.sh} (64%) diff --git a/.pipelines/.vsts-vhd-builder-release-windows.yaml b/.pipelines/.vsts-vhd-builder-release-windows.yaml index ab587f0e6e3..9b4266c20a3 100644 --- a/.pipelines/.vsts-vhd-builder-release-windows.yaml +++ b/.pipelines/.vsts-vhd-builder-release-windows.yaml @@ -19,7 +19,7 @@ pr: - vhdbuilder/packer/convert-sig-to-classic-storage-account-blob.sh - vhdbuilder/packer/generate-vhd-publishing-info.sh - vhdbuilder/packer/init-variables.sh - - vhdbuilder/packer/windows-image.env + - vhdbuilder/packer/windows-image.env.sh - vhdbuilder/packer/windows-vhd-builder-sig.json pool: diff --git a/vhdbuilder/packer/init-variables.sh b/vhdbuilder/packer/init-variables.sh index fb08106cf56..4ed313b7369 100755 --- a/vhdbuilder/packer/init-variables.sh +++ b/vhdbuilder/packer/init-variables.sh @@ -334,7 +334,8 @@ fi # shellcheck disable=SC2236 if [ "$OS_TYPE" == "Windows" ]; then imported_windows_image_name="" - source $CDIR/windows-image.env + + source $CDIR/windows-image.env.sh echo "Set the base image sku and version from windows-image.env" case "${WINDOWS_SKU}" in @@ -398,7 +399,7 @@ if [ "$OS_TYPE" == "Windows" ]; then ;; esac - # Create the sig image from the official images defined in windows-image.env by default + # Create the sig image from the official images defined in windows-image.env.sh by default windows_sigmode_source_subscription_id="" windows_sigmode_source_resource_group_name="" windows_sigmode_source_gallery_name="" diff --git a/vhdbuilder/packer/windows-image.env b/vhdbuilder/packer/windows-image.env.sh similarity index 64% rename from vhdbuilder/packer/windows-image.env rename to vhdbuilder/packer/windows-image.env.sh index bb78b508078..4f0c1b97e11 100644 --- a/vhdbuilder/packer/windows-image.env +++ b/vhdbuilder/packer/windows-image.env.sh @@ -7,31 +7,24 @@ WINDOWS_2019_BASE_IMAGE_SKU=2019-Datacenter-Core-smalldisk # TODO: update global:patch in generate-windows-vhd-configuration.ps1 and remove this comment when you bump 12B # - but revert and bring back if open ssh fails when you build the VHD. This image is 9B. WINDOWS_2019_BASE_IMAGE_VERSION=17763.6293.240905 +#WINDOWS_2019_BASE_IMAGE_VERSION=$(az vm image show --urn "MicrosoftWindowsServer:WindowsServer:${WINDOWS_2019_BASE_IMAGE_SKU}:latest" | jq -r .name) -# CLI example to get the latest image version: -# az vm image show --urn MicrosoftWindowsServer:WindowsServer:2022-Datacenter-Core-smalldisk:latest WINDOWS_2022_BASE_IMAGE_SKU=2022-Datacenter-Core-smalldisk -WINDOWS_2022_BASE_IMAGE_VERSION=20348.2966.241205 +WINDOWS_2022_BASE_IMAGE_VERSION=$(az vm image show --urn "MicrosoftWindowsServer:WindowsServer:${2022-Datacenter-Core-smalldisk}:latest" | jq -r .name) # CLI example to get all available image version under a SKU (suffix g2 for Gen 2): # az vm image list --all --publisher MicrosoftWindowsServer --offer WindowsServer --output table -s 2022-datacenter-core-smalldisk-g2 -# CLI example to get the latest image version: -# az vm image show --urn MicrosoftWindowsServer:WindowsServer:2022-datacenter-core-smalldisk-g2:latest + WINDOWS_2022_GEN2_BASE_IMAGE_SKU=2022-datacenter-core-smalldisk-g2 -WINDOWS_2022_GEN2_BASE_IMAGE_VERSION=20348.2966.241205 +WINDOWS_2022_GEN2_BASE_IMAGE_VERSION=$(az vm image show --urn "MicrosoftWindowsServer:WindowsServer:${WINDOWS_2022_GEN2_BASE_IMAGE_SKU}:latest" | jq -r .name) -# CLI example to get the latest image version: -# az vm image show --urn MicrosoftWindowsServer:WindowsServer:23h2-datacenter-core:latest WINDOWS_23H2_BASE_IMAGE_SKU=23h2-datacenter-core -WINDOWS_23H2_BASE_IMAGE_VERSION=25398.1308.241205 +WINDOWS_23H2_BASE_IMAGE_VERSION=$(az vm image show --urn "MicrosoftWindowsServer:${WINDOWS_23H2_BASE_IMAGE_SKU}:latest" | jq -r .name) # CLI example to get all available image version under a SKU (suffix g2 for Gen 2): # az vm image list --all --publisher MicrosoftWindowsServer --offer WindowsServer --output table -s 23h2-datacenter-core-g2 -# CLI example to get the latest image version: -# az vm image show --urn MicrosoftWindowsServer:WindowsServer:23h2-datacenter-core-g2:latest -# NOTE: Please update $global:patchUrls and $global:patchIDs in vhdbuilder/packer/generate-windows-vhd-configuration.ps1 on demand WINDOWS_23H2_GEN2_BASE_IMAGE_SKU=23h2-datacenter-core-g2 -WINDOWS_23H2_GEN2_BASE_IMAGE_VERSION=25398.1308.241205 +WINDOWS_23H2_GEN2_BASE_IMAGE_VERSION=$(az vm image show --urn "MicrosoftWindowsServer:WindowsServer:${WINDOWS_23H2_GEN2_BASE_IMAGE_SKU}:latest" | jq -r .name) # Please uncomment the following lines and set a larger os disk size that is at least 30GB when your PR check-in fails # WINDOWS_2019_CONTAINERD_OS_DISK_SIZE_GB=30 diff --git a/vhdbuilder/scripts/windows/automate_version_bump.sh b/vhdbuilder/scripts/windows/automate_version_bump.sh index 7a3eddf65a0..1f4f01e5bef 100644 --- a/vhdbuilder/scripts/windows/automate_version_bump.sh +++ b/vhdbuilder/scripts/windows/automate_version_bump.sh @@ -31,22 +31,31 @@ find_latest_image_version() { branch_name=imageBump/win-${new_image_version}b } -# This function replaces the old Windows 2019 & Windows 2022 (gen1/gen2) base image version with the latest version found by az vm image show in windows-image.env +# This function replaces the old Windows 2019 & Windows 2022 (gen1/gen2) base image version with the latest version found by az vm image show in windows-image.env.sh update_image_version() { - line=$(grep "WINDOWS_2019_BASE_IMAGE_VERSION=" vhdbuilder/packer/windows-image.env) - sed -i "s/$line/WINDOWS_2019_BASE_IMAGE_VERSION=$latest_image_version_2019/g" vhdbuilder/packer/windows-image.env - - line=$(grep "WINDOWS_2022_BASE_IMAGE_VERSION=" vhdbuilder/packer/windows-image.env) - sed -i "s/$line/WINDOWS_2022_BASE_IMAGE_VERSION=$latest_image_version_2022/g" vhdbuilder/packer/windows-image.env + line=$(grep "WINDOWS_2019_BASE_IMAGE_VERSION=" vhdbuilder/packer/windows-image.env.sh) + if [[ "$line" != *"az vm image show"* ]]; then + sed -i "s/$line/WINDOWS_2019_BASE_IMAGE_VERSION=$latest_image_version_2019/g" vhdbuilder/packer/windows-image.env.sh + fi - line=$(grep "WINDOWS_2022_GEN2_BASE_IMAGE_VERSION=" vhdbuilder/packer/windows-image.env) - sed -i "s/$line/WINDOWS_2022_GEN2_BASE_IMAGE_VERSION=$latest_image_version_2022_g2/g" vhdbuilder/packer/windows-image.env + line=$(grep "WINDOWS_2022_BASE_IMAGE_VERSION=" vhdbuilder/packer/windows-image.env.sh) + if [[ "$line" != *"az vm image show"* ]]; then + sed -i "s/$line/WINDOWS_2022_BASE_IMAGE_VERSION=$latest_image_version_2022/g" vhdbuilder/packer/windows-image.env.sh + fi + line=$(grep "WINDOWS_2022_GEN2_BASE_IMAGE_VERSION=" vhdbuilder/packer/windows-image.env.sh) + if [[ "$line" != *"az vm image show"* ]]; then + sed -i "s/$line/WINDOWS_2022_GEN2_BASE_IMAGE_VERSION=$latest_image_version_2022_g2/g" vhdbuilder/packer/windows-image.env.sh + fi - line=$(grep "WINDOWS_23H2_BASE_IMAGE_VERSION=" vhdbuilder/packer/windows-image.env) - sed -i "s/$line/WINDOWS_23H2_BASE_IMAGE_VERSION=$latest_image_version_23H2/g" vhdbuilder/packer/windows-image.env + line=$(grep "WINDOWS_23H2_BASE_IMAGE_VERSION=" vhdbuilder/packer/windows-image.env.sh) + if [[ "$line" != *"az vm image show"* ]]; then + sed -i "s/$line/WINDOWS_23H2_BASE_IMAGE_VERSION=$latest_image_version_23H2/g" vhdbuilder/packer/windows-image.env.sh + fi - line=$(grep "WINDOWS_23H2_GEN2_BASE_IMAGE_VERSION=" vhdbuilder/packer/windows-image.env) - sed -i "s/$line/WINDOWS_23H2_GEN2_BASE_IMAGE_VERSION=$latest_image_version_23H2_g2/g" vhdbuilder/packer/windows-image.env + line=$(grep "WINDOWS_23H2_GEN2_BASE_IMAGE_VERSION=" vhdbuilder/packer/windows-image.env.sh) + if [[ "$line" != *"az vm image show"* ]]; then + sed -i "s/$line/WINDOWS_23H2_GEN2_BASE_IMAGE_VERSION=$latest_image_version_23H2_g2/g" vhdbuilder/packer/windows-image.env.sh + fi } cherry_pick() { From c42577b8105fb9983348ff77ce2699e2c78d4fb1 Mon Sep 17 00:00:00 2001 From: Tim Wright Date: Wed, 18 Dec 2024 02:58:05 +0000 Subject: [PATCH 2/3] fix comment --- vhdbuilder/packer/init-variables.sh | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/vhdbuilder/packer/init-variables.sh b/vhdbuilder/packer/init-variables.sh index 4ed313b7369..3b8c1e11144 100755 --- a/vhdbuilder/packer/init-variables.sh +++ b/vhdbuilder/packer/init-variables.sh @@ -337,7 +337,7 @@ if [ "$OS_TYPE" == "Windows" ]; then source $CDIR/windows-image.env.sh - echo "Set the base image sku and version from windows-image.env" + echo "Set the base image sku and version from windows-image.env.sh" case "${WINDOWS_SKU}" in "2019") WINDOWS_IMAGE_SKU=$WINDOWS_2019_BASE_IMAGE_SKU @@ -346,7 +346,7 @@ if [ "$OS_TYPE" == "Windows" ]; then echo "Set OS disk size" if [ -n "${WINDOWS_2019_OS_DISK_SIZE_GB}" ]; then - echo "Setting os_disk_size_gb to the value in windows-image.env for 2019 Docker: ${WINDOWS_2019_OS_DISK_SIZE_GB}" + echo "Setting os_disk_size_gb to the value in windows-image.env.sh for 2019 Docker: ${WINDOWS_2019_OS_DISK_SIZE_GB}" os_disk_size_gb=${WINDOWS_2019_OS_DISK_SIZE_GB} fi ;; @@ -357,7 +357,7 @@ if [ "$OS_TYPE" == "Windows" ]; then echo "Set OS disk size" if [ -n "${WINDOWS_2019_CONTAINERD_OS_DISK_SIZE_GB}" ]; then - echo "Setting os_disk_size_gb to the value in windows-image.env for 2019 Containerd: ${WINDOWS_2019_CONTAINERD_OS_DISK_SIZE_GB}" + echo "Setting os_disk_size_gb to the value in windows-image.env.sh for 2019 Containerd: ${WINDOWS_2019_CONTAINERD_OS_DISK_SIZE_GB}" os_disk_size_gb=${WINDOWS_2019_CONTAINERD_OS_DISK_SIZE_GB} fi ;; From 3092486597abb6d1f10e486840b44c0d191cc910 Mon Sep 17 00:00:00 2001 From: Tim Wright Date: Wed, 18 Dec 2024 03:48:31 +0000 Subject: [PATCH 3/3] shellcheck fix --- vhdbuilder/packer/windows-image.env.sh | 2 ++ 1 file changed, 2 insertions(+) diff --git a/vhdbuilder/packer/windows-image.env.sh b/vhdbuilder/packer/windows-image.env.sh index 4f0c1b97e11..43795925df1 100644 --- a/vhdbuilder/packer/windows-image.env.sh +++ b/vhdbuilder/packer/windows-image.env.sh @@ -1,3 +1,5 @@ +# shellcheck shell=bash + # Windows base images for building VHD. To install Windows patches, please refer to configure-windows-vhd.ps1 # CLI example to get all available image version under a SKU: # az vm image list --all --publisher MicrosoftWindowsServer --offer WindowsServer --output table -s 2019-Datacenter-Core-smalldisk