From a53becd540b4a2c91089e3c42694dfd665932d92 Mon Sep 17 00:00:00 2001 From: smerle33 Date: Thu, 10 Oct 2024 10:42:34 +0200 Subject: [PATCH 1/7] fix(windows2019/openssh): try to force image version from base to previous one --- build-jenkins-agent-windows.pkr.hcl | 2 ++ 1 file changed, 2 insertions(+) diff --git a/build-jenkins-agent-windows.pkr.hcl b/build-jenkins-agent-windows.pkr.hcl index 894c845a3..fe7de095e 100644 --- a/build-jenkins-agent-windows.pkr.hcl +++ b/build-jenkins-agent-windows.pkr.hcl @@ -7,6 +7,8 @@ build { image_publisher = "MicrosoftWindowsServer" # List available SKUs with the command `az vm image list-skus --offer WindowsServer --location eastus --publisher MicrosoftWindowsServer --output table` image_sku = "${var.agent_os_version}-datacenter-core-g2" + # List available images `az vm image list --location eastus --publisher MicrosoftWindowsServer --offer WindowsServer --sku 2019-datacenter-core-g2 --all --output table` + image_version = "17763.6293.240905" os_type = "Windows" os_disk_size_gb = local.windows_disk_size_gb winrm_insecure = true From 111c6f8e9aabcf97c6df2c8020da48b5ff125900 Mon Sep 17 00:00:00 2001 From: smerle33 Date: Thu, 10 Oct 2024 11:39:13 +0200 Subject: [PATCH 2/7] simplify to only windows 2019 for now --- Jenkinsfile_k8s | 39 ++++++++++++++++++++------------------- 1 file changed, 20 insertions(+), 19 deletions(-) diff --git a/Jenkinsfile_k8s b/Jenkinsfile_k8s index d591160de..58f99d402 100644 --- a/Jenkinsfile_k8s +++ b/Jenkinsfile_k8s @@ -74,22 +74,22 @@ pipeline { } } } - stage('GC on Azure') { - environment { - PACKER_AZURE = credentials('packer-azure-serviceprincipal-sponsorship') - } - steps { - catchError(buildResult: 'SUCCESS', stageResult: 'FAILURE') { - sh 'az login --service-principal -u "$PACKER_AZURE_CLIENT_ID" -p "$PACKER_AZURE_CLIENT_SECRET" -t "$PACKER_AZURE_TENANT_ID"' - sh 'az account set -s "$PACKER_AZURE_SUBSCRIPTION_ID"' - sh './cleanup/azure_gallery_images.sh 1 dev' - sh './cleanup/azure_gallery_images.sh 7 staging' - sh './cleanup/azure.sh 1 dev' - sh './cleanup/azure.sh 1 staging' - sh './cleanup/azure.sh 1 prod' - } - } - } + // stage('GC on Azure') { + // environment { + // PACKER_AZURE = credentials('packer-azure-serviceprincipal-sponsorship') + // } + // steps { + // catchError(buildResult: 'SUCCESS', stageResult: 'FAILURE') { + // sh 'az login --service-principal -u "$PACKER_AZURE_CLIENT_ID" -p "$PACKER_AZURE_CLIENT_SECRET" -t "$PACKER_AZURE_TENANT_ID"' + // sh 'az account set -s "$PACKER_AZURE_SUBSCRIPTION_ID"' + // sh './cleanup/azure_gallery_images.sh 1 dev' + // sh './cleanup/azure_gallery_images.sh 7 staging' + // sh './cleanup/azure.sh 1 dev' + // sh './cleanup/azure.sh 1 staging' + // sh './cleanup/azure.sh 1 prod' + // } + // } + // } } } stage('Packer Images') { @@ -97,17 +97,18 @@ pipeline { axes { axis { name 'cpu_architecture' - values 'amd64', 'arm64' + values 'amd64'//, 'arm64' } axis { name 'agent_type' // make sure to port any addition to the list of agent types to the Build Docker Manifest stage if it's docker related - values 'ubuntu-22.04', 'windows-2019', 'windows-2022' + //values 'ubuntu-22.04', 'windows-2019', 'windows-2022' + values 'windows-2019' } axis { name 'compute_type' // "azure-arm" stands for "Azure Resource Manager", unrelated to arm64 CPU - values 'azure-arm', 'docker' + values 'azure-arm', //'docker' } } excludes { From e8755036a346759e9bd0f95d22c8357c16821f00 Mon Sep 17 00:00:00 2001 From: smerle33 Date: Thu, 10 Oct 2024 11:41:52 +0200 Subject: [PATCH 3/7] chore coma --- Jenkinsfile_k8s | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Jenkinsfile_k8s b/Jenkinsfile_k8s index 58f99d402..681c054d6 100644 --- a/Jenkinsfile_k8s +++ b/Jenkinsfile_k8s @@ -108,7 +108,7 @@ pipeline { axis { name 'compute_type' // "azure-arm" stands for "Azure Resource Manager", unrelated to arm64 CPU - values 'azure-arm', //'docker' + values 'azure-arm' //'docker' } } excludes { From d6b59ae6909d2d13b3d27068e380ddc78fdced4b Mon Sep 17 00:00:00 2001 From: smerle33 Date: Thu, 10 Oct 2024 14:48:31 +0200 Subject: [PATCH 4/7] fix the image version for windows 2019 AND 2022 --- Jenkinsfile_k8s | 2 +- build-jenkins-agent-windows.pkr.hcl | 3 ++- locals.pkr.hcl | 7 +++++++ 3 files changed, 10 insertions(+), 2 deletions(-) diff --git a/Jenkinsfile_k8s b/Jenkinsfile_k8s index 681c054d6..b52765da8 100644 --- a/Jenkinsfile_k8s +++ b/Jenkinsfile_k8s @@ -103,7 +103,7 @@ pipeline { name 'agent_type' // make sure to port any addition to the list of agent types to the Build Docker Manifest stage if it's docker related //values 'ubuntu-22.04', 'windows-2019', 'windows-2022' - values 'windows-2019' + values 'windows-2019', 'windows-2022' } axis { name 'compute_type' diff --git a/build-jenkins-agent-windows.pkr.hcl b/build-jenkins-agent-windows.pkr.hcl index fe7de095e..5a22fb362 100644 --- a/build-jenkins-agent-windows.pkr.hcl +++ b/build-jenkins-agent-windows.pkr.hcl @@ -8,7 +8,8 @@ build { # List available SKUs with the command `az vm image list-skus --offer WindowsServer --location eastus --publisher MicrosoftWindowsServer --output table` image_sku = "${var.agent_os_version}-datacenter-core-g2" # List available images `az vm image list --location eastus --publisher MicrosoftWindowsServer --offer WindowsServer --sku 2019-datacenter-core-g2 --all --output table` - image_version = "17763.6293.240905" + # List available images `az vm image list --location eastus --publisher MicrosoftWindowsServer --offer WindowsServer --sku 2022-datacenter-core-g2 --all --output table` + image_version = local.windows_image_version[var.agent_os_version] os_type = "Windows" os_disk_size_gb = local.windows_disk_size_gb winrm_insecure = true diff --git a/locals.pkr.hcl b/locals.pkr.hcl index 9701f5474..c7aecb0b0 100644 --- a/locals.pkr.hcl +++ b/locals.pkr.hcl @@ -13,6 +13,13 @@ locals { "azure-arm" = "packer" "docker" = "packer" } + + # List available images `az vm image list --location eastus --publisher MicrosoftWindowsServer --offer WindowsServer --sku 2022-datacenter-core-g2 --all --output table` + windows_image_version= { + "2019" = "17763.6293.240905" + "2022" = "20348.2762.241006" + } + azure_vm_size = { "amd64" = "Standard_D4ads_v5" # 4 CPU / 16 GB / Huge size required to avoid https:#docs.microsoft.com/en-us/azure/virtual-machines/linux/image-builder-troubleshoot#sysprep-timing and avoid full disk (DS2v2 only have 14 Gb SSD for system) "arm64" = "Standard_D4pds_v5" # 4 CPU / 16 GB From 0a5684d628cc1fd81d61f45e249c9f2fb0bc8a3d Mon Sep 17 00:00:00 2001 From: smerle33 Date: Thu, 10 Oct 2024 16:02:53 +0200 Subject: [PATCH 5/7] back to full pipeline --- Jenkinsfile_k8s | 39 +++++++++++++++++++-------------------- 1 file changed, 19 insertions(+), 20 deletions(-) diff --git a/Jenkinsfile_k8s b/Jenkinsfile_k8s index b52765da8..d591160de 100644 --- a/Jenkinsfile_k8s +++ b/Jenkinsfile_k8s @@ -74,22 +74,22 @@ pipeline { } } } - // stage('GC on Azure') { - // environment { - // PACKER_AZURE = credentials('packer-azure-serviceprincipal-sponsorship') - // } - // steps { - // catchError(buildResult: 'SUCCESS', stageResult: 'FAILURE') { - // sh 'az login --service-principal -u "$PACKER_AZURE_CLIENT_ID" -p "$PACKER_AZURE_CLIENT_SECRET" -t "$PACKER_AZURE_TENANT_ID"' - // sh 'az account set -s "$PACKER_AZURE_SUBSCRIPTION_ID"' - // sh './cleanup/azure_gallery_images.sh 1 dev' - // sh './cleanup/azure_gallery_images.sh 7 staging' - // sh './cleanup/azure.sh 1 dev' - // sh './cleanup/azure.sh 1 staging' - // sh './cleanup/azure.sh 1 prod' - // } - // } - // } + stage('GC on Azure') { + environment { + PACKER_AZURE = credentials('packer-azure-serviceprincipal-sponsorship') + } + steps { + catchError(buildResult: 'SUCCESS', stageResult: 'FAILURE') { + sh 'az login --service-principal -u "$PACKER_AZURE_CLIENT_ID" -p "$PACKER_AZURE_CLIENT_SECRET" -t "$PACKER_AZURE_TENANT_ID"' + sh 'az account set -s "$PACKER_AZURE_SUBSCRIPTION_ID"' + sh './cleanup/azure_gallery_images.sh 1 dev' + sh './cleanup/azure_gallery_images.sh 7 staging' + sh './cleanup/azure.sh 1 dev' + sh './cleanup/azure.sh 1 staging' + sh './cleanup/azure.sh 1 prod' + } + } + } } } stage('Packer Images') { @@ -97,18 +97,17 @@ pipeline { axes { axis { name 'cpu_architecture' - values 'amd64'//, 'arm64' + values 'amd64', 'arm64' } axis { name 'agent_type' // make sure to port any addition to the list of agent types to the Build Docker Manifest stage if it's docker related - //values 'ubuntu-22.04', 'windows-2019', 'windows-2022' - values 'windows-2019', 'windows-2022' + values 'ubuntu-22.04', 'windows-2019', 'windows-2022' } axis { name 'compute_type' // "azure-arm" stands for "Azure Resource Manager", unrelated to arm64 CPU - values 'azure-arm' //'docker' + values 'azure-arm', 'docker' } } excludes { From cb1e37768745b1cfa75bb7f060a2f2d387a350b7 Mon Sep 17 00:00:00 2001 From: smerle33 Date: Thu, 10 Oct 2024 16:03:49 +0200 Subject: [PATCH 6/7] chore --- build-jenkins-agent-windows.pkr.hcl | 2 -- 1 file changed, 2 deletions(-) diff --git a/build-jenkins-agent-windows.pkr.hcl b/build-jenkins-agent-windows.pkr.hcl index 5a22fb362..9a2bca1af 100644 --- a/build-jenkins-agent-windows.pkr.hcl +++ b/build-jenkins-agent-windows.pkr.hcl @@ -7,8 +7,6 @@ build { image_publisher = "MicrosoftWindowsServer" # List available SKUs with the command `az vm image list-skus --offer WindowsServer --location eastus --publisher MicrosoftWindowsServer --output table` image_sku = "${var.agent_os_version}-datacenter-core-g2" - # List available images `az vm image list --location eastus --publisher MicrosoftWindowsServer --offer WindowsServer --sku 2019-datacenter-core-g2 --all --output table` - # List available images `az vm image list --location eastus --publisher MicrosoftWindowsServer --offer WindowsServer --sku 2022-datacenter-core-g2 --all --output table` image_version = local.windows_image_version[var.agent_os_version] os_type = "Windows" os_disk_size_gb = local.windows_disk_size_gb From 81bc475b6b6266d4c048769b4b54c0b6bd90d0ac Mon Sep 17 00:00:00 2001 From: smerle33 Date: Thu, 10 Oct 2024 16:16:30 +0200 Subject: [PATCH 7/7] chore value for 22.04 --- build-jenkins-agent-ubuntu.pkr.hcl | 4 ++-- build-jenkins-agent-windows.pkr.hcl | 8 ++++---- locals.pkr.hcl | 7 ++++--- 3 files changed, 10 insertions(+), 9 deletions(-) diff --git a/build-jenkins-agent-ubuntu.pkr.hcl b/build-jenkins-agent-ubuntu.pkr.hcl index e73c8a012..8868b1f05 100644 --- a/build-jenkins-agent-ubuntu.pkr.hcl +++ b/build-jenkins-agent-ubuntu.pkr.hcl @@ -56,8 +56,8 @@ build { } provisioner "shell" { - execute_command = "{{ .Vars }} sudo -E su - jenkins -c \"bash -eu '{{ .Path }}'\"" - environment_vars = local.provisioning_env_vars + execute_command = "{{ .Vars }} sudo -E su - jenkins -c \"bash -eu '{{ .Path }}'\"" + environment_vars = local.provisioning_env_vars inline = [ "source /home/jenkins/.asdf/asdf.sh", # Required as this is a non-interactive and non-login `bash` "goss --version", diff --git a/build-jenkins-agent-windows.pkr.hcl b/build-jenkins-agent-windows.pkr.hcl index 9a2bca1af..45f8f7f6d 100644 --- a/build-jenkins-agent-windows.pkr.hcl +++ b/build-jenkins-agent-windows.pkr.hcl @@ -90,7 +90,7 @@ build { destination = "C:/goss-windows.yaml" } - provisioner "file" { + provisioner "file" { source = "./tests/goss-common.yaml" destination = "C:/goss-common.yaml" } @@ -101,8 +101,8 @@ build { } provisioner "powershell" { - pause_before = "2m" # long pause as 1m is not enough - environment_vars = local.provisioning_env_vars + pause_before = "2m" # long pause as 1m is not enough + environment_vars = local.provisioning_env_vars inline = [ "$ErrorActionPreference = 'Stop'", "goss --version", @@ -113,7 +113,7 @@ build { } provisioner "powershell" { - environment_vars = local.provisioning_env_vars + environment_vars = local.provisioning_env_vars inline = [ "Remove-Item -Force C:/goss-windows.yaml", "Remove-Item -Force C:/goss-common.yaml", diff --git a/locals.pkr.hcl b/locals.pkr.hcl index c7aecb0b0..2ee93addb 100644 --- a/locals.pkr.hcl +++ b/locals.pkr.hcl @@ -15,9 +15,10 @@ locals { } # List available images `az vm image list --location eastus --publisher MicrosoftWindowsServer --offer WindowsServer --sku 2022-datacenter-core-g2 --all --output table` - windows_image_version= { - "2019" = "17763.6293.240905" - "2022" = "20348.2762.241006" + windows_image_version = { + "2019" = "17763.6293.240905" + "2022" = "20348.2762.241006" + "22.04" = "latest" #just to avoid error on run for linux, but not used } azure_vm_size = {