From 6479e26904c0eb34780d094b598d01ecbc5f026f Mon Sep 17 00:00:00 2001
From: Florian Ruynat <16313165+floryut@users.noreply.github.com>
Date: Mon, 5 Apr 2021 22:45:19 +0200
Subject: [PATCH] Replace deprecated 'with_dict' with 'loop' (#7442)

---
 roles/download/tasks/main.yml                 |  2 +-
 .../preinstall/tasks/0090-etchosts.yml        |  4 ++--
 .../roles/kubevirt-images/tasks/main.yml      | 21 +++++++------------
 3 files changed, 10 insertions(+), 17 deletions(-)

diff --git a/roles/download/tasks/main.yml b/roles/download/tasks/main.yml
index 394228354..e20945af3 100644
--- a/roles/download/tasks/main.yml
+++ b/roles/download/tasks/main.yml
@@ -25,7 +25,7 @@
 
 - name: download | Download files / images
   include_tasks: "{{ include_file }}"
-  with_dict: "{{ downloads | combine(kubeadm_images) }}"
+  loop: "{{ downloads | combine(kubeadm_images) | dict2items }}"
   vars:
     download: "{{ download_defaults | combine(item.value) }}"
     include_file: "download_{% if download.container %}container{% else %}file{% endif %}.yml"
diff --git a/roles/kubernetes/preinstall/tasks/0090-etchosts.yml b/roles/kubernetes/preinstall/tasks/0090-etchosts.yml
index 81913cb10..491d24a6a 100644
--- a/roles/kubernetes/preinstall/tasks/0090-etchosts.yml
+++ b/roles/kubernetes/preinstall/tasks/0090-etchosts.yml
@@ -56,7 +56,7 @@
     etc_hosts_localhosts_dict_target: >-
       {%- set target_entries = (etc_hosts_localhosts_dict|default({})).get(item.key, []) | difference(item.value.get('unexpected' ,[])) -%}
       {{ etc_hosts_localhosts_dict_target|default({}) | combine({item.key: (target_entries + item.value.expected)|unique}) }}
-  with_dict: "{{ etc_hosts_localhost_entries }}"
+  loop: "{{ etc_hosts_localhost_entries|dict2items }}"
 
 - name: Hosts | Update (if necessary) hosts file
   lineinfile:
@@ -66,7 +66,7 @@
     state: present
     backup: yes
     unsafe_writes: yes
-  with_dict: "{{ etc_hosts_localhosts_dict_target }}"
+  loop: "{{ etc_hosts_localhosts_dict_target|dict2items }}"
 
 # gather facts to update ansible_fqdn
 - name: Update facts
diff --git a/test-infra/image-builder/roles/kubevirt-images/tasks/main.yml b/test-infra/image-builder/roles/kubevirt-images/tasks/main.yml
index 95ce250a4..e2ef4e8fc 100644
--- a/test-infra/image-builder/roles/kubevirt-images/tasks/main.yml
+++ b/test-infra/image-builder/roles/kubevirt-images/tasks/main.yml
@@ -10,34 +10,29 @@
     url: "{{ item.value.url }}"
     dest: "{{ images_dir }}/{{ item.value.filename }}"
     checksum: "{{ item.value.checksum }}"
-  with_dict:
-    - "{{ images }}"
+  loop: "{{ images|dict2items }}"
 
 - name: Unxz compressed images
   command: unxz --force {{ images_dir }}/{{ item.value.filename }}
-  with_dict:
-    - "{{ images }}"
+  loop: "{{ images|dict2items }}"
   when:
     - item.value.filename.endswith('.xz')
 
 - name: Convert images which is not in qcow2 format
   command: qemu-img convert -O qcow2 {{ images_dir }}/{{ item.value.filename.rstrip('.xz') }} {{ images_dir }}/{{ item.key }}.qcow2
-  with_dict:
-    - "{{ images }}"
+  loop: "{{ images|dict2items }}"
   when:
     - not (item.value.converted|bool)
 
 - name: Make sure all images are ending with qcow2
   command: cp {{ images_dir }}/{{ item.value.filename.rstrip('.xz') }} {{ images_dir }}/{{ item.key }}.qcow2
-  with_dict:
-    - "{{ images }}"
+  loop: "{{ images|dict2items }}"
   when:
     - item.value.converted|bool
 
 - name: Resize images  # noqa 301
   command: qemu-img resize {{ images_dir }}/{{ item.key }}.qcow2 +8G
-  with_dict:
-    - "{{ images }}"
+  loop: "{{ images|dict2items }}"
 
 # STEP 2: Include the images inside a container
 - name: Template default Dockerfile
@@ -47,16 +42,14 @@
 
 - name: Create docker images for each OS  # noqa 301
   command: docker build -t {{ registry }}/vm-{{ item.key }}:{{ item.value.tag }} --build-arg cloud_image="{{ item.key }}.qcow2" {{ images_dir }}
-  with_dict:
-    - "{{ images }}"
+  loop: "{{ images|dict2items }}"
 
 - name: docker login  # noqa 301
   command: docker login -u="{{ docker_user }}" -p="{{ docker_password }}" "{{ docker_host }}"
 
 - name: docker push image  # noqa 301
   command: docker push {{ registry }}/vm-{{ item.key }}:{{ item.value.tag }}
-  with_dict:
-    - "{{ images }}"
+  loop: "{{ images|dict2items }}"
 
 - name: docker logout  # noqa 301
   command: docker logout -u="{{ docker_user }}" "{{ docker_host }}"
-- 
GitLab