Merge "Revert "Convert undercloud deploy to use TripleoInventory class""
This commit is contained in:
commit
ec2eb092be
@ -50,9 +50,24 @@ from tripleoclient import heat_launcher
|
|||||||
from tripleo_common.utils import passwords as password_utils
|
from tripleo_common.utils import passwords as password_utils
|
||||||
|
|
||||||
# For ansible download
|
# For ansible download
|
||||||
from tripleo_common.inventory import TripleoInventory
|
|
||||||
from tripleo_common.utils import config
|
from tripleo_common.utils import config
|
||||||
|
|
||||||
|
ANSIBLE_INVENTORY = """
|
||||||
|
[targets]
|
||||||
|
overcloud ansible_connection=local
|
||||||
|
|
||||||
|
[Undercloud]
|
||||||
|
overcloud
|
||||||
|
|
||||||
|
[{hostname}]
|
||||||
|
overcloud
|
||||||
|
"""
|
||||||
|
|
||||||
|
ANSIBLE_SERVICE_INVENTORY = """
|
||||||
|
[{service}]
|
||||||
|
overcloud
|
||||||
|
"""
|
||||||
|
|
||||||
|
|
||||||
class DeployUndercloud(command.Command):
|
class DeployUndercloud(command.Command):
|
||||||
"""Deploy Undercloud (experimental feature)"""
|
"""Deploy Undercloud (experimental feature)"""
|
||||||
@ -329,9 +344,10 @@ class DeployUndercloud(command.Command):
|
|||||||
msg = 'Stack creation timeout: %d minutes elapsed' % (timeout)
|
msg = 'Stack creation timeout: %d minutes elapsed' % (timeout)
|
||||||
raise Exception(msg)
|
raise Exception(msg)
|
||||||
|
|
||||||
def _download_ansible_playbooks(self, client, stack_name):
|
def _download_ansible_playbooks(self, client, stack_id):
|
||||||
stack_config = config.Config(client)
|
stack_config = config.Config(client)
|
||||||
output_dir = os.environ.get('HOME')
|
output_dir = os.environ.get('HOME')
|
||||||
|
stack = client.stacks.get(stack_id)
|
||||||
|
|
||||||
print('** Downloading undercloud ansible.. **')
|
print('** Downloading undercloud ansible.. **')
|
||||||
# python output buffering is making this seem to take forever..
|
# python output buffering is making this seem to take forever..
|
||||||
@ -343,14 +359,15 @@ class DeployUndercloud(command.Command):
|
|||||||
ansible_dir = max(glob.iglob('%s/tripleo-*-config' % output_dir),
|
ansible_dir = max(glob.iglob('%s/tripleo-*-config' % output_dir),
|
||||||
key=os.path.getctime)
|
key=os.path.getctime)
|
||||||
|
|
||||||
inventory = TripleoInventory(
|
inventory = ANSIBLE_INVENTORY
|
||||||
hclient=client,
|
outputs = {i['output_key']: i['output_value'] for i in stack.outputs}
|
||||||
plan_name=stack_name,
|
|
||||||
ansible_ssh_user='root')
|
|
||||||
|
|
||||||
inv_path = os.path.join(ansible_dir, 'inventory.yaml')
|
for service in outputs['EnabledServices']['Undercloud']:
|
||||||
extra_vars = {'undercloud': {'ansible_connection': 'local'}}
|
inventory += ANSIBLE_SERVICE_INVENTORY.format(service=service)
|
||||||
inventory.write_static_inventory(inv_path, extra_vars)
|
|
||||||
|
# Write out the inventory file.
|
||||||
|
with open('%s/inventory' % ansible_dir, 'w') as f:
|
||||||
|
f.write(inventory.format(hostname=self._get_hostname()))
|
||||||
|
|
||||||
print('** Downloaded undercloud ansible to %s **' % ansible_dir)
|
print('** Downloaded undercloud ansible to %s **' % ansible_dir)
|
||||||
sys.stdout.flush()
|
sys.stdout.flush()
|
||||||
@ -359,7 +376,7 @@ class DeployUndercloud(command.Command):
|
|||||||
# Never returns, calls exec()
|
# Never returns, calls exec()
|
||||||
def _launch_ansible(self, ansible_dir):
|
def _launch_ansible(self, ansible_dir):
|
||||||
os.chdir(ansible_dir)
|
os.chdir(ansible_dir)
|
||||||
playbook_inventory = os.path.join(ansible_dir, 'inventory.yaml')
|
playbook_inventory = "%s/inventory" % (ansible_dir)
|
||||||
cmd = ['ansible-playbook', '-i', playbook_inventory,
|
cmd = ['ansible-playbook', '-i', playbook_inventory,
|
||||||
'deploy_steps_playbook.yaml', '-e', 'role_name=Undercloud',
|
'deploy_steps_playbook.yaml', '-e', 'role_name=Undercloud',
|
||||||
'-e', 'deploy_server_id=undercloud', '-e',
|
'-e', 'deploy_server_id=undercloud', '-e',
|
||||||
@ -481,7 +498,7 @@ class DeployUndercloud(command.Command):
|
|||||||
# download the ansible playbooks and execute them.
|
# download the ansible playbooks and execute them.
|
||||||
ansible_dir = \
|
ansible_dir = \
|
||||||
self._download_ansible_playbooks(orchestration_client,
|
self._download_ansible_playbooks(orchestration_client,
|
||||||
parsed_args.stack)
|
stack_id)
|
||||||
# Kill heat, we're done with it now.
|
# Kill heat, we're done with it now.
|
||||||
self._kill_heat()
|
self._kill_heat()
|
||||||
# Never returns.. We exec() it directly.
|
# Never returns.. We exec() it directly.
|
||||||
|
Loading…
Reference in New Issue
Block a user