Merge "Convert ansible action to TripleoInventory class"
This commit is contained in:
commit
96c0bc8d5d
|
@ -26,6 +26,7 @@ from mistral_lib import actions
|
||||||
from oslo_concurrency import processutils
|
from oslo_concurrency import processutils
|
||||||
|
|
||||||
from tripleo_common.actions import base
|
from tripleo_common.actions import base
|
||||||
|
from tripleo_common.inventory import TripleoInventory
|
||||||
|
|
||||||
|
|
||||||
def write_default_ansible_cfg(work_dir,
|
def write_default_ansible_cfg(work_dir,
|
||||||
|
@ -508,7 +509,7 @@ class AnsiblePlaybookAction(base.TripleOAction):
|
||||||
shutil.rmtree(self.work_dir)
|
shutil.rmtree(self.work_dir)
|
||||||
|
|
||||||
|
|
||||||
class AnsibleGenerateInventoryAction(actions.Action):
|
class AnsibleGenerateInventoryAction(base.TripleOAction):
|
||||||
"""Executes tripleo-ansible-inventory to generate an inventory"""
|
"""Executes tripleo-ansible-inventory to generate an inventory"""
|
||||||
|
|
||||||
def __init__(self, **kwargs):
|
def __init__(self, **kwargs):
|
||||||
|
@ -517,6 +518,8 @@ class AnsibleGenerateInventoryAction(actions.Action):
|
||||||
'ansible_ssh_user', 'tripleo-admin')
|
'ansible_ssh_user', 'tripleo-admin')
|
||||||
self._work_dir = self._kwargs_for_run.pop(
|
self._work_dir = self._kwargs_for_run.pop(
|
||||||
'work_dir', None)
|
'work_dir', None)
|
||||||
|
self.plan_name = self._kwargs_for_run.pop(
|
||||||
|
'plan_name', 'overcloud')
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def work_dir(self):
|
def work_dir(self):
|
||||||
|
@ -529,24 +532,16 @@ class AnsibleGenerateInventoryAction(actions.Action):
|
||||||
|
|
||||||
inventory_path = os.path.join(
|
inventory_path = os.path.join(
|
||||||
self.work_dir, 'tripleo-ansible-inventory.yaml')
|
self.work_dir, 'tripleo-ansible-inventory.yaml')
|
||||||
command = []
|
|
||||||
command.append('/usr/bin/tripleo-ansible-inventory')
|
|
||||||
command.append('--static-yaml-inventory')
|
|
||||||
command.append(inventory_path)
|
|
||||||
|
|
||||||
env_variables = {
|
inventory = TripleoInventory(
|
||||||
'HOME': self.work_dir,
|
session=self.get_session(context, 'heat'),
|
||||||
'OS_AUTH_URL': context.security.auth_uri,
|
hclient=self.get_orchestration_client(context),
|
||||||
'OS_USERNAME': context.security.user_name,
|
auth_url=context.security.auth_uri,
|
||||||
'OS_AUTH_TOKEN': context.security.auth_token,
|
cacert=context.security.auth_cacert,
|
||||||
'OS_PROJECT_NAME': context.security.project_name}
|
project_name=context.security.project_name,
|
||||||
|
username=context.security.user_name,
|
||||||
|
ansible_ssh_user=self.ansible_ssh_user,
|
||||||
|
plan_name=self.plan_name)
|
||||||
|
|
||||||
if self.ansible_ssh_user:
|
inventory.write_static_inventory(inventory_path)
|
||||||
command.append('--ansible_ssh_user')
|
|
||||||
command.append(self.ansible_ssh_user)
|
|
||||||
|
|
||||||
stderr, stdout = processutils.execute(
|
|
||||||
*command, cwd=self.work_dir,
|
|
||||||
env_variables=env_variables,
|
|
||||||
log_errors=processutils.LogErrors.ALL)
|
|
||||||
return inventory_path
|
return inventory_path
|
||||||
|
|
Loading…
Reference in New Issue