diff --git a/changelogs/fragments/ssh_raise_exception.yml b/changelogs/fragments/ssh_raise_exception.yml new file mode 100644 index 00000000000..f27235f268d --- /dev/null +++ b/changelogs/fragments/ssh_raise_exception.yml @@ -0,0 +1,3 @@ +--- +bugfixes: + - ssh - Raise exception when sshpass returns error code (https://github.com/ansible/ansible/issues/58133). diff --git a/lib/ansible/plugins/connection/ssh.py b/lib/ansible/plugins/connection/ssh.py index 8207c606b5a..b7e868ce494 100644 --- a/lib/ansible/plugins/connection/ssh.py +++ b/lib/ansible/plugins/connection/ssh.py @@ -450,6 +450,7 @@ def _handle_error( 'Upgrade sshpass to use sshpass_prompt, or otherwise switch to ssh keys.' raise AnsibleError('{0} {1}'.format(msg, details)) msg = '{0} {1}'.format(msg, details) + raise AnsibleConnectionFailure(msg) if return_tuple[0] == 255: SSH_ERROR = True