Skip to content

Commit f32a8d3

Browse files
authored
Merge pull request #21 from JPvRiel/master
Custom xml domain definition file and disk device start at vda
2 parents 17d8100 + d33251e commit f32a8d3

File tree

4 files changed

+8
-4
lines changed

4 files changed

+8
-4
lines changed

README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ Role Variables
2727

2828
- `libvirt_vm_arch`: CPU architecture, default is `x86_64`.
2929

30-
- `libvirt_vm_uri`: Override the libvirt connection URI. See the
30+
- `libvirt_vm_uri`: Override the libvirt connection URI. See the
3131
[libvirt docs](https://libvirt.org/remote.html) docs for more details.
3232

3333
- `libvirt_vm_virsh_default_env`: Variables contained within this dictionary are
@@ -100,6 +100,7 @@ Role Variables
100100
- `autostart`: Whether to start the VM when the host starts up. Default is
101101
`true`.
102102

103+
- `xml_template`: Optionally supply a modified XML template. Base customisation off the default `vm.xml.j2` template so as to include the expected jinja expressions the role uses.
103104

104105
N.B. the following variables are deprecated: `libvirt_vm_state`,
105106
`libvirt_vm_name`, `libvirt_vm_memory_mb`, `libvirt_vm_vcpus`,

defaults/main.yml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,10 +61,13 @@ libvirt_vms:
6161
# Path to console log file.
6262
console_log_path: "{{ libvirt_vm_console_log_path }}"
6363

64+
# XML template file to source domain definition
65+
xml_file: vm.xml.j2
66+
6467
# Variables to add to the enviroment that is used to execute virsh commands
6568
libvirt_vm_virsh_default_env: "{{ { 'LIBVIRT_DEFAULT_URI': libvirt_vm_uri } if libvirt_vm_uri else {} }}"
6669

67-
# Override for the libvirt connection uri. Leave unset to use the default.
70+
# Override for the libvirt connection uri. Leave unset to use the default.
6871
libvirt_vm_uri: ""
6972

7073
### DEPRECATED ###

tasks/vm.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
virt:
2121
name: "{{ vm.name }}"
2222
command: define
23-
xml: "{{ lookup('template', 'vm.xml.j2') }}"
23+
xml: "{{ lookup('template', vm.xml_file | default('vm.xml.j2')) }}"
2424
uri: "{{ libvirt_vm_uri | default(omit, true) }}"
2525
become: true
2626

templates/vm.xml.j2

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
<disk type='volume' device='{{ volume.device | default(libvirt_volume_default_device) }}'>
2323
<driver name='qemu' type='{{ volume.format | default(libvirt_volume_default_format) }}'/>
2424
<source pool='{{ volume.pool }}' volume='{{ volume.name }}'/>
25-
<target dev='vd{{ 'abcdefghijklmnopqrstuvwxyz'[loop.index] }}'/>
25+
<target dev='vd{{ 'abcdefghijklmnopqrstuvwxyz'[loop.index - 1] }}'/>
2626
</disk>
2727
{% endfor %}
2828
{% for interface in interfaces %}

0 commit comments

Comments
 (0)