diff --git a/README.rst b/README.rst index a520786..259698c 100644 --- a/README.rst +++ b/README.rst @@ -57,6 +57,12 @@ To configure OpenStack infrastructure: $ tools/openstack-config +Optionally provide environment name if using multiple environments: + +.. code-block:: + + $ tools/openstack-config -e + To run a specific playbook: .. code-block:: diff --git a/tools/openstack-config b/tools/openstack-config index 055a62c..3b0f2f8 100755 --- a/tools/openstack-config +++ b/tools/openstack-config @@ -7,31 +7,30 @@ cd ${OPENSTACK_CONFIG_PATH} PLAYBOOK=ansible/openstack.yml -while getopts ":p:" opt; do +while getopts ":p:e:" opt; do case $opt in p) PLAYBOOK=${OPTARG} ;; + + e) + ENV="-${OPTARG}" + ;; \?) - echo "Invalid option: -$opt" - echo "Usage: ${0} [-p ] [-- ]" + echo "Invalid option: -$OPTARG" + echo "Usage: ${0} [-p ] [-e ] [-- ]" exit 1 ;; esac - if [[ -n ${OPTARG} ]]; then - shift - fi - shift done -if [[ $1 == '--' ]]; then - shift -fi +# Removing parameters already parsed with getopts +shift $(( OPTIND - 1 )) echo "Running playbook $PLAYBOOK" exec ansible-playbook \ ${PLAYBOOK} \ -i ansible/inventory \ - -e @etc/openstack-config/openstack-config.yml \ + -e @etc/openstack-config/openstack-config${ENV}.yml \ $@