Skip to content

Commit e91af31

Browse files
author
Will Miller
committed
Fix detection of all absent VMs
`rejectattr` fails if the attribute is not set, and no default option is available. Alter the logic to ensure that if `state` is unset, it is treated as `present`.
1 parent d676ee4 commit e91af31

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

tasks/main.yml

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,10 @@
11
---
22
- include_tasks: autodetect.yml
3-
# We need to know the engine and emulator if we're creating any new VMs.
4-
when: libvirt_vms | rejectattr('state', 'eq', 'absent') | list
3+
# We don't need to know the engine and emulator if we're not creating any new
4+
# VMs.
5+
when: >-
6+
(libvirt_vms | selectattr('state', 'defined')
7+
| selectattr('state', 'eq', 'absent') | list) != libvirt_vms
58
69
- include_tasks: volumes.yml
710
vars:

0 commit comments

Comments
 (0)