From bc08b44fd11cb083b85ac9b30d7bffa2a4024046 Mon Sep 17 00:00:00 2001
From: Mark Goddard <mark@stackhpc.com>
Date: Fri, 28 Jun 2019 12:32:52 +0100
Subject: [PATCH] Exit on failure in init-runonce

Previously we sourced this script in tests/deploy.sh, but this was
recently changed. Following that change we lost the errexit setting,
meaning we ignore errors in init-runonce.

Adding errexit in the script itself means that all callers get error
handling.

Also log init-runonce output.

TrivialFix

Change-Id: I9b35bd5f0f76eec26ddd968d093a3a5fd55a7ce2
---
 tests/deploy.sh    | 2 +-
 tools/init-runonce | 4 +++-
 2 files changed, 4 insertions(+), 2 deletions(-)

diff --git a/tests/deploy.sh b/tests/deploy.sh
index 91e4a5f960..9267c748e8 100755
--- a/tests/deploy.sh
+++ b/tests/deploy.sh
@@ -28,7 +28,7 @@ function deploy {
 
     if ! openstack image show cirros >/dev/null 2>&1; then
         echo "Initialising OpenStack resources via init-runonce"
-        tools/init-runonce
+        tools/init-runonce > /tmp/logs/ansible/init-runonce
     else
         echo "Not running init-runonce - resources exist"
     fi
diff --git a/tools/init-runonce b/tools/init-runonce
index edbb490b5e..336baa162d 100755
--- a/tools/init-runonce
+++ b/tools/init-runonce
@@ -1,5 +1,7 @@
 #!/bin/bash
-#
+
+set -o errexit
+
 # This script is meant to be run once after running start for the first
 # time.  This script downloads a cirros image and registers it.  Then it
 # configures networking and nova quotas to allow 40 m1.small instances