From 90dd675df482a821fa6a76f7eeb69b2ca8514faa Mon Sep 17 00:00:00 2001 From: Thanh Ha Date: Fri, 14 Aug 2020 10:09:35 -0400 Subject: [PATCH] Run packer against a specific builder As preparation to enable the ability to configure multiple builders in a single packer template, we need to enable the ability in the job to select which builder to run. This patch sets up a new variable "packer-builder" which is used to select the builder definition in the templates file. Defaulting to "openstack" as that's the most common use case at the moment. Issue: RELENG-1052 Change-Id: Ib33a00f38a0005af69d52e7697322a2e84f6c674 Signed-off-by: Thanh Ha --- jjb/lf-ci-jobs.yaml | 2 ++ jjb/lf-macros.yaml | 1 + .../notes/packer-specify-builder-9911c0cf4dfb493d.yaml | 12 ++++++++++++ shell/packer-build.sh | 1 + 4 files changed, 16 insertions(+) create mode 100644 releasenotes/notes/packer-specify-builder-9911c0cf4dfb493d.yaml diff --git a/jjb/lf-ci-jobs.yaml b/jjb/lf-ci-jobs.yaml index fd463299..a7d2ceda 100644 --- a/jjb/lf-ci-jobs.yaml +++ b/jjb/lf-ci-jobs.yaml @@ -28,6 +28,7 @@ submodule-recursive: true submodule-timeout: 10 submodule-disable: false + packer-builder: openstack packer-cloud-settings: packer-cloud-env packer-version: 1.4.2 @@ -1479,6 +1480,7 @@ - lf-infra-packer-build: openstack: "{openstack}" openstack-cloud: "{openstack-cloud}" + packer-builder: "{packer-builder}" packer-cloud-settings: "{packer-cloud-settings}" packer-version: "{packer-version}" platform: "{platforms}" diff --git a/jjb/lf-macros.yaml b/jjb/lf-macros.yaml index b1875d2a..87267603 100644 --- a/jjb/lf-macros.yaml +++ b/jjb/lf-macros.yaml @@ -128,6 +128,7 @@ variable: CLOUDENV - inject: properties-content: | + PACKER_BUILDER={packer-builder} PACKER_PLATFORM={platform} PACKER_TEMPLATE={template} PACKER_VERSION={packer-version} diff --git a/releasenotes/notes/packer-specify-builder-9911c0cf4dfb493d.yaml b/releasenotes/notes/packer-specify-builder-9911c0cf4dfb493d.yaml new file mode 100644 index 00000000..b68a8735 --- /dev/null +++ b/releasenotes/notes/packer-specify-builder-9911c0cf4dfb493d.yaml @@ -0,0 +1,12 @@ +--- +features: + - | + Packer CI jobs now have the ability to specify which "builder" to use in + the job. Default configuration is the for the "openstack" builder. +upgrade: + - | + Requires common-packer v0.7.0 if using packer CI jobs. + - | + If your project is in AWS and uses the Packer CI jobs to build AMIs you + must set ``packer-builder: aws`` when upgrading to this version of + global-jjb or your jobs will default to openstack and fail. diff --git a/shell/packer-build.sh b/shell/packer-build.sh index 1a44e4fd..73e74965 100644 --- a/shell/packer-build.sh +++ b/shell/packer-build.sh @@ -63,6 +63,7 @@ fi set +x packer.io build -color=false \ + -only "${PACKER_BUILDER}" \ -var-file="$CLOUDENV" \ -var-file="$platform_file" \ "templates/$PACKER_TEMPLATE.json" -- 2.16.6