From ced2b93697c75d2074102d587f472dbfbf698de3 Mon Sep 17 00:00:00 2001 From: Brian Coca Date: Wed, 3 Aug 2022 13:31:19 -0400 Subject: [PATCH] config error origin (#78407) (#78409) (cherry picked from commit 9b79d6ba3582bb0ef339738b7e1ade879d00dfe3) --- changelogs/fragments/config_error_origin.yml | 2 ++ lib/ansible/config/manager.py | 4 ++-- test/integration/targets/config/runme.sh | 2 +- 3 files changed, 5 insertions(+), 3 deletions(-) create mode 100644 changelogs/fragments/config_error_origin.yml diff --git a/changelogs/fragments/config_error_origin.yml b/changelogs/fragments/config_error_origin.yml new file mode 100644 index 00000000000..9663930e7f3 --- /dev/null +++ b/changelogs/fragments/config_error_origin.yml @@ -0,0 +1,2 @@ +bugfixes: + - if a config setting prevents running ansible it should at least show it's "origin". diff --git a/lib/ansible/config/manager.py b/lib/ansible/config/manager.py index a28a84a528b..468f666b03b 100644 --- a/lib/ansible/config/manager.py +++ b/lib/ansible/config/manager.py @@ -551,8 +551,8 @@ class ConfigManager(object): origin = 'default' value = ensure_type(defs[config].get('default'), defs[config].get('type'), origin=origin) else: - raise AnsibleOptionsError('Invalid type for configuration option %s: %s' % - (to_native(_get_entry(plugin_type, plugin_name, config)), to_native(e))) + raise AnsibleOptionsError('Invalid type for configuration option %s (from %s): %s' % + (to_native(_get_entry(plugin_type, plugin_name, config)).strip(), origin, to_native(e))) # deal with restricted values if value is not None and 'choices' in defs[config] and defs[config]['choices'] is not None: diff --git a/test/integration/targets/config/runme.sh b/test/integration/targets/config/runme.sh index 64f65fdd6c7..122e15d76d4 100755 --- a/test/integration/targets/config/runme.sh +++ b/test/integration/targets/config/runme.sh @@ -7,7 +7,7 @@ set -eux ANSIBLE_TIMEOUT= ansible -m ping testhost -i ../../inventory "$@" # env var is wrong type, this should be a fatal error pointing at the setting -ANSIBLE_TIMEOUT='lola' ansible -m ping testhost -i ../../inventory "$@" 2>&1|grep 'Invalid type for configuration option setting: DEFAULT_TIMEOUT' +ANSIBLE_TIMEOUT='lola' ansible -m ping testhost -i ../../inventory "$@" 2>&1|grep 'Invalid type for configuration option setting: DEFAULT_TIMEOUT (from env: ANSIBLE_TIMEOUT)' # https://github.com/ansible/ansible/issues/69577 ANSIBLE_REMOTE_TMP="$HOME/.ansible/directory_with_no_space" ansible -m ping testhost -i ../../inventory "$@"