Skip to content

Commit

Permalink
feat: Catch failed cloud-init run before goss
Browse files Browse the repository at this point in the history
  • Loading branch information
James Cleverley-Prance committed Feb 22, 2022
1 parent 24d9c8b commit 3d4f303
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions terraform/modules/scripts/run-goss.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down

0 comments on commit 3d4f303

Please sign in to comment.