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 <wallysson.silva@windriver.com>
Change-Id: I79409f701494d6d195e9b4ac5f7d1bdd190f1e5f
This commit is contained in:
Wallysson Silva 2025-04-03 15:10:28 -03:00
parent 4edd6edfb4
commit 1724076563
2 changed files with 66 additions and 78 deletions

View File

@ -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

View File

@ -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