download/container: adapt to single key repo+tag -> image_name

This code will be deleted for the rework of the download role, for now
we minimally adapt it to the new structure of downloads.
This commit is contained in:
Max Gautier
2026-09-23 13:18:49 +02:00
parent 164f7fbf40
commit e013507027
4 changed files with 13 additions and 18 deletions
+1 -1
View File
@@ -10,7 +10,7 @@
- name: Check_pull_required | Set pull_required if the desired image is not yet loaded - name: Check_pull_required | Set pull_required if the desired image is not yet loaded
set_fact: set_fact:
pull_required: "{{ (image_reponame | regex_replace('^docker\\.io/(library/)?', '')) not in docker_images.stdout.split(',') }}" pull_required: "{{ (download.image_name | regex_replace('^docker\\.io/(library/)?', '')) not in docker_images.stdout.split(',') }}"
when: not download_always_pull when: not download_always_pull
- name: Check_pull_required | Check that the local digest sha256 corresponds to the given image tag - name: Check_pull_required | Check that the local digest sha256 corresponds to the given image tag
+3 -3
View File
@@ -21,7 +21,7 @@
- not download_always_pull - not download_always_pull
- debug: # noqa name[missing] - debug: # noqa name[missing]
msg: "Pull {{ image_reponame }} required is: {{ pull_required }}" msg: "Pull {{ download.image_name }} required is: {{ pull_required }}"
- name: Download_container | Determine if image is in cache - name: Download_container | Determine if image is in cache
stat: stat:
@@ -49,13 +49,13 @@
- name: Stop if image not in cache on ansible host when download_force_cache=true - name: Stop if image not in cache on ansible host when download_force_cache=true
assert: assert:
that: image_is_cached that: image_is_cached
msg: "Image cache file {{ image_path_cached }} not found for {{ image_reponame }} on localhost" msg: "Image cache file {{ image_path_cached }} not found for {{ download.image_name }} on localhost"
when: when:
- download_force_cache - download_force_cache
- not download_run_once - not download_run_once
- name: Download_container | Download image if required - name: Download_container | Download image if required
command: "{{ image_pull_command_on_localhost if download_localhost else image_pull_command }} {{ image_reponame }}" command: "{{ image_pull_command_on_localhost if download_localhost else image_pull_command }} {{ download.image_name }}"
delegate_to: "{{ download_delegate if download_run_once else inventory_hostname }}" delegate_to: "{{ download_delegate if download_run_once else inventory_hostname }}"
delegate_facts: true delegate_facts: true
run_once: "{{ download_run_once }}" run_once: "{{ download_run_once }}"
+1 -2
View File
@@ -42,8 +42,7 @@
value: value:
enabled: true enabled: true
container: true container: true
repo: "{{ item | regex_replace('^(.*):.*$', '\\1') }}" image_name: "{{ item }}"
tag: "{{ item | regex_replace('^.*:(.*)$', '\\1') }}"
groups: groups:
- k8s_cluster - k8s_cluster
loop: "{{ kubeadm_images_list | flatten(levels=1) }}" loop: "{{ kubeadm_images_list | flatten(levels=1) }}"
+8 -12
View File
@@ -1,8 +1,4 @@
--- ---
- name: Set_container_facts | Display the name of the image being processed
debug:
msg: "{{ download.repo }}"
- name: Set_container_facts | Set if containers should be pulled by digest - name: Set_container_facts | Set if containers should be pulled by digest
set_fact: set_fact:
pull_by_digest: "{{ download.sha256 is defined and download.sha256 }}" pull_by_digest: "{{ download.sha256 is defined and download.sha256 }}"
@@ -14,7 +10,7 @@
- name: Set_container_facts | Define file name of image - name: Set_container_facts | Define file name of image
set_fact: set_fact:
image_filename: "{{ image_reponame | regex_replace('/|\0|:', '_') }}.tar" image_filename: "{{ download.image_name | regex_replace('/|\0|:', '_') }}.tar"
- name: Set_container_facts | Define path of image - name: Set_container_facts | Define path of image
set_fact: set_fact:
@@ -23,33 +19,33 @@
- name: Set image save/load command for docker - name: Set image save/load command for docker
set_fact: set_fact:
image_save_command: "{{ docker_bin_dir }}/docker save {{ image_reponame }} | gzip -{{ download_compress }} > {{ image_path_final }}" image_save_command: "{{ docker_bin_dir }}/docker save {{ download.image_name }} | gzip -{{ download_compress }} > {{ image_path_final }}"
image_load_command: "{{ docker_bin_dir }}/docker load < {{ image_path_final }}" image_load_command: "{{ docker_bin_dir }}/docker load < {{ image_path_final }}"
when: container_manager == 'docker' when: container_manager == 'docker'
- name: Set image save/load command for containerd - name: Set image save/load command for containerd
set_fact: set_fact:
image_save_command: "{{ bin_dir }}/nerdctl -n k8s.io image save -o {{ image_path_final }} {{ image_reponame }}" image_save_command: "{{ bin_dir }}/nerdctl -n k8s.io image save -o {{ image_path_final }} {{ download.image_name }}"
image_load_command: "{{ bin_dir }}/nerdctl -n k8s.io image load < {{ image_path_final }}" image_load_command: "{{ bin_dir }}/nerdctl -n k8s.io image load < {{ image_path_final }}"
when: container_manager == 'containerd' when: container_manager == 'containerd'
- name: Set image save/load command for crio - name: Set image save/load command for crio
set_fact: set_fact:
image_save_command: "{{ bin_dir }}/skopeo copy containers-storage:{{ image_reponame }} docker-archive:{{ image_path_final }} 2>/dev/null" image_save_command: "{{ bin_dir }}/skopeo copy containers-storage:{{ download.image_name }} docker-archive:{{ image_path_final }} 2>/dev/null"
image_load_command: "{{ bin_dir }}/skopeo copy docker-archive:{{ image_path_final }} containers-storage:{{ image_reponame }} 2>/dev/null" image_load_command: "{{ bin_dir }}/skopeo copy docker-archive:{{ image_path_final }} containers-storage:{{ download.image_name }} 2>/dev/null"
when: container_manager == 'crio' when: container_manager == 'crio'
- name: Set image save/load command for docker on localhost - name: Set image save/load command for docker on localhost
set_fact: set_fact:
image_save_command_on_localhost: "{{ docker_bin_dir }}/docker save {{ image_reponame }} | gzip -{{ download_compress }} > {{ image_path_cached }}" image_save_command_on_localhost: "{{ docker_bin_dir }}/docker save {{ download.image_name }} | gzip -{{ download_compress }} > {{ image_path_cached }}"
when: container_manager_on_localhost == 'docker' when: container_manager_on_localhost == 'docker'
- name: Set image save/load command for containerd on localhost - name: Set image save/load command for containerd on localhost
set_fact: set_fact:
image_save_command_on_localhost: "{{ containerd_bin_dir }}/ctr -n k8s.io image export --platform linux/{{ image_arch }} {{ image_path_cached }} {{ image_reponame }}" image_save_command_on_localhost: "{{ containerd_bin_dir }}/ctr -n k8s.io image export --platform linux/{{ image_arch }} {{ image_path_cached }} {{ download.image_name }}"
when: container_manager_on_localhost == 'containerd' when: container_manager_on_localhost == 'containerd'
- name: Set image save/load command for crio on localhost - name: Set image save/load command for crio on localhost
set_fact: set_fact:
image_save_command_on_localhost: "{{ bin_dir }}/skopeo copy containers-storage:{{ image_reponame }} docker-archive:{{ image_path_final }} 2>/dev/null" image_save_command_on_localhost: "{{ bin_dir }}/skopeo copy containers-storage:{{ download.image_name }} docker-archive:{{ image_path_final }} 2>/dev/null"
when: container_manager_on_localhost == 'crio' when: container_manager_on_localhost == 'crio'