v0.9.1 #1235
dmacvicar
announced in
Announcements
v0.9.1
#1235
Replies: 1 comment
-
|
Is there a plan to update the examples to be compatible with v0.9.1, too? e.g. The example at https://github.com/dmacvicar/terraform-provider-libvirt/blob/main/examples/resources/libvirt_domain/resource.tf doesn't work after replacing the qcow2 file with one that exists in my system. When I run |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Bugfixes
VIR_DOMAIN_UNDEFINE_NVRAMandVIR_DOMAIN_UNDEFINE_TPM. These defaults may change in the future and be part of a domain block likecreateanddelete. (UEFI images cannot be destroyed when using nvram #1203 )=for os in domain.md in docs/resources #1209, SIGSEGV when connecting to a hypervisor over qemu+ssh #1210Features
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
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
This discussion was created from the release v0.9.1.
Beta Was this translation helpful? Give feedback.
All reactions