From 142f1f9e24f201f078a01aafcf0a7b7bfc6015f1 Mon Sep 17 00:00:00 2001 From: akutz Date: Mon, 16 Jul 2018 15:45:12 -0500 Subject: [PATCH] provider/vSphere: Make env destroy configurable This patch introduces the environment variable `VSPHERE_DESTROY_ENABLED`. Unless set to `true`, an environment deployed to vSphere will not be destroyed during the deprovision step. This PR is related to #161 and possibly #154. --- provision.sh | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/provision.sh b/provision.sh index a193916..9f15f45 100755 --- a/provision.sh +++ b/provision.sh @@ -436,7 +436,11 @@ elif [[ "$CLOUD_CMD" = "vsphere-deploy" || \ terraform taint -module=kubeconfig null_resource.kubeconfig || true time terraform apply -auto-approve ${DIR}/vsphere elif [ "$CLOUD_CMD" = "vsphere-destroy" ] ; then - time terraform destroy -force ${DIR}/vsphere || true + if [ "${VSPHERE_DESTROY_ENABLED}" = "true" ]; then + time terraform destroy -force ${DIR}/vsphere || true + else + echo "vsphere environment destruction disabled" + fi # Exit after destroying resources as further commands cause hang exit fi