Skip to content
Snippets Groups Projects
Commit 6d371d47 authored by Zuul's avatar Zuul Committed by Gerrit Code Review
Browse files

Merge "Support multiple inventories"

parents 3be572f6 6c72fa81
No related branches found
No related tags found
No related merge requests found
...@@ -201,6 +201,12 @@ necessary update containers, without generating configuration. ...@@ -201,6 +201,12 @@ necessary update containers, without generating configuration.
``kolla-ansible -i INVENTORY prune-images`` is used to prune orphaned Docker ``kolla-ansible -i INVENTORY prune-images`` is used to prune orphaned Docker
images on hosts. images on hosts.
``kolla-ansible -i INVENTORY1 -i INVENTORY2 ...`` Multiple inventories can be
specified by passing the ``--inventory`` or ``-i`` command line option multiple
times. This can be useful to share configuration between multiple environments.
Any common configuration can be set in ``INVENTORY1`` and ``INVENTORY2`` can be
used to set environment specific details.
.. note:: .. note::
In order to do smoke tests, requires ``kolla_enable_sanity_checks=yes``. In order to do smoke tests, requires ``kolla_enable_sanity_checks=yes``.
......
---
features:
- |
It is now possible to pass multiple inventories to ``kolla-ansible``. To do
so you should specify ``--inventory`` multiple times.
...@@ -125,7 +125,8 @@ function usage { ...@@ -125,7 +125,8 @@ function usage {
Usage: $0 COMMAND [options] Usage: $0 COMMAND [options]
Options: Options:
--inventory, -i <inventory_path> Specify path to ansible inventory file --inventory, -i <inventory_path> Specify path to ansible inventory file. \
Can be specified multiple times to pass multiple inventories.
--playbook, -p <playbook_path> Specify path to ansible playbook file --playbook, -p <playbook_path> Specify path to ansible playbook file
--configdir <config_path> Specify path to directory with globals.yml --configdir <config_path> Specify path to directory with globals.yml
--key -k <key_path> Specify path to ansible vault keyfile --key -k <key_path> Specify path to ansible vault keyfile
...@@ -239,12 +240,13 @@ BACKUP_TYPE="full" ...@@ -239,12 +240,13 @@ BACKUP_TYPE="full"
# Serial is not recommended and disabled by default. Users can enable it by # Serial is not recommended and disabled by default. Users can enable it by
# configuring ANSIBLE_SERIAL variable. # configuring ANSIBLE_SERIAL variable.
ANSIBLE_SERIAL=${ANSIBLE_SERIAL:-0} ANSIBLE_SERIAL=${ANSIBLE_SERIAL:-0}
INVENTORIES=()
while [ "$#" -gt 0 ]; do while [ "$#" -gt 0 ]; do
case "$1" in case "$1" in
(--inventory|-i) (--inventory|-i)
INVENTORY="$2" INVENTORIES+=("$2")
shift 2 shift 2
;; ;;
...@@ -502,5 +504,8 @@ GLOBALS_DIR="${CONFIG_DIR}/globals.d" ...@@ -502,5 +504,8 @@ GLOBALS_DIR="${CONFIG_DIR}/globals.d"
EXTRA_GLOBALS=$(find ${GLOBALS_DIR} -maxdepth 1 -type f -name '*.yml' -printf ' -e @%p' 2>/dev/null) EXTRA_GLOBALS=$(find ${GLOBALS_DIR} -maxdepth 1 -type f -name '*.yml' -printf ' -e @%p' 2>/dev/null)
PASSWORDS_FILE="${PASSWORDS_FILE:-${CONFIG_DIR}/passwords.yml}" PASSWORDS_FILE="${PASSWORDS_FILE:-${CONFIG_DIR}/passwords.yml}"
CONFIG_OPTS="-e @${CONFIG_DIR}/globals.yml ${EXTRA_GLOBALS} -e @${PASSWORDS_FILE} -e CONFIG_DIR=${CONFIG_DIR}" CONFIG_OPTS="-e @${CONFIG_DIR}/globals.yml ${EXTRA_GLOBALS} -e @${PASSWORDS_FILE} -e CONFIG_DIR=${CONFIG_DIR}"
CMD="ansible-playbook -i $INVENTORY $CONFIG_OPTS $EXTRA_OPTS $PLAYBOOK $VERBOSITY" CMD="ansible-playbook $CONFIG_OPTS $EXTRA_OPTS $PLAYBOOK $VERBOSITY"
for INVENTORY in ${INVENTORIES[@]}; do
CMD="${CMD} --inventory $INVENTORY"
done
process_cmd process_cmd
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment