From d870a3ee4e0facc5e3e60b60eccac6959115427e Mon Sep 17 00:00:00 2001
From: Max Gautier <mg@max.gautier.name>
Date: Mon, 13 May 2024 10:14:30 +0000
Subject: [PATCH] Avoid potential loop_var shadowing (#11162)

With CentOS, kubespray currently produces the following warning:

[WARNING]: TASK: bootstrap-os : Enable Oracle Linux repo: The loop variable
'item' is already in use. You should set the `loop_var` value in the
`loop_control` option for the task to something else to avoid variable
collisions and unexpected behavior.

This could bites us in nasty ways, so fix it.
---
 roles/bootstrap-os/tasks/main.yml | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/roles/bootstrap-os/tasks/main.yml b/roles/bootstrap-os/tasks/main.yml
index d1e5f7371..b8f676fae 100644
--- a/roles/bootstrap-os/tasks/main.yml
+++ b/roles/bootstrap-os/tasks/main.yml
@@ -24,10 +24,12 @@
       - vars/
       skip: True
   - name: Include tasks
-    include_tasks: "{{ item }}"
+    include_tasks: "{{ included_tasks_file }}"
     with_first_found:
     - <<: *search
       paths: []
+    loop_control:
+      loop_var: included_tasks_file
 
 
 - name: Create remote_tmp for it is used by another module
-- 
GitLab