Generate a play per step for external_deploy_tasks

external_deploy_tasks will now be written out in per step files in the
config download directory. This will allow including the task files for
a specific step only at that step, and saving time by not having to skip
so many tasks.

Change-Id: I7ded2cb74afe73eab5c423fcb31ec9046ea47790
This commit is contained in:
Emilien Macchi 2020-07-22 09:27:35 -04:00
parent d9811e94ea
commit eddc1e6094
4 changed files with 23 additions and 3 deletions

View File

@ -208,7 +208,9 @@ TRIPLEO_NETWORK_CONFIG_RESOURCE = 'NetworkConfig'
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'

View File

@ -29,7 +29,10 @@ FAKE_STACK = {
'outputs': [
{'output_key': 'RoleConfig',
'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_value': {}},
{'output_key': 'RoleData',

View File

@ -59,7 +59,7 @@ class TestConfig(base.TestCase):
'service_metadata_settings',
'service_names',
'upgrade_batch_tasks', 'upgrade_tasks',
'external_deploy_tasks']
'external_deploy_steps_tasks']
heat = mock.MagicMock()
heat.stacks.get.return_value = fakes.create_tht_stack()
@ -74,6 +74,11 @@ class TestConfig(base.TestCase):
mock_mkdir.assert_called()
expected_calls = []
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:
if 'external' in config:
continue

View File

@ -296,6 +296,16 @@ class Config(object):
role_config = self.get_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)
# Add .yaml extension only if there's no extension already
if '.' not in conf_path: