Add ability to run osa playbooks from tripleo-deploy-openshift

Introduce a `--playbook` option to the `tripleo-deploy-openshift`
script in order to be able to run openshift-ansible playbook directly
on already deployed servers.

It may be necessary to run specific openshift-ansible's playbook for
certain day 2 operation tasks.

Related-Bug: #1810812
Change-Id: Ieb25fa5ac0e209f738ed734e9063175ae2a8aa55
This commit is contained in:
Martin André 2019-01-07 12:20:29 +01:00
parent 53b11565e2
commit d4b78bf507
2 changed files with 18 additions and 2 deletions

View File

@ -0,0 +1,6 @@
---
features:
- |
Introduce a `--playbook` option to the `tripleo-deploy-openshift` script in
order to be able to run openshift-ansible playbook directly on already
deployed servers.

View File

@ -19,6 +19,7 @@ OPENSHIFT_ANSIBLE_DEFAULT_IMAGE=$(build_default_image)
: ${PLAN_NAME:=openshift} : ${PLAN_NAME:=openshift}
: ${CONFIG_DOWNLOAD_DIR:=} : ${CONFIG_DOWNLOAD_DIR:=}
: ${OPENSHIFT_PLAYBOOK:=}
: ${OPENSHIFT_ANSIBLE_IMAGE:=$OPENSHIFT_ANSIBLE_DEFAULT_IMAGE} : ${OPENSHIFT_ANSIBLE_IMAGE:=$OPENSHIFT_ANSIBLE_DEFAULT_IMAGE}
usage () { usage () {
@ -30,10 +31,12 @@ usage () {
echo " -d, --config-download-dir the path to the config-download directory for openshift" echo " -d, --config-download-dir the path to the config-download directory for openshift"
echo " DEPRECATED use --plan instead" echo " DEPRECATED use --plan instead"
echo " -n, --plan the plan name. Defaults to $PLAN_NAME" echo " -n, --plan the plan name. Defaults to $PLAN_NAME"
echo " -p, --playbook the path of the playbook to run. Defaults to"
echo " openshift/playbook.yml in the config-download directory"
echo " -h, --help print this help and exit" echo " -h, --help print this help and exit"
} }
OPTS=`getopt -o hd:n:i: --long help,config-download-dir:,plan:,image: -- "$@"` OPTS=`getopt -o hd:n:i:p: --long help,config-download-dir:,plan:,image:,playbook: -- "$@"`
eval set -- "$OPTS" eval set -- "$OPTS"
while true; do while true; do
@ -48,6 +51,9 @@ while true; do
shift shift
export PLAN_NAME=$1 export PLAN_NAME=$1
shift ;; shift ;;
-p | --playbook)
shift
export OPENSHIFT_PLAYBOOK=$1; shift ;;
-i | --image) -i | --image)
shift shift
export OPENSHIFT_ANSIBLE_IMAGE=$1; shift ;; export OPENSHIFT_ANSIBLE_IMAGE=$1; shift ;;
@ -64,6 +70,10 @@ if [[ ! -d $CONFIG_DOWNLOAD_DIR ]]; then
exit exit
fi fi
if [[ -z $OPENSHIFT_PLAYBOOK ]]; then
export OPENSHIFT_PLAYBOOK=${CONFIG_DOWNLOAD_DIR}/openshift/playbook.yml
fi
ANSIBLE_OPTS="-e @${CONFIG_DOWNLOAD_DIR}/openshift/global_vars.yml" ANSIBLE_OPTS="-e @${CONFIG_DOWNLOAD_DIR}/openshift/global_vars.yml"
if [[ -f ${CONFIG_DOWNLOAD_DIR}/openshift/global_gluster_vars.yml ]]; then if [[ -f ${CONFIG_DOWNLOAD_DIR}/openshift/global_gluster_vars.yml ]]; then
ANSIBLE_OPTS="${ANSIBLE_OPTS} -e @${CONFIG_DOWNLOAD_DIR}/openshift/global_gluster_vars.yml" ANSIBLE_OPTS="${ANSIBLE_OPTS} -e @${CONFIG_DOWNLOAD_DIR}/openshift/global_gluster_vars.yml"
@ -77,6 +87,6 @@ docker run \
-e ANSIBLE_HOST_KEY_CHECKING=False \ -e ANSIBLE_HOST_KEY_CHECKING=False \
-e ANSIBLE_CONFIG=${CONFIG_DOWNLOAD_DIR}/ansible.cfg \ -e ANSIBLE_CONFIG=${CONFIG_DOWNLOAD_DIR}/ansible.cfg \
-e INVENTORY_DIR=${CONFIG_DOWNLOAD_DIR}/openshift/inventory \ -e INVENTORY_DIR=${CONFIG_DOWNLOAD_DIR}/openshift/inventory \
-e PLAYBOOK_FILE=${CONFIG_DOWNLOAD_DIR}/openshift/playbook.yml \ -e PLAYBOOK_FILE=${OPENSHIFT_PLAYBOOK} \
-e OPTS="${ANSIBLE_OPTS}" \ -e OPTS="${ANSIBLE_OPTS}" \
-t ${OPENSHIFT_ANSIBLE_IMAGE} -t ${OPENSHIFT_ANSIBLE_IMAGE}