Allow to pass a static inventory to the validator CLI

This is especially interesting when doing a full upgrade, as you might
end in a situation where you don't have any running services on the
undercloud.

This patch will be needed down to stable/train.

Change-Id: Ife48ed6ec5e5ae7c9ff1695c83e1d3312dc1205a
(cherry picked from commit 4c713b189c)
This commit is contained in:
Cédric Jeanneret 2020-09-04 11:39:24 +02:00 committed by Cédric Jeanneret (Tengu)
parent 0b43745613
commit 98e4589371
1 changed files with 26 additions and 8 deletions

View File

@ -274,6 +274,17 @@ class TripleOValidatorRun(command.Command):
"ANSIBLE_STDOUT_CALLBACK=default")
)
extra_vars_group.add_argument(
'--static-inventory',
action='store',
default='',
help=_(
"Provide your own static inventory file. You can generate "
"such an inventory calling tripleo-ansible-inventory command. "
"Especially useful when heat service isn't available."
)
)
ex_group = parser.add_mutually_exclusive_group(required=True)
ex_group.add_argument(
@ -314,6 +325,12 @@ class TripleOValidatorRun(command.Command):
else:
extra_vars.update(yaml.load(env_file))
# We don't check if the file exists in order to support
# passing a string such as "localhost,", like we can do with
# the "-i" option of ansible-playbook.
if parsed_args.static_inventory:
static_inventory = parsed_args.static_inventory
else:
static_inventory = oooutils.get_tripleo_ansible_inventory(
ssh_user='heat-admin',
stack=parsed_args.plan,
@ -354,6 +371,7 @@ class TripleOValidatorRun(command.Command):
t.add_row(r.values())
print(t)
if not parsed_args.static_inventory:
LOG.debug(_('Removing static tripleo ansible inventory file'))
oooutils.cleanup_tripleo_ansible_inventory_file(
static_inventory)