Merge pull request #2 from paramite/flex-inventory
Allow inventory overrides
This commit is contained in:
commit
3f8acf0574
@ -38,7 +38,9 @@ class InventoryError(Exception):
|
|||||||
INVENTORY = os.path.join(base.OBSWRKDIR, 'openstack-inventory.yaml')
|
INVENTORY = os.path.join(base.OBSWRKDIR, 'openstack-inventory.yaml')
|
||||||
INV_FALLBACKS = [
|
INV_FALLBACKS = [
|
||||||
'~/tripleo-deploy/{stack}/openstack-inventory.yaml',
|
'~/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')
|
ENDPOINTS = os.path.join(base.OBSWRKDIR, 'scrape-endpoints.yaml')
|
||||||
STACKRC = os.path.join(base.OBSWRKDIR, 'stackrc')
|
STACKRC = os.path.join(base.OBSWRKDIR, 'stackrc')
|
||||||
@ -75,6 +77,12 @@ class Discover(base.ObservabilityBaseCommand):
|
|||||||
help=_("Overcloud stack name for which inventory file should "
|
help=_("Overcloud stack name for which inventory file should "
|
||||||
"be generated")
|
"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
|
return parser
|
||||||
|
|
||||||
def take_action(self, parsed_args):
|
def take_action(self, parsed_args):
|
||||||
@ -92,6 +100,8 @@ class Discover(base.ObservabilityBaseCommand):
|
|||||||
# OSP versions with deprecated tripleo-ansible-inventory fallbacks
|
# OSP versions with deprecated tripleo-ansible-inventory fallbacks
|
||||||
# to static inventory file generated at one of the fallback path
|
# to static inventory file generated at one of the fallback path
|
||||||
if not os.path.exists(INVENTORY):
|
if not os.path.exists(INVENTORY):
|
||||||
|
if parsed_args.inventory:
|
||||||
|
INV_FALLBACKS.insert(0, parsed_args.inventory)
|
||||||
for i in INV_FALLBACKS:
|
for i in INV_FALLBACKS:
|
||||||
absi = i.format(stack=parsed_args.stack_name)
|
absi = i.format(stack=parsed_args.stack_name)
|
||||||
absi = os.path.abspath(os.path.expanduser(absi))
|
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
|
# 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
|
return parser
|
||||||
|
|
||||||
def take_action(self, parsed_args):
|
def take_action(self, parsed_args):
|
||||||
|
inventory = INVENTORY
|
||||||
|
if parsed_args.inventory:
|
||||||
|
inventory = parsed_args.inventory
|
||||||
for compnt in parsed_args.components:
|
for compnt in parsed_args.components:
|
||||||
playbook = '%s.yml' % compnt
|
playbook = '%s.yml' % compnt
|
||||||
try:
|
try:
|
||||||
self._run_playbook(playbook, INVENTORY,
|
self._run_playbook(playbook, inventory,
|
||||||
parsed_args=parsed_args)
|
parsed_args=parsed_args)
|
||||||
except OSError as ex:
|
except OSError as ex:
|
||||||
print('Failed to load playbook file: %s' % ex)
|
print('Failed to load playbook file: %s' % ex)
|
||||||
|
Loading…
Reference in New Issue
Block a user