Merge pull request #2 from paramite/flex-inventory

Allow inventory overrides
This commit is contained in:
Leif Madsen 2022-12-31 13:42:58 -05:00 committed by GitHub
commit 3f8acf0574
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -38,7 +38,9 @@ class InventoryError(Exception):
INVENTORY = os.path.join(base.OBSWRKDIR, 'openstack-inventory.yaml')
INV_FALLBACKS = [
'~/tripleo-deploy/{stack}/openstack-inventory.yaml',
'./overcloud-deploy/{stack}/openstack-inventory.yaml'
'~/tripleo-deploy/{stack}/tripleo-ansible-inventory.yaml',
'./overcloud-deploy/{stack}/openstack-inventory.yaml',
'./overcloud-deploy/{stack}/tripleo-ansible-inventory.yaml',
]
ENDPOINTS = os.path.join(base.OBSWRKDIR, 'scrape-endpoints.yaml')
STACKRC = os.path.join(base.OBSWRKDIR, 'stackrc')
@ -75,6 +77,12 @@ class Discover(base.ObservabilityBaseCommand):
help=_("Overcloud stack name for which inventory file should "
"be generated")
)
parser.add_argument(
'--inventory',
help=_("Use this argument in case you have inventory file "
"generated or moved to non-standard place. Value has to be "
"path to inventory file including the file name.")
)
return parser
def take_action(self, parsed_args):
@ -92,6 +100,8 @@ class Discover(base.ObservabilityBaseCommand):
# OSP versions with deprecated tripleo-ansible-inventory fallbacks
# to static inventory file generated at one of the fallback path
if not os.path.exists(INVENTORY):
if parsed_args.inventory:
INV_FALLBACKS.insert(0, parsed_args.inventory)
for i in INV_FALLBACKS:
absi = i.format(stack=parsed_args.stack_name)
absi = os.path.abspath(os.path.expanduser(absi))
@ -141,13 +151,22 @@ class Setup(base.ObservabilityBaseCommand):
# TODO: in future will contain option for all stack components
]
)
parser.add_argument(
'--inventory',
help=_("Use this argument in case you don't want to use for "
"whatever reason the inventory file generated by discovery "
"command")
)
return parser
def take_action(self, parsed_args):
inventory = INVENTORY
if parsed_args.inventory:
inventory = parsed_args.inventory
for compnt in parsed_args.components:
playbook = '%s.yml' % compnt
try:
self._run_playbook(playbook, INVENTORY,
self._run_playbook(playbook, inventory,
parsed_args=parsed_args)
except OSError as ex:
print('Failed to load playbook file: %s' % ex)