Use clouds.yaml for openstack packer builders 50/12550/4
authorThanh Ha <thanh.ha@linuxfoundation.org>
Wed, 12 Sep 2018 00:03:52 +0000 (20:03 -0400)
committerThanh Ha <thanh.ha@linuxfoundation.org>
Wed, 12 Sep 2018 14:47:49 +0000 (10:47 -0400)
Since packer version 1.2.5, packer now supports pulling openstack
config from clouds.yaml. Let's consolidate to that file so that we
don't have duplicate configuration with the jobs that need the
openstack cli.

Issue: RELENG-1205
Change-Id: Idf23a30b111dd922120fb6195d0411e2fc993dab
Signed-off-by: Thanh Ha <thanh.ha@linuxfoundation.org>
docs/jjb/lf-ci-jobs.rst
docs/jjb/lf-macros.rst
jjb/lf-ci-jobs.yaml
jjb/lf-macros.yaml
releasenotes/notes/packer-openstack-clouds-yaml-b0f8a251d9b68bee.yaml [new file with mode: 0644]

index 0ac86d9..6a8caff 100644 (file)
@@ -552,6 +552,9 @@ Packer Merge job runs `packer build` to build system images in the cloud.
     :build-days-to-keep: Days to keep build logs in Jenkins. (default: 7)
     :build-timeout: Timeout in minutes before aborting build. (default: 90)
     :git-url: URL clone project from. (default: $GIT_URL/$PROJECT)
+    :openstack: Packer template uses an OpenStack builder (default: true).
+    :openstack-cloud: Sets OS_CLOUD variable to the value of this parameter.
+        (default: vex).
     :packer-cloud-settings: Name of settings file containing credentials
         for the cloud that packer will build on. (default: packer-cloud-env)
     :packer-version: Version of packer to install / use in build. (default: 1.0.2)
index a57fac5..69873c9 100644 (file)
@@ -110,6 +110,14 @@ lf-infra-packer-build
 
 Run `packer build` to build system images.
 
+:Required parameters:
+
+    :openstack: Packer template uses an OpenStack builder (true|false).
+    :openstack-cloud: Sets OS_CLOUD variable to the value of this parameter.
+    :packer-version: Version of packer to use.
+    :platform: Build platform as found in the vars directory.
+    :template: Packer template to build as found in the templates directory.
+
 lf-infra-packer-validate
 ------------------------
 
index ec3e48e..e9e483e 100644 (file)
@@ -37,7 +37,7 @@
     stream: master
     submodule-recursive: true
     packer-cloud-settings: packer-cloud-env
-    packer-version: 1.2.3
+    packer-version: 1.2.5
 
     #####################
     # Job Configuration #
 - lf_packer_merge: &lf_packer_merge
     name: lf-packer-merge
 
+    ######################
+    # Default parameters #
+    ######################
+
+    openstack: true
+    openstack-cloud: vex
+
     #####################
     # Job Configuration #
     #####################
 
+    parameters:
+      - lf-infra-parameters:
+          project: '{project}'
+          stream: '{stream}'
+          branch: '{branch}'
+          lftools-version: '{lftools-version}'
+      - lf-packer-parameters:
+          packer-version: '{packer-version}'
+
     builders:
       - lf-infra-packer-build:
+          openstack: '{openstack}'
+          openstack-cloud: '{openstack-cloud}'
           packer-cloud-settings: '{packer-cloud-settings}'
           packer-version: '{packer-version}'
           platform: '{platforms}'
index 5188417..9572f88 100644 (file)
 - builder:
     name: lf-infra-packer-build
     builders:
+      - conditional-step:
+          condition-kind: boolean-expression
+          condition-expression: '{openstack}'
+          steps:
+            - config-file-provider:
+                files:
+                  - file-id: clouds-yaml
+                    target: '$HOME/.config/openstack/clouds.yaml'
+            - inject:
+                properties-content: OS_CLOUD={openstack-cloud}
       - config-file-provider:
           files:
             - file-id: '{packer-cloud-settings}'
diff --git a/releasenotes/notes/packer-openstack-clouds-yaml-b0f8a251d9b68bee.yaml b/releasenotes/notes/packer-openstack-clouds-yaml-b0f8a251d9b68bee.yaml
new file mode 100644 (file)
index 0000000..9a429d3
--- /dev/null
@@ -0,0 +1,14 @@
+---
+features:
+  - |
+    Add support to the packer-build job to use clouds.yaml for openstack builder
+    configuration rather than through the cloud-env file. This allows us to
+    simplify the template configuration for openstack builders moving forward.
+upgrade:
+  - |
+    Minimum packer version 1.2.5 is now required for the packer-build job.
+  - |
+    **lf-infra-packer-build** macro now requires 2 new variables to be passed.
+
+    #. **openstack:** Set to true if template is built using the openstack builder
+    #. **openstack-cloud:** The clouds.yaml cloud to use when running ``packer build``