26 lines
832 B
Bash
26 lines
832 B
Bash
|
|
#!/usr/bin/env bash
|
||
|
|
#
|
||
|
|
# teardown.sh -- destroy the two test VMs. Cloud image + snippet files
|
||
|
|
# stay in PVE storage so the next `terraform apply` is fast.
|
||
|
|
|
||
|
|
set -euo pipefail
|
||
|
|
cd "$(dirname "$0")/../terraform"
|
||
|
|
|
||
|
|
if ! command -v terraform >/dev/null; then
|
||
|
|
echo "terraform not installed on this host" >&2
|
||
|
|
exit 2
|
||
|
|
fi
|
||
|
|
|
||
|
|
# Destroy only the VMs, keep the cached cloud image + snippets so the
|
||
|
|
# next apply doesn't re-download. `terraform destroy` with -target lists
|
||
|
|
# is fine because everything else is either downloaded content (image)
|
||
|
|
# or a snippet file (cheap to re-create).
|
||
|
|
terraform destroy \
|
||
|
|
-target=proxmox_virtual_environment_vm.store \
|
||
|
|
-target=proxmox_virtual_environment_vm.bmpgen \
|
||
|
|
-auto-approve
|
||
|
|
|
||
|
|
echo
|
||
|
|
echo "VMs destroyed. To also drop the cached image + snippets:"
|
||
|
|
echo " terraform destroy (without -target)"
|