Fix conditional on ansible_vault_in_place_copy

When ansible_vault_in_place_copy is supploed as extra var it is
not always treated a False properly, still messing up with conditions

Using bool filter help to eliminate such behaviour.

Also reduce verbosity of blockinfile loop by using loop label.

Change-Id: Iafaf53c77288d8f45b0bf0ddd99fe242a9f6e7cb
This commit is contained in:
Dmitriy Rabotyagov
2025-04-22 16:22:08 +02:00
parent 6a600eb981
commit 2714b4fe1a

View File

@@ -76,7 +76,7 @@
when:
- _secrets is defined
- _secrets | length > 0
- ansible_vault_in_place_copy
- ansible_vault_in_place_copy | bool
- name: Place encrypted secrets in independent blocks
ansible.builtin.blockinfile:
@@ -85,10 +85,12 @@
marker: "# {mark} ANSIBLE MANAGED {{ item.item['key'] }}"
mode: "0600"
loop: "{{ new_secrets.results }}"
loop_control:
label: "{{ item.item['key'] }}"
when:
- _secrets is defined
- _secrets | length > 0
- not ansible_vault_in_place_copy
- not ansible_vault_in_place_copy | bool
- name: Undefine the secrets variable
ansible.builtin.set_fact: