diff --git a/lib/ansible/plugins/action/__init__.py b/lib/ansible/plugins/action/__init__.py index fe42bb40d4e..9c6cb8b700c 100644 --- a/lib/ansible/plugins/action/__init__.py +++ b/lib/ansible/plugins/action/__init__.py @@ -1203,16 +1203,21 @@ class ActionBase(ABC): data['deprecations'].extend(self._discovery_deprecation_warnings) if res['rc'] and data.get('_ansible_parsed') and not data.get('failed'): - data |= { - 'failed': True, - 'module_rc': res['rc'], - 'msg': 'The module exited with a non-zero rc but was not marked as failed. This indicates a module execution failure.' - } - if 'module_stdout' not in data: - data |= { - 'module_stdout': res.get('stdout', ''), - 'module_stderr': res.get('stderr', ''), - } + data.setdefault('warnings', []).append( + f'The module ({self._task.resolved_action}) exited with a non-zero rc but was not marked as failed. ' + 'This may indicate a module execution failure or other module execution related issue. ' + 'Running with ANSIBLE_DEBUG=1 may provide more information.' + ) + # data |= { + # 'failed': True, + # 'module_rc': res['rc'], + # 'msg': 'The module exited with a non-zero rc but was not marked as failed. This indicates a module execution failure.' + # } + # if 'module_stdout' not in data: + # data |= { + # 'module_stdout': res.get('stdout', ''), + # 'module_stderr': res.get('stderr', ''), + # } # mark the entire module results untrusted as a template right here, since the current action could # possibly template one of these values. diff --git a/test/integration/targets/module_behavior/tasks/main.yml b/test/integration/targets/module_behavior/tasks/main.yml index 421bc864bff..fe45ac63571 100644 --- a/test/integration/targets/module_behavior/tasks/main.yml +++ b/test/integration/targets/module_behavior/tasks/main.yml @@ -29,10 +29,12 @@ - missing_stdout is failed - missing_stdout.msg.splitlines()|first == empty_stdout - - non_zero_rc is failed - - non_zero_rc.module_rc == 2 - - non_zero_rc.module_stdout is defined - - non_zero_rc.module_stderr is defined + - non_zero_rc is successful + - non_zero_rc.warnings is defined + - non_zero_rc.warnings|select('search', 'exited with a non-zero rc') != [] + # - non_zero_rc.module_rc == 2 + # - non_zero_rc.module_stdout is defined + # - non_zero_rc.module_stderr is defined - traceback is failed - traceback.module_rc is not defined