2021-05-11 15:39:36 +08:00
|
|
|
#!/bin/bash
|
|
|
|
set -eo pipefail
|
|
|
|
|
|
|
|
CURRENT_DIR=$(cd $(dirname $0); pwd)
|
|
|
|
TEMP_DIR="${CURRENT_DIR}/temp"
|
|
|
|
REPO_ROOT_DIR="${CURRENT_DIR%/contrib/offline}"
|
|
|
|
|
|
|
|
: ${DOWNLOAD_YML:="roles/download/defaults/main.yml"}
|
|
|
|
|
|
|
|
mkdir -p ${TEMP_DIR}
|
|
|
|
|
2022-02-14 15:19:28 +08:00
|
|
|
# generate all download files url template
|
2021-05-11 15:39:36 +08:00
|
|
|
grep 'download_url:' ${REPO_ROOT_DIR}/${DOWNLOAD_YML} \
|
2022-02-14 15:19:28 +08:00
|
|
|
| sed 's/^.*_url: //g;s/\"//g' > ${TEMP_DIR}/files.list.template
|
2021-05-11 15:39:36 +08:00
|
|
|
|
2022-02-14 15:19:28 +08:00
|
|
|
# generate all images list template
|
2021-05-11 15:39:36 +08:00
|
|
|
sed -n '/^downloads:/,/download_defaults:/p' ${REPO_ROOT_DIR}/${DOWNLOAD_YML} \
|
2022-02-14 15:19:28 +08:00
|
|
|
| sed -n "s/repo: //p;s/tag: //p" | tr -d ' ' \
|
|
|
|
| sed 'N;s#\n# #g' | tr ' ' ':' | sed 's/\"//g' > ${TEMP_DIR}/images.list.template
|
2021-05-11 15:39:36 +08:00
|
|
|
|
2022-02-14 15:19:28 +08:00
|
|
|
# add kube-* images to images list template
|
2021-05-11 15:39:36 +08:00
|
|
|
KUBE_IMAGES="kube-apiserver kube-controller-manager kube-scheduler kube-proxy"
|
2022-02-14 15:19:28 +08:00
|
|
|
for i in $KUBE_IMAGES; do
|
|
|
|
echo "{{ kube_image_repo }}/$i:{{ kube_version }}" >> ${TEMP_DIR}/images.list.template
|
|
|
|
done
|
|
|
|
|
|
|
|
# run ansible to expand templates
|
|
|
|
/bin/cp ${CURRENT_DIR}/generate_list.yml ${REPO_ROOT_DIR}
|
2021-05-11 15:39:36 +08:00
|
|
|
|
2022-02-14 15:19:28 +08:00
|
|
|
(cd ${REPO_ROOT_DIR} && ansible-playbook $* generate_list.yml && /bin/rm generate_list.yml) || exit 1
|