Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Preserve ssh error #56460

Merged
merged 3 commits into from May 23, 2019
Merged

Preserve ssh error #56460

merged 3 commits into from May 23, 2019

Conversation

bcoca
Copy link
Member

@bcoca bcoca commented May 15, 2019

Allow original ssh error to be seen and traceback to be available on high verbosity
fixes #35313

ISSUE TYPE
  • Bugfix Pull Request
COMPONENT NAME

connection/ssh

@bcoca
Copy link
Member Author

bcoca commented May 15, 2019

cc @JulienPalard @kustodian @paulRbr

@ansibot ansibot added affects_2.9 This issue/PR affects Ansible v2.9 bug This issue/PR relates to a bug. core_review In order to be merged, this PR must follow the core review workflow. needs_triage Needs a first human triage before being processed. support:community This issue/PR relates to code supported by the Ansible community. support:core This issue/PR relates to code supported by the Ansible Engineering Team. labels May 15, 2019
@JulienPalard
Copy link
Contributor

Hi Brian! Thanks for looking at it!

I tested your PR locally and it does not fix my personal issue, so I propose also changing:

diff --git a/lib/ansible/plugins/connection/ssh.py b/lib/ansible/plugins/connection/ssh.py
index 23a365f9db..36f76d57b7 100644
--- a/lib/ansible/plugins/connection/ssh.py
+++ b/lib/ansible/plugins/connection/ssh.py
@@ -1034,7 +1034,7 @@ class Connection(ConnectionBase):
             raise AnsibleControlPersistBrokenPipeError('SSH Error: data could not be sent because of ControlPersist broken pipe.')
 
         if p.returncode == 255 and in_data and checkrc:
-            raise AnsibleConnectionFailure('SSH Error: data could not be sent to remote host "%s". Make sure this host can be reached over ssh' % self.host)
+            raise AnsibleConnectionFailure('Data could not be sent to remote host "%s". Make sure this host can be reached over ssh: %s' % (self.host, to_native(b_stderr)))
 
         return (p.returncode, b_stdout, b_stderr)
 

without my change on your branch I'm getting:

TASK [Gathering Facts] ****************************************************************************************************************************
fatal: [staging.example.com]: UNREACHABLE! => {"changed": false, "msg": "SSH Error: data could not be sent to remote host \"red.act.ed.ip\". Make sure this host can be reached over ssh", "unreachable": true}

with my change:

TASK [Gathering Facts] ****************************************************************************************************************************
fatal: [staging.example.com]: UNREACHABLE! => {"changed": false, "msg": "Data could not be sent to remote host \"red.act.ed.ip\". Make sure this host can be reached over ssh: sign_and_send_pubkey: signing failed: agent refused operation\r\nroot@red.act.ed.ip: Permission denied (publickey,password).\r\n", "unreachable": true}

@samdoran samdoran removed the needs_triage Needs a first human triage before being processed. label May 21, 2019
@JulienPalard
Copy link
Contributor

LGTM, I'm getting:

TASK [Gathering Facts] ****************************************************************************************************************************
fatal: [staging1.example.com]: UNREACHABLE! => {"changed": false, "msg": "Data could not be sent to remote host \"re.dac.ted.ip\". Make sure this host can be reached over ssh: sign_and_send_pubkey: signing failed: agent refused operation\r\nroot@re.dac.ted.ip: Permission denied (publickey,password).\r\n", "unreachable": true}

@bcoca bcoca merged commit 22b9525 into ansible:devel May 23, 2019
@bcoca bcoca deleted the ssh_better_error branch May 23, 2019 14:03
bcoca added a commit to bcoca/ansible that referenced this pull request May 23, 2019
* Preserve ssh error

* more details on fail

* removed redundant caption to errors

(cherry picked from commit 22b9525)
abadger pushed a commit that referenced this pull request May 24, 2019
* Preserve ssh error

* more details on fail

* removed redundant caption to errors

(cherry picked from commit 22b9525)
@ansible ansible locked and limited conversation to collaborators Aug 5, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
affects_2.9 This issue/PR affects Ansible v2.9 bug This issue/PR relates to a bug. core_review In order to be merged, this PR must follow the core review workflow. support:community This issue/PR relates to code supported by the Ansible community. support:core This issue/PR relates to code supported by the Ansible Engineering Team.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

ansible-playbook fails silenty if ssh key permissions are too open
5 participants