Skip to content
This repository has been archived by the owner on Nov 1, 2023. It is now read-only.

Commit

Permalink
Merge pull request #2 from paramite/flex-inventory
Browse files Browse the repository at this point in the history
Allow inventory overrides
  • Loading branch information
leifmadsen authored Dec 31, 2022
2 parents 183b738 + a5b8fb7 commit 3f8acf0
Showing 1 changed file with 21 additions and 2 deletions.
23 changes: 21 additions & 2 deletions observabilityclient/v1/deploy.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,9 @@ def __str__(self):
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')
Expand Down Expand Up @@ -75,6 +77,12 @@ def get_parser(self, prog_name):
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):
Expand All @@ -92,6 +100,8 @@ def take_action(self, parsed_args):
# 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))
Expand Down Expand Up @@ -141,13 +151,22 @@ def get_parser(self, prog_name):
# 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)
Expand Down

0 comments on commit 3f8acf0

Please sign in to comment.