From af95c03965e867e93c5856e6ecc04729520cce86 Mon Sep 17 00:00:00 2001 From: Payback159 Date: Thu, 16 May 2024 21:34:51 +0200 Subject: [PATCH] move pull required check out of loop --- roles/download/tasks/main.yml | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/roles/download/tasks/main.yml b/roles/download/tasks/main.yml index 94e2fd1f19c..5caad72fd51 100644 --- a/roles/download/tasks/main.yml +++ b/roles/download/tasks/main.yml @@ -18,7 +18,7 @@ # The image_info_command depends on the Container Runtime and will output something like the following: # nginx:1.15,gcr.io/google-containers/kube-proxy:v1.14.1,gcr.io/google-containers/kube-proxy@sha256:44af2833c6cbd9a7fc2e9d2f5244a39dfd2e31ad91bf9d4b7d810678db738ee9,gcr.io/google-containers/kube-apiserver:v1.14.1,etc... -- name: Download | Generate a list of information about the images on a node # noqa command-instead-of-shell - image_info_command contains a pipe, therefore requiring shell +- name: Download | Generate a list of information about the images on a node # noqa command-instead-of-shell - image_info_command contains a pipe, therefore requiring shell shell: "{{ image_info_command }}" register: node_images changed_when: false @@ -30,20 +30,20 @@ msg: "{{ node_images.stdout }}" when: not download_always_pull -#convert all items in downloads which have the key container set to true -#and check if the container exists in node_images.stdout.split(',') +# convert all items in downloads which have the key container set to true +# and check if the container exists in node_images.stdout.split(',') # if yes, set the enabled key to false -#TODO: Some images are not cached on all nodes, which leads to repeated downloads... I still don't know why this is the case. -#TODO: Adapt to also support pull by sha256 +# TODO: Some images are not cached on all nodes, which leads to repeated downloads... I still don't know why this is the case. +# TODO: Adapt to also support pull by sha256 - name: Download | Check if the container image is already present set_fact: downloads: "{{ downloads | combine({item.key: item.value | combine({'enabled': false})}) }}" loop: "{{ downloads | dict2items }}" when: - not download_always_pull - - item.value.container is defined and item.value.container | bool == true + - item.value.container is defined and item.value.container - item.value.repo + ':' + item.value.tag in node_images.stdout.split(',') - #- or item.value.repo + '@sha256:' + item.value.sha256 in node_images.stdout.split(',') + # - or item.value.repo + '@sha256:' + item.value.sha256 in node_images.stdout.split(',') tags: - download - upload