From e7a09fc0a468f7072bd068ea0f80d101263f9acf Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?R=C3=A9mi=20-=20Le=20Filament?= <remi@le-filament.com>
Date: Mon, 17 Oct 2022 10:52:56 +0200
Subject: [PATCH] [FIX] some modules do not loop through list

---
 tasks/main.yml | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)

diff --git a/tasks/main.yml b/tasks/main.yml
index 4ece322..af23077 100644
--- a/tasks/main.yml
+++ b/tasks/main.yml
@@ -2,7 +2,7 @@
 - name: Include OS-specific variables.
   include_vars: "{{ ansible_os_family }}.yml"
 
-- name: Correct the machine hostname to "{{ inventory_hostname_short }}"
+- name: Set machine hostname
   hostname: name="{{ inventory_hostname_short | lower | regex_replace('_','') }}"
 
 - name: Debian Update repo and upgrade installed packages
@@ -42,15 +42,17 @@
 
 - name: Remove unecessary files if present
   file:
-    path: "{{ files_to_remove }}"
+    path: "{{ item }}"
     state: absent
   when: ansible_os_family == "Debian"
+  with_items: "{{ files_to_remove }}"
 
 - name: Remove unecessary users if present
   user:
-    name: "{{ users_to_remove }}"
+    name: "{{ item }}"
     remove: true
     state: absent
+  with_items: "{{ users_to_remove }}"
 
 - name: disable dynamic motd news
   lineinfile:
-- 
GitLab