Skip to content

Commit e90b854

Browse files
author
Will Miller
committed
Set VM attribute defaults in main.yml
1 parent 2156bd3 commit e90b854

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

tasks/main.yml

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,24 +4,39 @@
44
when: "libvirt_vms | rejectattr('state', 'eq', 'absent')"
55

66
- include_tasks: volumes.yml
7+
vars:
8+
libvirt_vm_volumes: "{{ vm.volumes | default([]) }}"
79
with_items: "{{ libvirt_vms }}"
810
loop_control:
911
loop_var: vm
1012
when: (vm.state | default('present')) == 'present'
1113

1214
- include_tasks: vm.yml
15+
vars:
16+
libvirt_vm_console_log_path: "{{ vm.console_log_path | default(libvirt_vm_default_console_log_dir + '/' + vm.name + 'console.log') }}"
17+
libvirt_vm_name: "{{ vm.name }}"
18+
machine_default: "{{ none if libvirt_vm_engine == 'kvm' else 'pc-1.0' }}"
19+
libvirt_vm_machine: "{{ vm.machine | default(machine_default) }}"
20+
cpu_mode_default: "{{ 'host-passthrough' if libvirt_vm_engine == 'kvm' else 'host-model' }}"
21+
libvirt_vm_cpu_mode: "{{ vm.cpu_mode | default(cpu_mode_default) }}"
22+
libvirt_vm_volumes: "{{ vm.volumes | default([]) }}"
23+
libvirt_vm_interfaces: "{{ vm.interfaces | default([]) }}"
1324
with_items: "{{ libvirt_vms }}"
1425
loop_control:
1526
loop_var: vm
1627
when: (vm.state | default('present')) == 'present'
1728

1829
- include_tasks: destroy-volumes.yml
30+
vars:
31+
libvirt_vm_volumes: "{{ vm.volumes | default([]) }}"
1932
with_items: "{{ libvirt_vms }}"
2033
loop_control:
2134
loop_var: vm
2235
when: (vm.state | default('present')) == 'absent'
2336

2437
- include_tasks: destroy-vm.yml
38+
vars:
39+
libvirt_vm_name: "{{ vm.name }}"
2540
with_items: "{{ libvirt_vms }}"
2641
loop_control:
2742
loop_var: vm

0 commit comments

Comments
 (0)