forked from klauserber/coder-development-cluster
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrun_destroy.sh
executable file
·31 lines (21 loc) · 1.06 KB
/
run_destroy.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
#!/usr/bin/env bash
SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )
. ${SCRIPT_DIR}/script_init.inc.sh
UNINSTALL_APPS=${3:-true}
REMOVE_BACKUPS=${4:-false}
${SCRIPT_DIR}/secrets_get.sh ${GCLOUD_PROJECT} ${CLUSTER_NAME}
ansible-playbook -i inventory ${SCRIPT_DIR}/automate/tf_vars.yml
. ${SCRIPT_DIR}/config/env
export GOOGLE_APPLICATION_CREDENTIALS=${SCRIPT_DIR}/config_default/google-coder-automation.json
terraform -chdir=${SCRIPT_DIR}/infrastructure/google init \
-backend-config="bucket=${BUCKET_NAME}" \
-backend-config="prefix=tf-state/${CLUSTER_NAME}" \
if [[ ! ${UNINSTALL_APPS} == "false" ]]; then
${SCRIPT_DIR}/get_kubeconfig.sh
IP_ADDRESS=$(terraform -chdir=${SCRIPT_DIR}/infrastructure/google output -raw ip_address)
ansible-playbook -i inventory ${SCRIPT_DIR}/automate/destroy.yml -e ip_address=${IP_ADDRESS}
fi
terraform -chdir=${SCRIPT_DIR}/infrastructure/google destroy ${TERRAFORM_OPTIONS}
if [[ ${REMOVE_BACKUPS} == "true" ]]; then
ansible-playbook -i inventory ${SCRIPT_DIR}/automate/remove_backups.yml
fi