c85e5ed1de
When using the tripleo-deploy-openshift script standalone, we want it to default to the same image as what's used when calling the script from TripleO. Parse the default values from the container_image_prepare_defaults.yaml file and use them to construct the URI of the openshift-ansible image instead of hardcoding it. The script first search for the `container_image_prepare_defaults.yaml` in the location of the rpm-installed tripleo-common, then relative to the script in case of a tripleo-common checkout, and finally defaults to the latest upstream image if the file cannot be found. Change-Id: Ieb65bfcfb7f87599488344fbe91114e9d0a021fc
73 lines
2.5 KiB
Bash
Executable File
73 lines
2.5 KiB
Bash
Executable File
#!/bin/bash
|
|
|
|
build_default_image () {
|
|
if [ -f /usr/share/openstack-tripleo-common/common/container-images/container_image_prepare_defaults.yaml ]; then
|
|
local default_file=/usr/share/openstack-tripleo-common/common/container-images/container_image_prepare_defaults.yaml
|
|
elif [ -f ${BASH_SOURCE%/*}/../container-images/container_image_prepare_defaults.yaml ]; then
|
|
local default_file=${BASH_SOURCE%/*}/../container-images/container_image_prepare_defaults.yaml
|
|
else
|
|
echo "docker.io/openshift/origin-ansible:latest"
|
|
exit
|
|
fi
|
|
local namespace=$(awk '/openshift_namespace:/ {print $2}' $default_file)
|
|
local prefix=$(awk '/openshift_prefix:/ {print $2}' $default_file)
|
|
local tag=$(awk '/openshift_tag:/ {print $2}' $default_file)
|
|
echo ${namespace}/${prefix}-ansible:${tag}
|
|
}
|
|
|
|
OPENSHIFT_ANSIBLE_DEFAULT_IMAGE=$(build_default_image)
|
|
|
|
: ${CONFIG_DOWNLOAD_DIR:=}
|
|
: ${OPENSHIFT_ANSIBLE_IMAGE:=$OPENSHIFT_ANSIBLE_DEFAULT_IMAGE}
|
|
|
|
usage () {
|
|
echo "Usage: $0 [options]"
|
|
echo ""
|
|
echo "Options:"
|
|
echo " -i, --image the openshift-ansible image tag to use. Defaults to"
|
|
echo " $OPENSHIFT_ANSIBLE_DEFAULT_IMAGE"
|
|
echo " -d, --config-download-dir the path to the config-download directory for openshift"
|
|
echo " -h, --help print this help and exit"
|
|
}
|
|
|
|
OPTS=`getopt -o hd:i: --long help,config-download-dir:,image: -- "$@"`
|
|
eval set -- "$OPTS"
|
|
|
|
while true; do
|
|
case "$1" in
|
|
-h | --help)
|
|
usage; exit ;;
|
|
-d | --config-download-dir)
|
|
shift
|
|
export CONFIG_DOWNLOAD_DIR=$1; shift ;;
|
|
-i | --image)
|
|
shift
|
|
export OPENSHIFT_ANSIBLE_IMAGE=$1; shift ;;
|
|
--) shift ; break ;;
|
|
* ) break ;;
|
|
esac
|
|
done
|
|
|
|
if [[ -z $CONFIG_DOWNLOAD_DIR ]]; then
|
|
echo "Missing required --config-download-dir option"
|
|
usage
|
|
exit
|
|
fi
|
|
|
|
ANSIBLE_OPTS="-e @${CONFIG_DOWNLOAD_DIR}/openshift/global_vars.yml"
|
|
if [[ -f ${CONFIG_DOWNLOAD_DIR}/openshift/global_gluster_vars.yml ]]; then
|
|
ANSIBLE_OPTS="${ANSIBLE_OPTS} -e @${CONFIG_DOWNLOAD_DIR}/openshift/global_gluster_vars.yml"
|
|
fi
|
|
|
|
docker run \
|
|
--net=host \
|
|
-u `id -u` \
|
|
-v ${CONFIG_DOWNLOAD_DIR}:${CONFIG_DOWNLOAD_DIR} \
|
|
-w ${CONFIG_DOWNLOAD_DIR} \
|
|
-e ANSIBLE_HOST_KEY_CHECKING=False \
|
|
-e ANSIBLE_CONFIG=${CONFIG_DOWNLOAD_DIR}/ansible.cfg \
|
|
-e INVENTORY_DIR=${CONFIG_DOWNLOAD_DIR}/openshift/inventory \
|
|
-e PLAYBOOK_FILE=${CONFIG_DOWNLOAD_DIR}/openshift/playbook.yml \
|
|
-e OPTS="${ANSIBLE_OPTS}" \
|
|
-t ${OPENSHIFT_ANSIBLE_IMAGE}
|