Skip to content

add UUID options #59

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Jul 2, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,10 @@ Role Variables
VM console logs, if a VM-specific log file path is not given. Default is
"/var/log/libvirt/qemu/".

- `libvirt_vm_default_uuid_deterministic`: Whether UUID should be calculated by
hashing the VM name. If not, the UUID is randomly generated by libvirt when
the VM is defined. Default is False.

- `libvirt_vm_image_cache_path`: The directory in which to cache downloaded
images. Default is "/tmp/".

Expand Down Expand Up @@ -64,6 +68,12 @@ Role Variables

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

- `uuid`: the UUID to manually assign to the VM. If specified, neither
`uuid_deterministic` nor `libvirt_vm_default_uuid_deterministic` are used.

- `uuid_deterministic`: overrides default set in
`libvirt_vm_default_uuid_deterministic`

- `memory_mb`: the memory to assign to the VM, in megabytes.

- `vcpus`: the number of VCPU cores to assign to the VM.
Expand Down
4 changes: 4 additions & 0 deletions defaults/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@
# file path is not given.
libvirt_vm_default_console_log_dir: "/var/log/libvirt-consoles/"

# Whether UUID should be calculated by hashing the VM name. If not, the UUID is
# randomly generated by libvirt when the VM is defined.
libvirt_vm_default_uuid_deterministic: False

# The default location for libvirt images
libvirt_volume_default_images_path: '/var/lib/libvirt/images'

Expand Down
5 changes: 5 additions & 0 deletions templates/vm.xml.j2
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
<domain type='{{ libvirt_vm_engine }}'>
<name>{{ vm.name }}</name>
{% if vm.uuid is defined %}
<uuid>{{ vm.uuid }}</uuid>
{% elif (libvirt_vm_default_uuid_deterministic | bool) or (vm.uuid_deterministic is defined and (vm.uuid_deterministic | bool)) %}
<uuid>{{ vm.name | to_uuid }}</uuid>
{% endif %}
<memory>{{ vm.memory_mb | int * 1024 }}</memory>
<vcpu>{{ vm.vcpus }}</vcpu>
{% if vm.clock_offset |default( libvirt_vm_clock_offset ) %}
Expand Down