From 6db6d1967ec5af33209fc6780e61b5973019f233 Mon Sep 17 00:00:00 2001 From: Abhijeet Kasurde Date: Tue, 28 Jan 2025 07:05:37 -0800 Subject: [PATCH] connection: raise exception return by SSH (#84592) Fixes: #58133 Signed-off-by: Abhijeet Kasurde --- changelogs/fragments/ssh_raise_exception.yml | 3 +++ lib/ansible/plugins/connection/ssh.py | 1 + 2 files changed, 4 insertions(+) create mode 100644 changelogs/fragments/ssh_raise_exception.yml 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