From e47e1dfc2617c7d1d4a8c5fe69aaf52455fd33ee Mon Sep 17 00:00:00 2001 From: Jiri Stransky Date: Tue, 10 Oct 2017 09:59:12 +0200 Subject: [PATCH] Allow processing external_deploy_steps_tasks Process external_deploy_steps_tasks as a part of config download mechanism, which will allow services to export Ansible tasks to be executed on undercloud directly, with full undercloud and overcloud inventory available. These tasks can be used to perform complex actions from the undercloud, such as executing nested installers like kubespray or ceph-ansible. This should allow deploying overcloud with a single Ansible playbook, and without creating Ansible->Mistral->Ansible loop. Implements: blueprint ansible-config-download Change-Id: I8491540edf78711f3229eabeda22a17cd55e99c8 --- tripleo_common/constants.py | 2 ++ tripleo_common/tests/utils/test_config.py | 7 +++++-- tripleo_common/utils/config.py | 10 ++++++++-- 3 files changed, 15 insertions(+), 4 deletions(-) diff --git a/tripleo_common/constants.py b/tripleo_common/constants.py index 1f2a7282d..c112538a8 100644 --- a/tripleo_common/constants.py +++ b/tripleo_common/constants.py @@ -145,3 +145,5 @@ SERVER_RESOURCE_TYPES = 'OS::TripleO::%sServer' # Resource name for deployment resources when using config download TRIPLEO_DEPLOYMENT_RESOURCE = 'TripleODeployment' + +EXTERNAL_TASKS = ['external_deploy_tasks'] diff --git a/tripleo_common/tests/utils/test_config.py b/tripleo_common/tests/utils/test_config.py index bb2f401c6..f3e48c6a4 100644 --- a/tripleo_common/tests/utils/test_config.py +++ b/tripleo_common/tests/utils/test_config.py @@ -41,7 +41,8 @@ class TestConfig(base.TestCase): 'service_config_settings', 'service_metadata_settings', 'service_names', - 'upgrade_batch_tasks', 'upgrade_tasks'] + 'upgrade_batch_tasks', 'upgrade_tasks', + 'external_deploy_tasks'] fake_role = [role for role in fakes.FAKE_STACK['outputs'][1]['output_value']] @@ -56,7 +57,9 @@ class TestConfig(base.TestCase): expected_calls = [] for config in config_type_list: for role in fake_role: - if config == 'step_config': + if 'external' in config: + continue + elif config == 'step_config': expected_calls += [call('/tmp/tht/%s/%s.pp' % (role, config))] else: diff --git a/tripleo_common/utils/config.py b/tripleo_common/utils/config.py index 01be3c07f..af83c510b 100644 --- a/tripleo_common/utils/config.py +++ b/tripleo_common/utils/config.py @@ -180,7 +180,10 @@ class Config(object): role_path = os.path.join(tmp_path, role_name) self._mkdir(role_path) for config in config_type or role.keys(): - if config == 'step_config': + if config in constants.EXTERNAL_TASKS: + # external tasks are collected globally, not per-role + continue + elif config == 'step_config': filepath = os.path.join(role_path, 'step_config.pp') with self._open_file(filepath) as step_config: step_config.write('\n'.join(step for step in @@ -208,7 +211,10 @@ class Config(object): for config_name, config in six.iteritems(role_config): conf_path = os.path.join(tmp_path, config_name + ".yaml") with self._open_file(conf_path) as conf_file: - conf_file.write(config) + if isinstance(config, list) or isinstance(config, dict): + yaml.safe_dump(config, conf_file, default_flow_style=False) + else: + conf_file.write(config) # Get deployment data self.log.info("Getting server data from Heat...")