Set backup paths automatically only if not already set

This commit is contained in:
Kuba Orlik 2025-09-12 23:56:23 +02:00
parent eac505346b
commit 1622fae1a0

View File

@ -4,6 +4,7 @@
- set_fact: - set_fact:
all_backup_paths: "{{ all_backup_paths | default([]) + (lookup('file', 'inventory/group_vars/' + item + '.yml') | from_yaml | dict2items | selectattr('key', 'equalto', 'backup_paths') | map(attribute='value') | list | first | default([])) }}" all_backup_paths: "{{ all_backup_paths | default([]) + (lookup('file', 'inventory/group_vars/' + item + '.yml') | from_yaml | dict2items | selectattr('key', 'equalto', 'backup_paths') | map(attribute='value') | list | first | default([])) }}"
loop: "{{ group_names }}" loop: "{{ group_names }}"
when: all_backup_paths is not defined
- debug: - debug:
var: all_backup_paths var: all_backup_paths