From 172407656392e9521d834cd6241d2689062e5a52 Mon Sep 17 00:00:00 2001 From: Wallysson Silva Date: Thu, 3 Apr 2025 15:10:28 -0300 Subject: [PATCH] Move gen_images_archive_debian.yaml to prestage role This commit moves the gen_images_archive_debian.yaml content to the main.yaml task of prestage-images prestage role. Test Plan: - PASS: upload the prestage images files and perform dcmanager subcloud prestage Story: 2011149 Task: 51816 Signed-off-by: Wallysson Silva Change-Id: I79409f701494d6d195e9b4ac5f7d1bdd190f1e5f --- .../tasks/gen_images_archive_debian.yml | 75 ------------------- .../prestage/prestage-images/tasks/main.yml | 69 ++++++++++++++++- 2 files changed, 66 insertions(+), 78 deletions(-) delete mode 100644 playbookconfig/src/playbooks/roles/prestage/prestage-images/tasks/gen_images_archive_debian.yml diff --git a/playbookconfig/src/playbooks/roles/prestage/prestage-images/tasks/gen_images_archive_debian.yml b/playbookconfig/src/playbooks/roles/prestage/prestage-images/tasks/gen_images_archive_debian.yml deleted file mode 100644 index 4c087822b..000000000 --- a/playbookconfig/src/playbooks/roles/prestage/prestage-images/tasks/gen_images_archive_debian.yml +++ /dev/null @@ -1,75 +0,0 @@ ---- -# -# Copyright (c) 2023, 2025 Wind River Systems, Inc. -# -# SPDX-License-Identifier: Apache-2.0 -# -# TASKS DESCRIPTION: -# These task performs the following: -# - download images in the images list if specified and push them to the -# local registry. -# - archive the snapshot of the registry filesystem and save it in the -# prestage directory. -# - remove downloaded images from the local registry if the subcloud is -# running software version older than 22.12 (Debian) -# - -- block: - - block: - # The following task will generate the docker_registries dictionary used for images download - - name: Retrieve the configured docker registries - import_tasks: get_docker_registries.yml - - - name: Log in the docker registries that are authenticated - docker_login: - registry: "{{ item.value.url }}" - username: "{{ item.value.username }}" - password: "{{ item.value.password }}" - register: login_result - retries: 10 - delay: 5 - until: login_result is succeeded - loop: "{{ docker_registries|dict2items }}" - when: item.value.username is defined - no_log: true - - - name: Set prestage environment variables - set_fact: - prestage_env: - REGISTRIES: "{{ docker_registries | to_json }}" - PRESTAGE_DOWNLOAD: yes - - - name: Download container images for prestage - script: > - roles/common/push-docker-images/files/download_images.py - "{{ image_list | unique | join(',') }}" - register: download_images_output - retries: "{{ download_retries | default(10) }}" - delay: "{{ retry_delay | default(5) }}" - until: (download_images_output.rc == 0 or "HARD FAIL" in download_images_output.stdout) - failed_when: download_images_output.rc != 0 - environment: "{{ prestage_env }}" - - - debug: var=download_images_output.stdout_lines - - - name: Log out of the authenticated registries - docker_login: - registry: "{{ item.value.url }}" - state: absent - loop: "{{ docker_registries|dict2items }}" - when: item.value.username is defined - no_log: true - - when: image_list - - - name: Take a snapshot of the local registry filesystem - import_role: - name: common/generate-registry-filesystem-archive - vars: - registry_archive_fqpn: "{{ prestage_dir }}/local_registry_filesystem.tgz" - when: prestage_reason == 'for_install' - - always: - - name: Clear docker cache - command: docker image prune -af - failed_when: false diff --git a/playbookconfig/src/playbooks/roles/prestage/prestage-images/tasks/main.yml b/playbookconfig/src/playbooks/roles/prestage/prestage-images/tasks/main.yml index 79df51844..4eb810926 100644 --- a/playbookconfig/src/playbooks/roles/prestage/prestage-images/tasks/main.yml +++ b/playbookconfig/src/playbooks/roles/prestage/prestage-images/tasks/main.yml @@ -5,7 +5,70 @@ # SPDX-License-Identifier: Apache-2.0 # # ROLE DESCRIPTION: -# This role generates container images archive file(s). +# These task performs the following: +# - download images in the images list if specified and push them to the +# local registry. +# - archive the snapshot of the registry filesystem and save it in the +# prestage directory. +# - remove downloaded images from the local registry if the subcloud is +# running software version older than 22.12 (Debian) -- name: Archive container images (Debian) - include_tasks: gen_images_archive_debian.yml +- block: + - block: + # The following task will generate the docker_registries dictionary used for images download + - name: Retrieve the configured docker registries + import_tasks: get_docker_registries.yml + + - name: Log in the docker registries that are authenticated + docker_login: + registry: "{{ item.value.url }}" + username: "{{ item.value.username }}" + password: "{{ item.value.password }}" + register: login_result + retries: 10 + delay: 5 + until: login_result is succeeded + loop: "{{ docker_registries|dict2items }}" + when: item.value.username is defined + no_log: true + + - name: Set prestage environment variables + set_fact: + prestage_env: + REGISTRIES: "{{ docker_registries | to_json }}" + PRESTAGE_DOWNLOAD: yes + + - name: Download container images for prestage + script: > + roles/common/push-docker-images/files/download_images.py + "{{ image_list | unique | join(',') }}" + register: download_images_output + retries: "{{ download_retries | default(10) }}" + delay: "{{ retry_delay | default(5) }}" + until: (download_images_output.rc == 0 or "HARD FAIL" in download_images_output.stdout) + failed_when: download_images_output.rc != 0 + environment: "{{ prestage_env }}" + + - debug: var=download_images_output.stdout_lines + + - name: Log out of the authenticated registries + docker_login: + registry: "{{ item.value.url }}" + state: absent + loop: "{{ docker_registries|dict2items }}" + when: item.value.username is defined + no_log: true + + when: image_list + + - name: Take a snapshot of the local registry filesystem + import_role: + name: common/generate-registry-filesystem-archive + vars: + registry_archive_fqpn: "{{ prestage_dir }}/local_registry_filesystem.tgz" + when: prestage_reason == 'for_install' + + always: + - name: Clear docker cache + command: docker image prune -af + failed_when: false