$ ~/.terraform.d/plugins/linux_amd64/terraform-provider-libvirt --version
/home/gthieleb/.terraform.d/plugins/linux_amd64/terraform-provider-libvirt d1cf93cdb066b2d3d2c2c046d2fb986808d9a424
Compiled against library: libvirt 5.6.0
Using library: libvirt 5.6.0
Running hypervisor: QEMU 4.1.1
Running against daemon: 5.6.0
Checklist
[x] Is your issue/contribution related with enabling some setting/option exposed by libvirt that the plugin does not yet support, or requires changing/extending the provider terraform schema?
[x] Make sure you explain why this option is important to you, why it should be important to everyone. Describe your use-case with detail and provide examples where possible.
[x] If it is a very special case, consider using the XSLT support in the provider to tweak the definition instead of opening an issue
[x] Maintainers do not have expertise in every libvirt setting, so please, describe the feature and how it is used. Link to the appropriate documentation
[x] Is it a bug or something that does not work as expected? Please make sure you fill the version information below:
Description of Issue/Question
Update an existing template by adding a new disk forces recreation of the domain.
This leads to generation of a new mac address and new device ids.
I make use of the mac_address for a custom cloud-init iso (The usage scenario is multi nic VM setups).
It is created after creation of the libvirt_domain based on the output of a previous terraform apply command.
Setup
# we need to use the local qemu connection string here
provider "libvirt" {
uri = "qemu:///system"
}
resource "libvirt_volume" "vol" {
name = "centos-test.qcow2"
pool = "vm-pool"
source = "/data/vms/templates/centos-packer.qcow2"
format = "qcow2"
}
# Create the machine
resource "libvirt_domain" "vm" {
# run state is controlled by ansible
running = "false"
name = "centos-test"
memory = "2048"
vcpu = 2
network_interface {
# we only provide the name of the existing
network_name = "default"
}
disk {
volume_id = libvirt_volume.vol.id
}
graphics {
type = "spice"
listen_type = "address"
autoport = "true"
}
}
output "libvirt_domain" {
value = libvirt_domain.vm
}
Steps to Reproduce Issue
Perform terraform apply using the template above
Add an additional device entry to the terraform template (Its an ISO that points to the custom cloudinit iso).
disk {
file = "/data/isos/centos-test_cloudinit.iso"
}
System Information
Linux distribution
Fedora 31
Terraform version
Provider and libvirt versions
Checklist
[x] Is your issue/contribution related with enabling some setting/option exposed by libvirt that the plugin does not yet support, or requires changing/extending the provider terraform schema?
[x] Is it a bug or something that does not work as expected? Please make sure you fill the version information below:
Description of Issue/Question
Update an existing template by adding a new disk forces recreation of the domain. This leads to generation of a new mac address and new device ids.
I make use of the
mac_address
for a custom cloud-init iso (The usage scenario is multi nic VM setups). It is created after creation of thelibvirt_domain
based on the output of a previous terraform apply command.Setup
Steps to Reproduce Issue
terraform apply
using the template aboveterraform
template (Its an ISO that points to the custom cloudinit iso).terraform apply
again.Current Behavior
terraform plan
terraform apply
Desired behavior
Terraform apply should not recreate the domain. Alternativel it should set
mac
and domainid
to its former values.