From 0cbb6f38bffc0987a63e11838c8c90c73dd93dc4 Mon Sep 17 00:00:00 2001 From: Max Gautier Date: Thu, 24 Sep 2026 09:00:21 +0000 Subject: [PATCH] downloads: pre-filter the loop instead of using when (#13563) This prevent evaluation of the whole item even if not used, and the tasks scheduling of skipped tasks. Preventing evaluation in particular helps avoiding irrelevant errors, like when an unused downloads member has undefined members. --- roles/download/tasks/main.yml | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/roles/download/tasks/main.yml b/roles/download/tasks/main.yml index 9139d009b..d3b20dd10 100644 --- a/roles/download/tasks/main.yml +++ b/roles/download/tasks/main.yml @@ -18,13 +18,15 @@ - name: Download | Download files / images include_tasks: "{{ include_file }}" - loop: "{{ downloads | combine(kubeadm_images) | dict2items }}" + loop: "{{ [] if skip_downloads + else ( + (downloads | combine(kubeadm_images)).values() + | selectattr('enabled') + ) + }}" vars: - download: "{{ download_defaults | combine(item.value) }}" + download: "{{ download_defaults | combine(item) }}" include_file: "download_{% if download.container %}container{% else %}file{% endif %}.yml" when: - - not skip_downloads - - download.enabled - - item.value.enabled - (not download.container) or (download.container and download_container) - (download_run_once and inventory_hostname == download_delegate) or (group_names | intersect(download.groups) != [])