playbookconfig: set default values for offline_img_dir

Set default values for offline_img_dir if it is undefined.

Closes-bug: 1966377

Signed-off-by: Jackie Huang <jackie.huang@windriver.com>
Change-Id: Ifb284c753449864ec9a792fc353d5711ce8ab2df
This commit is contained in:
Jackie Huang 2022-03-25 13:56:02 +08:00
parent e60730e797
commit b48d6097a4

View File

@ -1,4 +1,4 @@
From 0517a60784b1b4833f2ada90fa78f2a2e3d17e6a Mon Sep 17 00:00:00 2001
From 79662e16a5a8d08e7dd24613f9afde23dfb26329 Mon Sep 17 00:00:00 2001
From: Jackie Huang <jackie.huang@windriver.com>
Date: Fri, 26 Nov 2021 16:14:32 +0800
Subject: [PATCH] download_images: add support to load image offline file
@ -18,8 +18,8 @@ Upstream-Status: Pending
Signed-off-by: Jackie Huang <jackie.huang@windriver.com>
---
.../push-docker-images/files/download_images.py | 26 ++++++++++++++++++----
.../roles/common/push-docker-images/tasks/main.yml | 1 +
2 files changed, 23 insertions(+), 4 deletions(-)
.../roles/common/push-docker-images/tasks/main.yml | 5 +++++
2 files changed, 27 insertions(+), 4 deletions(-)
diff --git a/playbookconfig/src/playbooks/roles/common/push-docker-images/files/download_images.py b/playbookconfig/src/playbooks/roles/common/push-docker-images/files/download_images.py
index 7793820..e59dd89 100644
@ -82,14 +82,23 @@ index 7793820..e59dd89 100644
print("Image push succeeded: %s" % local_img)
diff --git a/playbookconfig/src/playbooks/roles/common/push-docker-images/tasks/main.yml b/playbookconfig/src/playbooks/roles/common/push-docker-images/tasks/main.yml
index e1738bf..2a6cc87 100644
index e1738bf..b4e755d 100644
--- a/playbookconfig/src/playbooks/roles/common/push-docker-images/tasks/main.yml
+++ b/playbookconfig/src/playbooks/roles/common/push-docker-images/tasks/main.yml
@@ -134,6 +134,7 @@
@@ -129,11 +129,16 @@
local_registry_credentials: "{{ local_registry_credentials_output.stdout }}"
when: local_registry_credentials is not defined
+- name: Set default values for offline_img_dir if it is undefined
+ set_fact:
+ offline_img_dir: "{{ offline_img_dir | default('') }}"
+
- name: Download images and push to local registry
script: download_images.py {{ download_images }}
register: download_images_output
environment:
REGISTRIES: "{{ registries | to_json }}"
+ OFFLINE_IMG_DIR: "{{ offline_img_dir if (offline_img_dir is defined) }}"
+ OFFLINE_IMG_DIR: "{{ offline_img_dir }}"
- debug:
msg: "{{ download_images_output.stdout_lines }}"