mirror of
https://github.com/ansible-collections/community.general.git
synced 2025-07-23 13:20:23 -07:00
Ensure that command/shell errors are displayed
This fix ensures that if there are specific module errors (in our case the python interpreter was not found) then command and shell returns a proper error. It also fixes a few other imperfections that we noticed during troubleshooting: - Return the real RC if it were available - Improve a dictionary evaluation using .get() - Return an RC of -1 if it is unknown (instead of returning 0) This fixes #18846
This commit is contained in:
parent
41614fd8e6
commit
39c9c6b942
3 changed files with 8 additions and 6 deletions
|
@ -720,6 +720,8 @@ class ActionBase(with_metaclass(ABCMeta, object)):
|
|||
data['module_stderr'] = res['stderr']
|
||||
if res['stderr'].startswith(u'Traceback'):
|
||||
data['exception'] = res['stderr']
|
||||
if 'rc' in res:
|
||||
data['rc'] = res['rc']
|
||||
return data
|
||||
|
||||
def _low_level_execute_command(self, cmd, sudoable=True, in_data=None, executable=None, encoding_errors='surrogate_or_replace'):
|
||||
|
@ -801,7 +803,7 @@ class ActionBase(with_metaclass(ABCMeta, object)):
|
|||
display.debug("Going to peek to see if file has changed permissions")
|
||||
peek_result = self._execute_module(module_name='file', module_args=dict(path=destination, diff_peek=True), task_vars=task_vars, persist_files=True)
|
||||
|
||||
if not('failed' in peek_result and peek_result['failed']) or peek_result.get('rc', 0) == 0:
|
||||
if not peek_result.get('failed', False) or peek_result.get('rc', 0) == 0:
|
||||
|
||||
if peek_result['state'] == 'absent':
|
||||
diff['before'] = ''
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue