|
1 | 1 | --- |
2 | 2 | - include_tasks: autodetect.yml |
3 | 3 | # We need to know the engine and emulator if we're creating any new VMs. |
4 | | - when: "libvirt_vms | rejectattr('state', 'eq', 'absent')" |
| 4 | + when: libvirt_vms | rejectattr('state', 'eq', 'absent') | list |
5 | 5 |
|
6 | 6 | - include_tasks: volumes.yml |
7 | 7 | vars: |
8 | | - libvirt_vm_volumes: "{{ vm.volumes | default([]) }}" |
| 8 | + volumes: "{{ vm.volumes | default([], true) }}" |
9 | 9 | with_items: "{{ libvirt_vms }}" |
10 | 10 | loop_control: |
11 | 11 | loop_var: vm |
12 | | - when: (vm.state | default('present')) == 'present' |
| 12 | + when: (vm.state | default('present', true)) == 'present' |
13 | 13 |
|
14 | 14 | - include_tasks: vm.yml |
15 | 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 }}" |
| 16 | + console_log_path: "{{ vm.console_log_path | default(libvirt_vm_default_console_log_dir + '/' + vm.name + 'console.log', true) }}" |
18 | 17 | machine_default: "{{ none if libvirt_vm_engine == 'kvm' else 'pc-1.0' }}" |
19 | | - libvirt_vm_machine: "{{ vm.machine | default(machine_default) }}" |
| 18 | + machine: "{{ vm.machine | default(machine_default, true) }}" |
20 | 19 | 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([]) }}" |
| 20 | + cpu_mode: "{{ vm.cpu_mode | default(cpu_mode_default, true) }}" |
| 21 | + volumes: "{{ vm.volumes | default([], true) }}" |
| 22 | + interfaces: "{{ vm.interfaces | default([], true) }}" |
24 | 23 | with_items: "{{ libvirt_vms }}" |
25 | 24 | loop_control: |
26 | 25 | loop_var: vm |
27 | | - when: (vm.state | default('present')) == 'present' |
| 26 | + when: (vm.state | default('present', true)) == 'present' |
28 | 27 |
|
29 | 28 | - include_tasks: destroy-volumes.yml |
30 | 29 | vars: |
31 | | - libvirt_vm_volumes: "{{ vm.volumes | default([]) }}" |
| 30 | + volumes: "{{ vm.volumes | default([], true) }}" |
32 | 31 | with_items: "{{ libvirt_vms }}" |
33 | 32 | loop_control: |
34 | 33 | loop_var: vm |
35 | | - when: (vm.state | default('present')) == 'absent' |
| 34 | + when: (vm.state | default('present', true)) == 'absent' |
36 | 35 |
|
37 | 36 | - include_tasks: destroy-vm.yml |
38 | | - vars: |
39 | | - libvirt_vm_name: "{{ vm.name }}" |
40 | 37 | with_items: "{{ libvirt_vms }}" |
41 | 38 | loop_control: |
42 | 39 | loop_var: vm |
43 | | - when: (vm.state | default('present')) == 'absent' |
| 40 | + when: (vm.state | default('present', true)) == 'absent' |
0 commit comments