Skip to content

Commit 97614a0

Browse files
committed
Fix boolean conditionals in when clauses for Ansible 2.19+ compatibility
Ansible 2.19 enforces that all 'when' conditions must evaluate to an explicit boolean. Bare string values (e.g. non-empty cert content) are truthy but not boolean, causing the error: 'Conditional result (True) was derived from value of type str. Conditionals must have a boolean result.' Replace bare .content attribute checks with '| length > 0' in three tasks: - Copy Libvirt TLS certificates and keys - Copy QEMU TLS certificates and keys - Copy Libvirt VNC TLS certificates and keys Ref: https://docs.ansible.com/ansible/latest/playbook_guide/playbooks_conditionals.html
1 parent 23f69e4 commit 97614a0

1 file changed

Lines changed: 3 additions & 3 deletions

File tree

tasks/config.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@
111111
loop: "{{ _libvirt_tls_certs.keys() }}"
112112
when:
113113
- libvirt_host_tls_listen | bool
114-
- _libvirt_loop_item.content
114+
- _libvirt_loop_item.content | length > 0
115115
vars:
116116
_libvirt_loop_item: "{{ _libvirt_tls_certs[item] }}"
117117
notify: restart libvirt
@@ -159,7 +159,7 @@
159159
loop: "{{ _libvirt_host_qemu_tls_certs.keys() }}"
160160
when:
161161
- libvirt_host_qemu_tls_enabled | bool
162-
- _libvirt_host_qemu_loop_item.content
162+
- _libvirt_host_qemu_loop_item.content | length > 0
163163
vars:
164164
_libvirt_host_qemu_loop_item: "{{ _libvirt_host_qemu_tls_certs[item] }}"
165165
notify: restart libvirt
@@ -194,7 +194,7 @@
194194
loop: "{{ _libvirt_host_vnc_tls_certs.keys() }}"
195195
when:
196196
- libvirt_host_vnc_tls_enabled | bool
197-
- _libvirt_host_vnc_loop_item.content
197+
- _libvirt_host_vnc_loop_item.content | length > 0
198198
vars:
199199
_libvirt_host_vnc_loop_item: "{{ _libvirt_host_vnc_tls_certs[item] }}"
200200
notify: restart libvirt

0 commit comments

Comments
 (0)