Run packer against a specific builder 89/65089/3
authorThanh Ha <zxiiro@gmail.com>
Fri, 14 Aug 2020 14:09:35 +0000 (10:09 -0400)
committerThanh Ha <zxiiro@gmail.com>
Wed, 19 Aug 2020 15:32:49 +0000 (11:32 -0400)
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 <zxiiro@gmail.com>
jjb/lf-ci-jobs.yaml
jjb/lf-macros.yaml
releasenotes/notes/packer-specify-builder-9911c0cf4dfb493d.yaml [new file with mode: 0644]
shell/packer-build.sh

index fd46329..a7d2ced 100644 (file)
@@ -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
 
       - 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}"
index b1875d2..8726760 100644 (file)
               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 (file)
index 0000000..b68a873
--- /dev/null
@@ -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.
index 1a44e4f..73e7496 100644 (file)
@@ -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"