Skip to content

Commit d44fd9c

Browse files
committed
Add possibility to give UUID
1 parent 11d6724 commit d44fd9c

File tree

2 files changed

+15
-0
lines changed

2 files changed

+15
-0
lines changed

README.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,10 @@ Role Variables
1616
VM console logs, if a VM-specific log file path is not given. Default is
1717
"/var/log/libvirt/qemu/".
1818

19+
- `libvirt_vm_default_uuid_deterministic`: Whether UUID should be calculated by
20+
hashing the VM name. If not, the UUID is randomly generated by libvirt when
21+
the VM is defined. Default is False.
22+
1923
- `libvirt_vm_image_cache_path`: The directory in which to cache downloaded
2024
images. Default is "/tmp/".
2125

@@ -64,6 +68,12 @@ Role Variables
6468

6569
- `name`: the name to assign to the VM.
6670

71+
- `uuid`: the UUID to manually assign to the VM. If specified, neither
72+
`uuid_deterministic` nor `libvirt_vm_default_uuid_deterministic` are used.
73+
74+
- `uuid_deterministic`: overrides default set in
75+
`libvirt_vm_default_uuid_deterministic`
76+
6777
- `memory_mb`: the memory to assign to the VM, in megabytes.
6878

6979
- `vcpus`: the number of VCPU cores to assign to the VM.

templates/vm.xml.j2

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
11
<domain type='{{ libvirt_vm_engine }}'>
22
<name>{{ vm.name }}</name>
3+
{% if vm.uuid is defined %}
4+
<uuid>{{ vm.uuid }}</uuid>
5+
{% elif libvirt_vm_default_uuid_deterministic is sameas true or (vm.uuid_deterministic is defined and vm.uuid_deterministic is sameas true %}
6+
<uuid>{{ vm.name | to_uuid }}</uuid>
7+
{% endif %}
38
<memory>{{ vm.memory_mb | int * 1024 }}</memory>
49
<vcpu>{{ vm.vcpus }}</vcpu>
510
{% if vm.clock_offset |default( libvirt_vm_clock_offset ) %}

0 commit comments

Comments
 (0)