dmacvicar / terraform-provider-libvirt

Terraform provider to provision infrastructure with Linux's KVM using libvirt
Apache License 2.0
1.54k stars 457 forks source link

Re-running terraform apply after initial Error will error out with "domain [...] already exists" #921

Open raoulbhatia opened 2 years ago

raoulbhatia commented 2 years ago

Related to #920 and also #423

System Information etc.

See #920


Description of Issue/Question

Setup

See #920

Steps to Reproduce Issue

  1. terraform apply until you hit #920
  2. Manually fix by editing /etc/apparmor.d/local/abstractions/libvirt-qemu
  3. terraform apply
libvirt_domain.domain-ubuntu: Creating...
╷
│ Error: error defining libvirt domain: operation failed: domain 'terraform-kvm-ansible' already exists with uuid 7454585d-3a7c-42a9-a822-835b9ca3c1b6
│
│   with libvirt_domain.domain-ubuntu,
│   on main.tf line 33, in resource "libvirt_domain" "domain-ubuntu":
│   33: resource "libvirt_domain" "domain-ubuntu" {
│

Solution

  1. Run virsh undefine terraform-kvm-ansible
  2. terraform apply
  3. terraform-kvm-ansible will come up successfully

Additional information:

Apparmor as articulated in #920

alancaldelas commented 2 years ago

This also is happening to me, any updates?

tovoro commented 2 years ago

Same here while deploying Centos 8 guests on a Fedora35 Host. Additionally, the domain does not get destroyed when running terraform destroy

alancaldelas commented 2 years ago

Yeah, I'm also on a F35 host. Additionally, I'm doing a UEFI deployment and running the destroy also removes the /usr/share/edk2/OVMF_VARS.fd file so when I got re-deploy the file is now missing.