Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Kayobe multiple environments support #35

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 17 additions & 9 deletions tools/openstack-config
Original file line number Diff line number Diff line change
Expand Up @@ -4,30 +4,38 @@ SCRIPT=${BASH_SOURCE[0]}
TOOLS_PATH=$(dirname ${SCRIPT})
OPENSTACK_CONFIG_PATH=$(dirname ${TOOLS_PATH})
cd ${OPENSTACK_CONFIG_PATH}
MANDATORY_PARAM=false

PLAYBOOK=ansible/openstack.yml

while getopts ":p:" opt; do
while getopts ":p:e:" opt; do
case $opt in
p)
PLAYBOOK=${OPTARG}
;;

e)
MANDATORY_PARAM=true;
ENV="-${OPTARG}"
;;
\?)
echo "Invalid option: -$opt"
echo "Usage: ${0} [-p <playbook>] [-- <other arguments to ansible-playbook>]"
echo "Invalid option: -$OPTARG"
echo "Usage: ${0} [-p <playbook>] [-e <kayobe environment name>] [-- <other arguments to ansible-playbook>]"
exit 1
;;
esac
if [[ -n ${OPTARG} ]]; then
shift
fi
shift
done

if [[ $1 == '--' ]]; then
shift
# Fail as mandatory environment paremeter is missing
if ! $MANDATORY_PARAM
then
echo "-e missing - environment parameter is mandatory" >&2
exit 1
fi

# Removing parameters already parsed with getopts
shift $(( OPTIND - 1 ))

echo "Running playbook $PLAYBOOK"

exec ansible-playbook \
Expand Down