mirror of
https://github.com/jpetazzo/container.training.git
synced 2026-07-21 22:07:13 +00:00
🔧 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:
committed by
Jérôme Petazzoni
parent
fa0a894ebc
commit
bc1ba942c0
@@ -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
|
||||
)
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user