diff --git a/changelogs/fragments/detect_interpreter_stdout.yml b/changelogs/fragments/detect_interpreter_stdout.yml new file mode 100644 index 00000000000..bbc3b063300 --- /dev/null +++ b/changelogs/fragments/detect_interpreter_stdout.yml @@ -0,0 +1,2 @@ +bugfixes: + - Also check stdout for interpreter errors for more intelligent messages to user diff --git a/lib/ansible/plugins/action/__init__.py b/lib/ansible/plugins/action/__init__.py index 63ef5b906a3..ec91e8ac547 100644 --- a/lib/ansible/plugins/action/__init__.py +++ b/lib/ansible/plugins/action/__init__.py @@ -918,12 +918,16 @@ class ActionBase(with_metaclass(ABCMeta, object)): if res['stderr'].startswith(u'Traceback'): data['exception'] = res['stderr'] - # try to figure out if we are missing interpreter - if self._used_interpreter is not None and '%s: No such file or directory' % self._used_interpreter.lstrip('!#') in data['module_stderr']: - data['msg'] = "The module failed to execute correctly, you probably need to set the interpreter." - else: - data['msg'] = "MODULE FAILURE" + # The default + data['msg'] = "MODULE FAILURE" + # try to figure out if we are missing interpreter + if self._used_interpreter is not None: + match = '%s: No such file or directory' % self._used_interpreter.lstrip('!#') + if match in data['module_stderr'] or match in data['module_stdout']: + data['msg'] = "The module failed to execute correctly, you probably need to set the interpreter." + + # always append hint data['msg'] += '\nSee stdout/stderr for the exact error' if 'rc' in res: