From cbedbd3c9c81908cc1ac6d7aa835bb9110fabb17 Mon Sep 17 00:00:00 2001 From: Brian Coca Date: Mon, 14 May 2018 15:04:11 -0400 Subject: [PATCH] enforce required config --- lib/ansible/config/manager.py | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/lib/ansible/config/manager.py b/lib/ansible/config/manager.py index c1370581b0..c0882a613d 100644 --- a/lib/ansible/config/manager.py +++ b/lib/ansible/config/manager.py @@ -343,11 +343,20 @@ class ConfigManager(object): # set default if we got here w/o a value if value is None: - value = defs[config].get('default') - origin = 'default' - # skip typing as this is a temlated default that will be resolved later in constants, which has needed vars - if plugin_type is None and isinstance(value, string_types) and (value.startswith('{{') and value.endswith('}}')): - return value, origin + if defs[config].get('required', False): + entry = '' + if plugin_type: + entry += 'plugin_type: %s ' % plugin_type + if plugin_name: + entry += 'plugin: %s ' % plugin_name + entry += 'setting: %s ' % config + raise AnsibleError("No setting was provided for required configuration %s" % (entry)) + else: + value = defs[config].get('default') + origin = 'default' + # skip typing as this is a temlated default that will be resolved later in constants, which has needed vars + if plugin_type is None and isinstance(value, string_types) and (value.startswith('{{') and value.endswith('}}')): + return value, origin # ensure correct type try: