Skip to content

Commit 497acd1

Browse files
authored
Merge pull request #59 from raspbeguy/uuid
add UUID options
2 parents 11d6724 + fc62319 commit 497acd1

File tree

3 files changed

+19
-0
lines changed

3 files changed

+19
-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.

defaults/main.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,10 @@
44
# file path is not given.
55
libvirt_vm_default_console_log_dir: "/var/log/libvirt-consoles/"
66

7+
# Whether UUID should be calculated by hashing the VM name. If not, the UUID is
8+
# randomly generated by libvirt when the VM is defined.
9+
libvirt_vm_default_uuid_deterministic: False
10+
711
# The default location for libvirt images
812
libvirt_volume_default_images_path: '/var/lib/libvirt/images'
913

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 | bool) or (vm.uuid_deterministic is defined and (vm.uuid_deterministic | bool)) %}
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)