From 3d4f303a84d7aeba5d25d7a1732c4ca7265343ed Mon Sep 17 00:00:00 2001 From: James Cleverley-Prance Date: Tue, 22 Feb 2022 11:32:17 +0000 Subject: [PATCH] feat: Catch failed cloud-init run before goss --- terraform/modules/scripts/run-goss.sh | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/terraform/modules/scripts/run-goss.sh b/terraform/modules/scripts/run-goss.sh index b8aea0b6..c7667584 100755 --- a/terraform/modules/scripts/run-goss.sh +++ b/terraform/modules/scripts/run-goss.sh @@ -31,8 +31,14 @@ install_goss() { readonly -f install_goss wait_for_cloud_init() { - while ! grep -q "finish: modules-final: SUCCESS: running modules for final" /var/log/cloud-init.log; do - echo "Waiting 5s for cloud-init to finish" + while :; do + if grep -q "finish: modules-final: SUCCESS: running modules for final" /var/log/cloud-init.log; then + echo "Waiting 5s for cloud-init to finish" + break + elif grep -q "finish: modules-final: FAIL" /var/log/cloud-init.log; then + echo "cloud init failed" + exit 1 + fi sleep 5 done }