terraform-provider-libvirt
terraform-provider-libvirt copied to clipboard
updates to disk file argument are not reflected on libvirt host
System Information
Linux distribution
Ubuntu 18.04.2 LTS
Terraform version
Terraform v0.11.14
+ provider.libvirt (unversioned)
+ provider.template v2.1.2
Provider and libvirt versions
terraform-provider-libvirt 0.5.2
Compiled against library: libvirt 4.0.0
Using library: libvirt 4.0.0
Checklist
-
[ ] 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?
- [ ] 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.
- [ ] If it is a very special case, consider using the XSLT support in the provider to tweak the definition instead of opening an issue
- [ ] 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
Changing file path in disk block and running terraform apply
results in successful (according to terraform) in-place update, but does not result in a change on the host. For example, the following shows output after changing path to iso file from SLE-15-Packages-s390x-GM-DVD1.iso
to SLE-15-Installer-DVD-s390x-GM-DVD1.iso
:
terraform apply
data.template_file.user_data: Refreshing state...
data.template_file.network_config: Refreshing state...
libvirt_cloudinit_disk.commoninit_guest1: Refreshing state... (ID: /guestimages/data1/terraform/joe_terraf...o;5d4adfc2-9d4c-9f28-f090-f002d2df7cd0)
libvirt_volume.guest1: Refreshing state... (ID: /guestimages/data1/terraform/joe_terraform_demo.qcow2)
libvirt_domain.guest1: Refreshing state... (ID: 8680a09d-72c8-4210-a31a-0733d4f7d1c6)
An execution plan has been generated and is shown below.
Resource actions are indicated with the following symbols:
~ update in-place
Terraform will perform the following actions:
~ libvirt_domain.guest1
disk.1.file: "/home/jmuro/images/isos/SLE-15-Packages-s390x-GM-DVD1.iso" => "/home/jmuro/images/isos/SLE-15-Installer-DVD-s390x-GM-DVD1.iso"
Plan: 0 to add, 1 to change, 0 to destroy.
Do you want to perform these actions?
Terraform will perform the actions described above.
Only 'yes' will be accepted to approve.
Enter a value: yes
libvirt_domain.guest1: Modifying... (ID: 8680a09d-72c8-4210-a31a-0733d4f7d1c6)
disk.1.file: "/home/jmuro/images/isos/SLE-15-Packages-s390x-GM-DVD1.iso" => "/home/jmuro/images/isos/SLE-15-Installer-DVD-s390x-GM-DVD1.iso"
libvirt_domain.guest1: Modifications complete after 0s (ID: 8680a09d-72c8-4210-a31a-0733d4f7d1c6)
Apply complete! Resources: 0 added, 1 changed, 0 destroyed.
Output of terraform show
(correctly) shows updated disk path:
...
libvirt_domain.guest1:
id = 8680a09d-72c8-4210-a31a-0733d4f7d1c6
arch = s390x
autostart = false
disk.# = 2
disk.0.file =
disk.0.scsi = false
disk.0.url =
disk.0.volume_id = /guestimages/data1/terraform/joe_terraform_demo.qcow2
disk.0.wwn =
disk.1.file = /home/jmuro/images/isos/SLE-15-Installer-DVD-s390x-GM-DVD1.iso
disk.1.scsi = false
However, output of virsh dumpxml
on host showing old path still in-use:
<domain type='kvm' id='53'>
<name>joe_terraform_demo</name>
<uuid>8680a09d-72c8-4210-a31a-0733d4f7d1c6</uuid>
<memory unit='KiB'>1048576</memory>
<currentMemory unit='KiB'>1048576</currentMemory>
<vcpu placement='static'>2</vcpu>
...
<disk type='file' device='cdrom'>
<driver name='qemu' type='raw'/>
<source file='/home/jmuro/images/isos/SLE-15-Packages-s390x-GM-DVD1.iso'/>
<backingStore/>
<target dev='hda' bus='scsi'/>
<readonly/>
<alias name='scsi0-0-0-0'/>
<address type='drive' controller='0' bus='0' target='0' unit='0'/>
</disk>
Also, ssh'ing into guest and mounting /dev/sr0
shows installer disk is still attached.
Setup
main.tf
provider "libvirt" {
uri = "qemu+ssh://myuser@myhost/system"
}
resource "libvirt_volume" "guest1" {
name = "joe_terraform_demo.qcow2"
pool = "terraform"
base_volume_name = "sles15-sp1-master"
base_volume_pool = "terraform"
format = "qcow2"
}
resource "libvirt_domain" "guest1" {
name = "joe_terraform_demo"
vcpu = "2"
memory = "1024"
cloudinit = "${libvirt_cloudinit_disk.commoninit_guest1.id}"
disk = [
{
volume_id = "${libvirt_volume.guest1.id}"
},
{
file = "/home/jmuro/images/isos/SLE-15-Installer-DVD-s390x-GM-DVD1.iso"
#file = "/home/jmuro/images/isos/SLE-15-Packages-s390x-GM-DVD1.iso"
}
]
network_interface {
bridge = "mybridge"
}
console {
type = "pty"
target_port = "0"
}
xml {
xslt = "${file("${path.module}/xsl/xml_overrides.xsl")}"
}
provisioner "local-exec" {
command = "echo ${libvirt_domain.guest1.network_interface.0.mac} >> domain.txt"
}
}
Steps to Reproduce Issue
- Change disk file argument in main.tf
-
terraform apply