Merge "Generate a play per step for external_deploy_tasks" into stable/train

This commit is contained in:
Zuul 2020-07-30 20:20:27 +00:00 committed by Gerrit Code Review
commit 033d9da8b6
4 changed files with 23 additions and 3 deletions

View File

@ -203,7 +203,9 @@ TRIPLEO_NETWORK_CONFIG_RESOURCE = 'NetworkConfig'
HOST_NETWORK = 'ctlplane' HOST_NETWORK = 'ctlplane'
EXTERNAL_TASKS = ['external_deploy_tasks'] # The key is different in RoleConfig than in RoleData, so we need both so they
# are correctly found.
EXTERNAL_TASKS = ['external_deploy_tasks', 'external_deploy_steps_tasks']
ANSIBLE_ERRORS_FILE = 'ansible-errors.json' ANSIBLE_ERRORS_FILE = 'ansible-errors.json'

View File

@ -29,7 +29,10 @@ FAKE_STACK = {
'outputs': [ 'outputs': [
{'output_key': 'RoleConfig', {'output_key': 'RoleConfig',
'output_value': { 'output_value': {
'foo_config': 'foo'}}, 'foo_config': 'foo',
'external_deploy_steps_tasks': [{'name': 'Fake external task',
'debug': 'name=hello',
'when': 'step|int == 1'}]}},
{'output_key': 'HostnameNetworkConfigMap', {'output_key': 'HostnameNetworkConfigMap',
'output_value': {}}, 'output_value': {}},
{'output_key': 'RoleData', {'output_key': 'RoleData',

View File

@ -50,7 +50,7 @@ class TestConfig(base.TestCase):
'service_metadata_settings', 'service_metadata_settings',
'service_names', 'service_names',
'upgrade_batch_tasks', 'upgrade_tasks', 'upgrade_batch_tasks', 'upgrade_tasks',
'external_deploy_tasks'] 'external_deploy_steps_tasks']
heat = mock.MagicMock() heat = mock.MagicMock()
heat.stacks.get.return_value = fakes.create_tht_stack() heat.stacks.get.return_value = fakes.create_tht_stack()
@ -65,6 +65,11 @@ class TestConfig(base.TestCase):
mock_mkdir.assert_called() mock_mkdir.assert_called()
expected_calls = [] expected_calls = []
for config in config_type_list: for config in config_type_list:
if 'external' in config:
for step in range(constants.DEFAULT_STEPS_MAX):
expected_calls += [call('/tmp/tht/%s_step%s.yaml' %
(config, step))]
for role in fake_role: for role in fake_role:
if 'external' in config: if 'external' in config:
continue continue

View File

@ -279,6 +279,16 @@ class Config(object):
role_config = self.get_role_config() role_config = self.get_role_config()
for config_name, config in six.iteritems(role_config): for config_name, config in six.iteritems(role_config):
# External tasks are in RoleConfig and not defined per role.
# So we don't use the RoleData to create the per step playbooks.
if config_name in constants.EXTERNAL_TASKS:
for i in range(constants.DEFAULT_STEPS_MAX):
filepath = os.path.join(config_dir,
'%s_step%s.yaml'
% (config_name, i))
self._write_tasks_per_step(config, filepath, i)
conf_path = os.path.join(config_dir, config_name) conf_path = os.path.join(config_dir, config_name)
# Add .yaml extension only if there's no extension already # Add .yaml extension only if there's no extension already
if '.' not in conf_path: if '.' not in conf_path: