Update Terraform libvirt to v0.9.7 #9
Reference in New Issue
Block a user
Delete Branch "renovate/libvirt-0.x"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
This PR contains the following updates:
0.7.6→0.9.7Release Notes
dmacvicar/terraform-provider-libvirt (libvirt)
v0.9.7Compare Source
Highlights
libvirt_volumeURL uploads to work when the source server does not provideContent-Length, as long ascapacityis set explicitly (including acceptance tests).What's Changed
Volume upload behavior
create.content.urluploads to fall back to user-providedcapacitywhen the HTTP source does not includeContent-Length.CI and release maintenance
Included changes
chore: add dependabot config for github actionschore(deps): update GitHub Actions dependencies(#1306, #1307, #1308, #1309, #1310, #1312, #1313, #1314, #1315)fix: allow URL uploads without content length(closes #1316)Contributors
Full Changelog
Full Changelog: https://github.com/dmacvicar/terraform-provider-libvirt/compare/v0.9.6...v0.9.7
v0.9.6Compare Source
Highlights
terraform importsupport forlibvirt_domainusing an existing domain UUID.What's Changed
Domain lifecycle and import
terraform importsupport forlibvirt_domainby UUID, allowing Terraform state to be populated from an existing libvirt domain definition.Readback and state preservation
Maintenance
google.golang.org/grpcfrom1.75.1to1.79.3.Contributors
Full Changelog
Full Changelog: https://github.com/dmacvicar/terraform-provider-libvirt/compare/v0.9.5...v0.9.6
v0.9.5Compare Source
Highlights
XMLNamemetadata.What's Changed
Schema and code generation
XMLNamemetadata, exposing:qemu_commandlineqemu_capabilitiesqemu_overrideqemu_deprecationlxc_namespacebhyve_commandlinevmware_data_center_pathxen_commandlineDomain and network improvements
vlan-idhandling reported in issue #1236.Documentation
Included changes
docs: add hypervisor namespace field descriptionsfix: support hypervisor XMLName fields in codegenrefactor: apply codegen field policies after reflectiontest: cover anonymous embedded XML fieldsfix: Process anonymous fields in libvirt XML(#1222 by @atopuzov)fix: make vlan tag ids configurable(fixes #1236)v0.9.4Compare Source
New Features (Experimental)
destroy.shutdown.timeoutoption onlibvirt_domainsends an ACPI shutdown signal and waits for the guest to power off cleanly before destroying it, instead of force-killing. Subject to change in future releases.createanddestroyblocks onlibvirt_poolgive explicit control over build, start, autostart, and backing storage deletion behavior during pool create/destroy. Subject to change in future releases.Bug Fixes
KEEP_NVRAMandKEEP_TPMundefine flags during updates. (#1232, @atopuzov)capacity_unitnot preserved on volume readback — specifyingcapacity_unit = "GiB"on a volume would cause "Provider produced inconsistent result after apply" on every apply, because libvirt normalizes to bytes in XML. The codegen now preserves the user's unit when the value was explicitly set. (#1253)terraform destroyof adirpool was callingStoragePoolDeletewhich removed the backing directory. The default behavior now preserves the directory (matchingvirsh pool-destroy+pool-undefine), with an explicitdestroy.delete = trueoverride available. (#1285)Dependencies
github.com/cloudflare/circlfrom 1.6.1 to 1.6.3. (#1284)Contributors
v0.9.3Compare Source
What's Changed
New Contributors
And thanks for those unmerged PRs @SkinGad @yannlambret @nicholas-rees
Full Changelog: https://github.com/dmacvicar/terraform-provider-libvirt/compare/v0.9.2...v0.9.3
v0.9.2Compare Source
Full Changelog: https://github.com/dmacvicar/terraform-provider-libvirt/compare/v0.9.1...v0.9.2
Thanks to @BohdanTkachenko for the feedback, reports and PR suggestions.
v0.9.1Compare Source
Bugfixes
VIR_DOMAIN_UNDEFINE_NVRAMandVIR_DOMAIN_UNDEFINE_TPM. These defaults may change in the future and be part of a domain block likecreateanddelete. (#1203 )Features
Support for full libvirt API (XML) (#1208 )
The provider now supports the whole libvirt API 🥳 (* that is supported by libvirtxml), thanks to a code generation engine which generates the whole terraform glue for the schemas and conversions.
For now, the usual resources (domain, network, volume, pool) are included, but this opens the door to handle other resources (secrets, etc) with little effort.
Migration Guide: 0.9.0 → v0.9.1
⚠️ as the schema is now generated, the documentation is now injected into the code generation. As there is no machine readable documentation for libvirt XML, we generated a set of documentation metadata using AI. This process can be improved over time.
Due to the introduction of the generator and some bugs in the 0.9.0 schema, we had to do some changes in the schema.
This document explains how to move Terraform configurations from provider v0.9.0 (the last manual schema) to the current HEAD that uses the libvirt-schema code generator. It only covers resources and attributes that existed in 0.9.0: domains, networks, storage pools, and storage volumes. Anything new that HEAD exposes can simply be added following the generated schema documentation.
What Changed Globally
accessmode→access_mode,portgroup→port_group). Set exactly the fields you care about; anything left null stays absent in the XML.memory+memory_unit,capacity+capacity_unit, etc.). Leaving the unit unset lets libvirt use its default.yes/nostrings when libvirt models them as attributes (e.g.os.loader_readonly). True presence booleans (likefeatures.acpi) still use Terraform bools.source.poolorfilesystem.source.{ metadata = { xml = <<EOF ... } }so we can extend later without breaking state.Domain Resource
Top-level attribute mapping
unitmemory_unitmax_memorymaximum_memorymaximum_memory_unitif you previously used a non-default unit.max_memory_slotsmaximum_memory_slotscurrent_memorycurrent_memory+ optionalcurrent_memory_unitmetadata(string)metadata = { xml = <<EOF ... EOF }os.archos.type_archtype_*prefix mirrors<os><type arch="..."/>.os.machineos.type_machineos.kernel_argsos.cmdline<cmdline>element.os.loader_pathos.loaderos.loader_readonly(bool)os.loader_readonly(string)"yes"/"no"because the XML attribute is a string.os.nvram.*os.nv_ram = { file, template, format = { type = ... } }devices.filesystems[*].accessmodeaccess_modedevices.filesystems[*].readonlyread_onlydevices.interfaces[*].source.portgroupsource = { network = { port_group = ... } }devices.rngs[*].devicebackend = { random = "/dev/urandom" }orbackend = { egd = { ... } }OS block specifics
os.boot_devicesis still a list, but if you previously stored strings you now provide objects:boot_devices = [{ dev = "hd" }, { dev = "network" }]."yes"/"no"). Wrap them intostring()if you had boolean locals.os = { nv_ram = { file = "/var/lib/libvirt/nvram.bin", template = "/usr/share/OVMF/OVMF_VARS.fd", format = { type = "raw" } } }.Loader value + attributes
<loader>is a “value + attributes” element. The path is the value (os.loader), and every XML attribute becomes a sibling attribute:Leave the attribute unset to let libvirt pick its default (the provider preserves user intent for optional attributes).
Disks and filesystems
0.9 flattened every disk source. HEAD requires you to pick the XML variant explicitly:
Filesystems follow the same pattern. Replace the old flat fields with nested objects:
Variant notation
Every
<source>element with mutually exclusive children (files, volumes, blocks, etc.) becomes an object whose attributes map 1:1 to the libvirt XML children. Only set the branch you need:Even if a variant has additional attributes in XML, the generated struct exposes them in that nested object (e.g.,
ram = { usage = 1024, unit = "MiB" }). This pattern is consistent across disks, filesystems, host devices, etc.Interfaces
source.network,source.bridge, andsource.devare now mutually exclusive nested objects. Example conversions:portgroupbecameport_group,wait_for_ipstays the same helper object.RNG / TPM / other devices
<backend>. Usebackend = { random = "/dev/urandom" }for /dev/random orbackend = { egd = { source = { mode = "connect", host = "unix", service = "..." } } }for EGD sockets.backend = { emulator = { path = "/var/lib/swtpm/sock" } }). Map your previousbackend_typeto one of the backend objects:emulator,passthrough, orexternal.auto_port,websocket, etc.).Metadata
0.9 stored raw XML as a string. Now wrap it:
Storage Volume Resource
Key differences:
format(string)target = { format = { type = "qcow2" } }permissions.*target.permissions.*target.backing_store.formatbacking_store = { format = { type = "qcow2" } }<format>element.capacitycapacity+ optionalcapacity_unitcapacity_unitunset to keep KiB.allocationallocation+allocation_unit(read-only)path(computed)path, but it mirrorstarget.pathEverything else (name, pool, create/content) behaves exactly like 0.9. Plan/apply will touch
terraform stateautomatically once you update the config.Storage Pool Resource
The generated schema simply fills in additional optional sub-objects (
source.host,source.auth,features, etc.). All attributes that existed in 0.9 keep their names and shapes:target = { path = "/var/lib/libvirt/pools" }works unchanged.target.permissions.*still take strings, not integers.source.device = [{ path = "/dev/sdb" }]keeps the same structure.Unless you opt into the new nested fields you do not need to change existing pool configurations.
Network Resource
modeforward = { mode = "nat" }<forward>element.bridge(string)bridge = { name = "virbr0" }autostartautostartipsips, but nested attr names now snake_case (local_ptr,dhcp.hosts, etc.)portgroup→port_groupinside DHCP hosts.Example conversion:
DHCP ranges/hosts did not change other than automatic snake_case normalisation.
Contributors
v0.9.0Compare Source
⚠️ ⚠️ ⚠️ ⚠️ This version of the provider breaks compatibility ⚠️ ⚠️ ⚠️ ⚠️
Background
When this provider was developed, the idea was to mimic a cloud experience on top of libvirt. Because of this, the schema was done as flat as possible, features were abstracted and some features like disks from remote sources were added as convenience.
The initial users of the provider were usually makers of infrastructure software who needed complex network setups. Lot of code was contributed which added complexity outside of its initial design.
So for long time I wanted to restart the provider under a new design principles where:
I knew 1.0 would never come in the current form.
The new provider
The new provider is based on the new plugin framework. This gives us some room for better diagnostics and better plans.
It makes definitions more verbose, but it also means we can implement any libvirt feature. Defaults work as long as they are defaults in libvirt.
Migration plan
You can find the legacy provider in the v0.8 branch. New releases can be done of 0.8.x versions to add bugfixes, so people who rely on it have a path forward. I'd likely not maintain much of 0.8.x, but I guess many people will help here, as they do today with different PRs.
There is no automated way of migrating the HCL of previous providers, but given that it is documented how the new schema is defined, which was not the case with the previous schema, it should be much easier to drive LLMs to perform a conversion.
You should check the documentation and README, which will give you an idea of the main differences and equivalences, but here is an example of the new schema to get an idea:
Feedback is appreciated. There will be a long journey for people to port and iron all the issues, but it is clear this is the path to go.
Docs: https://registry.terraform.io/providers/dmacvicar/libvirt/latest/docs
v0.8.3Compare Source
Full Changelog: https://github.com/dmacvicar/terraform-provider-libvirt/compare/v0.8.2...v0.8.3
v0.8.2Compare Source
What's Changed
Content sniffing
Upgrade dependencies
Bug fixes
New Contributors
Full Changelog: https://github.com/dmacvicar/terraform-provider-libvirt/compare/v0.8.1...v0.8.2
v0.8.1Compare Source
What's Changed
This release is mostly about fixes for the SSH transport, which was released with many bugs in v0.8.0
Experimental LVM storage pool support
There is a new experimental feature, support for LVM storage pools. I don't use myself this type of pools, so I put together all the contributions and made the code ready for release mostly based on integration tests. Try it and give feedback.
New Contributors
Full Changelog: https://github.com/dmacvicar/terraform-provider-libvirt/compare/v0.8.0...v0.8.1
v0.8.0Compare Source
What's Changed
Two big features include improved ssh config support (for example for supporting jump hosts) and a new data source for host information.
Breaking changes
Other highlights:
Community
We activated discussions, so that the community can share useful files, help each other and also get announcements.
Contributors
Thanks to all the community for their contributions and for supporting other users:
Full Changelog: https://github.com/dmacvicar/terraform-provider-libvirt/compare/v0.7.6...v0.8.0
Configuration
📅 Schedule: (UTC)
🚦 Automerge: Disabled by config. Please merge this manually once you are satisfied.
♻ Rebasing: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox.
🔕 Ignore: Close this PR and you won't be reminded about this update again.
This PR has been generated by Mend Renovate.
View command line instructions
Checkout
From your project repository, check out a new branch and test the changes.