diff --git a/doc/source/user/operating-kolla.rst b/doc/source/user/operating-kolla.rst index 65def70dc6..5c3ed3b12b 100644 --- a/doc/source/user/operating-kolla.rst +++ b/doc/source/user/operating-kolla.rst @@ -201,6 +201,12 @@ necessary update containers, without generating configuration. ``kolla-ansible -i INVENTORY prune-images`` is used to prune orphaned Docker 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:: In order to do smoke tests, requires ``kolla_enable_sanity_checks=yes``. diff --git a/releasenotes/notes/support-multiple-inventories-f0b694fa4e78bb8a.yaml b/releasenotes/notes/support-multiple-inventories-f0b694fa4e78bb8a.yaml new file mode 100644 index 0000000000..2ce42da313 --- /dev/null +++ b/releasenotes/notes/support-multiple-inventories-f0b694fa4e78bb8a.yaml @@ -0,0 +1,5 @@ +--- +features: + - | + It is now possible to pass multiple inventories to ``kolla-ansible``. To do + so you should specify ``--inventory`` multiple times. diff --git a/tools/kolla-ansible b/tools/kolla-ansible index 65a8b49210..05e40d313b 100755 --- a/tools/kolla-ansible +++ b/tools/kolla-ansible @@ -125,7 +125,8 @@ function usage { Usage: $0 COMMAND [options] Options: - --inventory, -i Specify path to ansible inventory file + --inventory, -i Specify path to ansible inventory file. \ +Can be specified multiple times to pass multiple inventories. --playbook, -p Specify path to ansible playbook file --configdir Specify path to directory with globals.yml --key -k Specify path to ansible vault keyfile @@ -239,12 +240,13 @@ BACKUP_TYPE="full" # Serial is not recommended and disabled by default. Users can enable it by # configuring ANSIBLE_SERIAL variable. ANSIBLE_SERIAL=${ANSIBLE_SERIAL:-0} +INVENTORIES=() while [ "$#" -gt 0 ]; do case "$1" in (--inventory|-i) - INVENTORY="$2" + INVENTORIES+=("$2") shift 2 ;; @@ -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) 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}" -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