added null ressouce to destroy lb

This commit is contained in:
Karim Naufal 2022-02-24 01:44:56 +01:00
parent 4e3858e54b
commit 6739b4a493
2 changed files with 18 additions and 0 deletions

17
main.tf
View File

@ -158,3 +158,20 @@ data "hcloud_load_balancer" "traefik" {
depends_on = [null_resource.kustomization]
}
resource "null_resource" "destroy_lb" {
triggers = {
token = random_password.k3s_token.result
}
# Important when issuing terraform destroy, otherwise the LB will not let the network get deleted
provisioner "local-exec" {
when = destroy
command = <<-EOT
hcloud load-balancer delete traefik
hcloud network delete k3s
EOT
on_failure = continue
}
}

View File

@ -66,6 +66,7 @@ rpm --import https://rpm.rancher.io/public.key
zypper refresh
zypper --gpg-auto-import-keys install -y https://rpm.rancher.io/k3s/stable/common/microos/noarch/k3s-selinux-0.4-1.sle.noarch.rpm
udevadm settle
exit 0
EOF
}