From 960fc05b8a6f1ebd4d5fad6c216eb0fc2ea46f8f Mon Sep 17 00:00:00 2001 From: Alex Schultz Date: Mon, 30 Apr 2018 14:22:48 -0600 Subject: [PATCH] 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 --- tools/yaml-validate.py | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/tools/yaml-validate.py b/tools/yaml-validate.py index c60e3ea05f..d298166c81 100755 --- a/tools/yaml-validate.py +++ b/tools/yaml-validate.py @@ -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