[Ansible] Look for inventory in SoftwareConfig options

Currently, the only way to use a custom inventory is to change the
HEAT_ANSIBLE_INVENTORY environment variable. This becomes a problem when
the inventory has to be changed between playbook runs from two
sequential SoftwareDeployments, as environment variables won't be
reloaded.

This change allows to specify the location of the inventory in the
"options" map for each SoftwareConfig.

Change-Id: I6709213240119e999d4f36e2938b0de9311d2556
This commit is contained in:
Mariusz 2019-03-15 14:13:26 +00:00
parent 6139799be2
commit 82037a90db
1 changed files with 4 additions and 0 deletions

View File

@ -55,6 +55,10 @@ def main(argv=sys.argv):
skip_tags = c['options'].get('skip_tags')
modulepath = c['options'].get('modulepath')
callback_plugins = c['options'].get('callback_plugins')
inventory = c['options'].get('inventory')
if inventory:
global ANSIBLE_INVENTORY
ANSIBLE_INVENTORY = os.path.join(WORKING_DIR, inventory)
fn = os.path.join(WORKING_DIR, '%s_playbook.yaml' % c['id'])
vars_filename = os.path.join(WORKING_DIR, '%s_variables.json' % c['id'])