Move packer validate to an include-raw
authorAndrew Grimberg <agrimberg@linuxfoundation.org>
Wed, 1 Feb 2017 15:40:38 +0000 (07:40 -0800)
committerAndrew Grimberg <agrimberg@linuxfoundation.org>
Wed, 1 Feb 2017 15:40:38 +0000 (07:40 -0800)
Rather than deal with trying to properly escape curly-braces variables
in the shell script for the packer validate it's just easier to move
that out to a script to be included with no extra parsing

Change-Id: I15ccfceafef46f05d12ba5b4e5cf7b07d75ee40f
Signed-off-by: Andrew Grimberg <agrimberg@linuxfoundation.org>
jjb/ci-management/ci-management-macros.yaml
jjb/ci-management/raw-include-packer-validate.sh [new file with mode: 0644]

index 6481773..e79cf8a 100644 (file)
@@ -7,28 +7,7 @@
           files:
             - file-id: 'packer-cloud-env'
               variable: 'CLOUDENV'
-      # yamllint disable rule:line-length
-      - shell: |
-          cd packer
-          varfiles="../packer/vars/*"
-          templates="../packer/templates/*"
-          provision="../packer/provision/*.sh"
-          for v in $varfiles; do
-              [[ "${{v##*/}}" =~ ^(cloud-env.*)$ ]] && continue
-              for t in $templates; do
-                  export PACKER_LOG="yes" && \
-                  export PACKER_LOG_PATH="packer-validate-${{v##*/}}-${{t##*/}}.log" && \
-                              packer.io validate -var-file=$CLOUDENV \
-                              -var-file=$v $t
-                  if [ $? -ne 0 ]; then
-                      break
-                  fi
-              done
-          done
-          for p in $provision; do
-              /bin/bash -n $p > provision-validate-${{p##*/}}.log 2>&1
-          done
-      # yamllint enable
+      - shell: !include-raw: raw-include-packer-validate.sh
 
 - builder:
     name: packer-build
diff --git a/jjb/ci-management/raw-include-packer-validate.sh b/jjb/ci-management/raw-include-packer-validate.sh
new file mode 100644 (file)
index 0000000..01984dd
--- /dev/null
@@ -0,0 +1,19 @@
+cd packer
+varfiles="../packer/vars/*"
+templates="../packer/templates/*"
+provision="../packer/provision/*.sh"
+for v in $varfiles; do
+  [[ "${v##*/}" =~ ^(cloud-env.*)$ ]] && continue
+  for t in $templates; do
+  export PACKER_LOG="yes" && \
+  export PACKER_LOG_PATH="packer-validate-${v##*/}-${t##*/}.log" && \
+          packer.io validate -var-file=$CLOUDENV \
+          -var-file=$v $t
+  if [ $? -ne 0 ]; then
+      break
+  fi
+  done
+done
+for p in $provision; do
+  /bin/bash -n $p > provision-validate-${p##*/}.log 2>&1
+done