Ensure tasks aren't empty dicts

Ansible doesn't like it when tasks are empty dicts so let's make sure
we aren't passing an empty dict in to the ansible tasks. Unfortunately
since we're validating non-heat processed yaml, the list_concats end
up being dicts to the yaml validator so we can't just ensure they are
always lists.

Change-Id: I13dcc4f3d4ea2ac4c7ab62887dfea293246f6530
Related-Bug: #1768019
This commit is contained in:
Alex Schultz 2018-04-30 14:22:48 -06:00
parent ca69e1c57d
commit 960fc05b8a
1 changed files with 16 additions and 0 deletions

View File

@ -59,6 +59,14 @@ OPTIONAL_DOCKER_SECTIONS = ['docker_puppet_tasks', 'upgrade_tasks',
'logging_source', 'logging_groups',
'external_deploy_tasks', 'external_post_deploy_tasks',
'docker_config_scripts', 'step_config']
# ansible tasks cannot be an empty dict or ansible is unhappy
ANSIBLE_TASKS_SECTIONS = ['upgrade_tasks', 'pre_upgrade_rolling_tasks',
'fast_forward_upgrade_tasks',
'fast_forward_post_upgrade_tasks',
'post_upgrade_tasks', 'update_tasks',
'post_update_tasks', 'host_prep_tasks',
'external_deploy_tasks',
'external_post_deploy_tasks' ]
REQUIRED_DOCKER_PUPPET_CONFIG_SECTIONS = ['config_volume', 'step_config',
'config_image']
OPTIONAL_DOCKER_PUPPET_CONFIG_SECTIONS = [ 'puppet_tags', 'volumes' ]
@ -521,6 +529,14 @@ def validate_docker_service(filename, tpl):
continue
else:
if section_name in OPTIONAL_DOCKER_SECTIONS:
# check for LP##1768019
if section_name in ANSIBLE_TASKS_SECTIONS and \
role_data.get(section_name) == {}:
print('ERROR: %s cannot be an empty dict. If not '
'required please consider removing remove this '
'option or setting it to [] or null' %
section_name)
return 1
continue
elif section_name in OPTIONAL_SECTIONS:
continue