You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

33 lines
1.3 KiB

  1. #!/bin/bash
  2. set -eo pipefail
  3. CURRENT_DIR=$(cd $(dirname $0); pwd)
  4. TEMP_DIR="${CURRENT_DIR}/temp"
  5. REPO_ROOT_DIR="${CURRENT_DIR%/contrib/offline}"
  6. : ${DOWNLOAD_YML:="roles/kubespray-defaults/defaults/main/download.yml"}
  7. mkdir -p ${TEMP_DIR}
  8. # generate all download files url template
  9. grep 'download_url:' ${REPO_ROOT_DIR}/${DOWNLOAD_YML} \
  10. | sed 's/^.*_url: //g;s/\"//g' > ${TEMP_DIR}/files.list.template
  11. # generate all images list template
  12. sed -n '/^downloads:/,/download_defaults:/p' ${REPO_ROOT_DIR}/${DOWNLOAD_YML} \
  13. | sed -n "s/repo: //p;s/tag: //p" | tr -d ' ' \
  14. | sed 'N;s#\n# #g' | tr ' ' ':' | sed 's/\"//g' > ${TEMP_DIR}/images.list.template
  15. # add kube-* images to images list template
  16. # Those container images are downloaded by kubeadm, then roles/kubespray-defaults/defaults/main/download.yml
  17. # doesn't contain those images. That is reason why here needs to put those images into the
  18. # list separately.
  19. KUBE_IMAGES="kube-apiserver kube-controller-manager kube-scheduler kube-proxy"
  20. for i in $KUBE_IMAGES; do
  21. echo "{{ kube_image_repo }}/$i:{{ kube_version }}" >> ${TEMP_DIR}/images.list.template
  22. done
  23. # run ansible to expand templates
  24. /bin/cp ${CURRENT_DIR}/generate_list.yml ${REPO_ROOT_DIR}
  25. (cd ${REPO_ROOT_DIR} && ansible-playbook $* generate_list.yml && /bin/rm generate_list.yml) || exit 1