Skip to content

Commit

Permalink
Merge branch 'main' into updatecli_43cd02cbfe369d52657ea550b57eca5afc…
Browse files Browse the repository at this point in the history
…d79931da384311ba0ef3d13d04e97f
  • Loading branch information
smerle33 authored Dec 22, 2023
2 parents c76ee93 + 0209ec1 commit 3f62db4
Show file tree
Hide file tree
Showing 6 changed files with 26 additions and 20 deletions.
4 changes: 2 additions & 2 deletions Jenkinsfile_k8s
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ pipeline {
}
stage('GC on Azure') {
environment {
PACKER_AZURE = credentials('packer-azure-serviceprincipal')
PACKER_AZURE = credentials('packer-azure-serviceprincipal-sponsorship')
}
steps {
catchError(buildResult: 'SUCCESS', stageResult: 'FAILURE') {
Expand Down Expand Up @@ -173,7 +173,7 @@ pipeline {
environment {
// Defines the following environment variables: AZURE_CLIENT_ID, AZURE_CLIENT_SECRET, AZURE_TENANT_ID, AZURE_SUBSCRIPTION_ID
// Ref. https://plugins.jenkins.io/azure-credentials/#plugin-content-declarative-pipeline
AZURE = credentials('packer-azure-serviceprincipal')
AZURE = credentials('packer-azure-serviceprincipal-sponsorship')
// // Split packer plugins/configuration for each matrix cell - ref. https://www.packer.io/docs/configure
// PACKER_PLUGIN_PATH = "${env.WORKSPACE}/plugins"
// Define Packer Input variables through environment variables prefixed with 'PKR_VAR_'
Expand Down
6 changes: 3 additions & 3 deletions build-jenkins-agent-ubuntu.pkr.hcl
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ build {
}

provisioner "shell" {
execute_command = "{{ .Vars }} sudo -E su - jenkins -c \"bash -eu '{{ .Path }}'\""
execute_command = "{{ .Vars }} sudo -E su - jenkins -c \"bash -eu '{{ .Path }}'\""
inline = [
"source /home/jenkins/.asdf/asdf.sh", # Required as this is a non-interactive and non-login `bash`
"goss --version",
Expand All @@ -55,9 +55,9 @@ build {
}

post-processor "docker-tag" {
only = ["docker.ubuntu"]
only = ["docker.ubuntu"]
# TODO specify architecture in image name with local.image_name
repository = format("%s/jenkins-agent-%s-%s",var.docker_namespace, var.agent_os_type, var.agent_os_version)
repository = format("%s/jenkins-agent-%s-%s", var.docker_namespace, var.agent_os_type, var.agent_os_version)
tags = [var.image_version, "latest"]
}
}
4 changes: 2 additions & 2 deletions build-jenkins-agent-windows.pkr.hcl
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ build {

provisioner "file" {
source = "./goss/goss-windows.yaml"
destination = "C:/goss-windows.yaml"
destination = "C:/goss-windows.yaml"
}

provisioner "breakpoint" {
Expand All @@ -79,7 +79,7 @@ build {
}

provisioner "powershell" {
pause_before = "2m" # long pause as 1m is not enough
pause_before = "2m" # long pause as 1m is not enough
inline = [
"$ErrorActionPreference = 'Stop'",
"goss --version",
Expand Down
14 changes: 7 additions & 7 deletions locals.pkr.hcl
Original file line number Diff line number Diff line change
Expand Up @@ -10,18 +10,18 @@ locals {
"arm64" = "${local.agent_os_version_safe}-lts-arm64"
}
windows_winrm_user = {
"azure-arm" = "packer"
"docker" = "packer"
"azure-arm" = "packer"
"docker" = "packer"
}
azure_vm_size = {
"amd64" = "Standard_D4s_v3" # 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_D4ps_v5" # 4 CPU / 16 GB
"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
}
azure_destination_resource_group = "${var.build_type}-packer-images"
azure_galleries = {
"prod_packer_images" = ["East US", "East US 2"]
"staging_packer_images" = ["East US", "East US 2"] # Only the "main" branch, should map the production as much as possible
"dev_packer_images" = ["East US"] # Faster builds for branches, pull requests or local development
"prod_packer_images" = ["East US 2"]
"staging_packer_images" = ["East US 2"]
"dev_packer_images" = ["East US 2"]
}
windows_disk_size_gb = 150 # Must be greater than 127 Gb to allow Azure template to work with
provisioning_env_vars = concat(
Expand Down
14 changes: 8 additions & 6 deletions sources.pkr.hcl
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,11 @@ source "azure-arm" "base" {
managed_image_resource_group_name = local.azure_destination_resource_group

vm_size = local.azure_vm_size[var.architecture]
spot {
eviction_policy = "Delete"
}

# network defined in https://github.com/jenkins-infra/azure-net/blob/a396b20f676602703c0dbdf4cee977eae2669cd7/vnets.tf#L535
virtual_network_name = "infra-ci-jenkins-io-sponsorship-vnet"
virtual_network_subnet_name = "infra-ci-jenkins-io-sponsorship-vnet-packer-builds"
virtual_network_resource_group_name = "infra-ci-jenkins-io-sponsorship"

# Resource group where to create the VM resources (required to scope permissions into this resource group)
build_resource_group_name = "${var.build_type}-packer-builds"
Expand All @@ -17,9 +19,9 @@ source "azure-arm" "base" {

# Where to export the image
shared_image_gallery_destination {
subscription = var.azure_subscription_id
resource_group = local.azure_destination_resource_group
gallery_name = "${var.build_type}_packer_images"
subscription = var.azure_gallery_subscription_id
resource_group = local.azure_destination_resource_group
gallery_name = "${var.build_type}_packer_images"
# Not unique name defined in https://github.com/jenkins-infra/azure/blob/bfe56cb4f843b0c8029413090c383f7ac38dde2a/locals.tf#L4-L41
image_name = "${local.image_name}"
image_version = var.image_version
Expand Down
4 changes: 4 additions & 0 deletions variables.pkr.hcl
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,10 @@ variable "azure_subscription_id" {
type = string
default = env("AZURE_SUBSCRIPTION_ID")
}
variable "azure_gallery_subscription_id" {
type = string
default = env("AZURE_SUBSCRIPTION_ID") # allow to specify distinct subscription
}
variable "image_version" {
type = string
default = "0.0.1" # Default is a valid version to not fail azure validation
Expand Down

0 comments on commit 3f62db4

Please sign in to comment.