File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -4,30 +4,38 @@ SCRIPT=${BASH_SOURCE[0]}
44TOOLS_PATH=$( dirname ${SCRIPT} )
55OPENSTACK_CONFIG_PATH=$( dirname ${TOOLS_PATH} )
66cd ${OPENSTACK_CONFIG_PATH}
7+ MANDATORY_PARAM=false
78
89PLAYBOOK=ansible/openstack.yml
910
10- while getopts " :p:" opt; do
11+ while getopts " :p:e: " opt; do
1112 case $opt in
1213 p)
1314 PLAYBOOK=${OPTARG}
1415 ;;
16+
17+ e)
18+ MANDATORY_PARAM=true;
19+ ENV=" -${OPTARG} "
20+ ;;
1521 \? )
16- echo " Invalid option: -$opt "
17- echo " Usage: ${0} [-p <playbook>] [-- <other arguments to ansible-playbook>]"
22+ echo " Invalid option: -$OPTARG "
23+ echo " Usage: ${0} [-p <playbook>] [-e <kayobe environment name>] [- - <other arguments to ansible-playbook>]"
1824 exit 1
1925 ;;
2026 esac
21- if [[ -n ${OPTARG} ]]; then
22- shift
23- fi
24- shift
2527done
2628
27- if [[ $1 == ' --' ]]; then
28- shift
29+ # Fail as mandatory environment paremeter is missing
30+ if ! $MANDATORY_PARAM
31+ then
32+ echo " -e missing - environment parameter is mandatory" >&2
33+ exit 1
2934fi
3035
36+ # Removing parameters already parsed with getopts
37+ shift $(( OPTIND - 1 ))
38+
3139echo " Running playbook $PLAYBOOK "
3240
3341exec ansible-playbook \
You can’t perform that action at this time.
0 commit comments