Skip to content

Commit 7577333

Browse files
authored
Merge pull request #173 from stackhpc/backport/stackhpc/wallaby/multiple-inventories
Support multiple inventories
2 parents 6640950 + 9ac15b6 commit 7577333

File tree

3 files changed

+19
-3
lines changed

3 files changed

+19
-3
lines changed

doc/source/user/operating-kolla.rst

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -201,6 +201,12 @@ necessary update containers, without generating configuration.
201201
``kolla-ansible -i INVENTORY prune-images`` is used to prune orphaned Docker
202202
images on hosts.
203203

204+
``kolla-ansible -i INVENTORY1 -i INVENTORY2 ...`` Multiple inventories can be
205+
specified by passing the ``--inventory`` or ``-i`` command line option multiple
206+
times. This can be useful to share configuration between multiple environments.
207+
Any common configuration can be set in ``INVENTORY1`` and ``INVENTORY2`` can be
208+
used to set environment specific details.
209+
204210
.. note::
205211

206212
In order to do smoke tests, requires ``kolla_enable_sanity_checks=yes``.
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
features:
3+
- |
4+
It is now possible to pass multiple inventories to ``kolla-ansible``. To do
5+
so you should specify ``--inventory`` multiple times.

tools/kolla-ansible

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,8 @@ function usage {
125125
Usage: $0 COMMAND [options]
126126
127127
Options:
128-
--inventory, -i <inventory_path> Specify path to ansible inventory file
128+
--inventory, -i <inventory_path> Specify path to ansible inventory file. \
129+
Can be specified multiple times to pass multiple inventories.
129130
--playbook, -p <playbook_path> Specify path to ansible playbook file
130131
--configdir <config_path> Specify path to directory with globals.yml
131132
--key -k <key_path> Specify path to ansible vault keyfile
@@ -243,12 +244,13 @@ BACKUP_TYPE="full"
243244
# Serial is not recommended and disabled by default. Users can enable it by
244245
# configuring ANSIBLE_SERIAL variable.
245246
ANSIBLE_SERIAL=${ANSIBLE_SERIAL:-0}
247+
INVENTORIES=()
246248

247249
while [ "$#" -gt 0 ]; do
248250
case "$1" in
249251

250252
(--inventory|-i)
251-
INVENTORY="$2"
253+
INVENTORIES+=("$2")
252254
shift 2
253255
;;
254256

@@ -516,5 +518,8 @@ GLOBALS_DIR="${CONFIG_DIR}/globals.d"
516518
EXTRA_GLOBALS=$(find ${GLOBALS_DIR} -maxdepth 1 -type f -name '*.yml' -printf ' -e @%p' 2>/dev/null)
517519
PASSWORDS_FILE="${PASSWORDS_FILE:-${CONFIG_DIR}/passwords.yml}"
518520
CONFIG_OPTS="-e @${CONFIG_DIR}/globals.yml ${EXTRA_GLOBALS} -e @${PASSWORDS_FILE} -e CONFIG_DIR=${CONFIG_DIR}"
519-
CMD="ansible-playbook -i $INVENTORY $CONFIG_OPTS $EXTRA_OPTS $PLAYBOOK $VERBOSITY"
521+
CMD="ansible-playbook $CONFIG_OPTS $EXTRA_OPTS $PLAYBOOK $VERBOSITY"
522+
for INVENTORY in ${INVENTORIES[@]}; do
523+
CMD="${CMD} --inventory $INVENTORY"
524+
done
520525
process_cmd

0 commit comments

Comments
 (0)