summaryrefslogtreecommitdiff
path: root/roles/vm/guest
diff options
context:
space:
mode:
Diffstat (limited to 'roles/vm/guest')
-rw-r--r--roles/vm/guest/define/templates/libvirt-domain.xml.j24
-rw-r--r--roles/vm/guest/install/tasks/main.yml2
2 files changed, 4 insertions, 2 deletions
diff --git a/roles/vm/guest/define/templates/libvirt-domain.xml.j2 b/roles/vm/guest/define/templates/libvirt-domain.xml.j2
index 0430229b..11b1be6e 100644
--- a/roles/vm/guest/define/templates/libvirt-domain.xml.j2
+++ b/roles/vm/guest/define/templates/libvirt-domain.xml.j2
@@ -56,7 +56,7 @@
{% endif %}
{% for bus in ['virtio', 'scsi'] %}
{% for device, src in (install.disks[bus] | default({})).items() %}
- <disk type='block' device='disk'>
+ <disk type='{{ (src.type == 'image') | ternary('file', 'block') }}' device='disk'>
<driver name='qemu' type='raw' cache='none' discard='unmap'/>
{% if src.type == 'lvm' %}
<source dev='/dev/mapper/{{ src.vg | replace('-', '--') }}-{{ src.lv | replace('-', '--') }}'/>
@@ -64,6 +64,8 @@
<source dev='/dev/zvol/{{ vm_host.zfs[src.backend | default('default')].pool }}/{{ vm_host.zfs[src.backend | default('default')].name }}/{{ inventory_hostname }}/{{ src.name }}'/>
{% elif src.type == 'blockdev' %}
<source dev='{{ src.path }}'/>
+{% elif src.type == 'image' %}
+ <source file='{{ src.path }}'/>
{% endif %}
<target dev='{{ device }}' bus='{{ bus }}'/>
</disk>
diff --git a/roles/vm/guest/install/tasks/main.yml b/roles/vm/guest/install/tasks/main.yml
index f2bd5362..d4a31929 100644
--- a/roles/vm/guest/install/tasks/main.yml
+++ b/roles/vm/guest/install/tasks/main.yml
@@ -10,7 +10,7 @@
size: "{{ item.value.size }}"
state: present
-- name: create zfs base datasets for vm
+- name: create zfs-based datasets for vm
loop: "{{ install.disks.virtio | default({}) | combine(install.disks.scsi | default({})) | dict2items | selectattr('value.type', 'eq', 'zfs') | map(attribute='value.backend') | map('default', 'default') | unique | list }}"
delegate_to: "{{ vm_host.name }}"
zfs: