🔧 Retry 'terraform apply' 3 times if it fails

Some platforms (looking at you OpenStack) can exhibit random
transient failures. This helps to work around them.
This commit is contained in:
ENIX NOC
2023-03-11 18:27:41 +00:00
committed by Jérôme Petazzoni
parent fa0a894ebc
commit bc1ba942c0

View File

@@ -34,8 +34,15 @@ infra_start() {
fi
echo prefix = \"$TAG\" >> terraform.tfvars
echo how_many_nodes = \"$COUNT\" >> terraform.tfvars
terraform apply -auto-approve
terraform output -raw ip_addresses > ips.txt
for RETRY in 1 2 3; do
if terraform apply -auto-approve; then
terraform output -raw ip_addresses > ips.txt
break
fi
done
if ! [ -f ips.txt ]; then
die "Terraform failed."
fi
)
}