summaryrefslogtreecommitdiff
path: root/test/lib/ansible_test/_internal/commands/shell/__init__.py
diff options
context:
space:
mode:
Diffstat (limited to 'test/lib/ansible_test/_internal/commands/shell/__init__.py')
-rw-r--r--test/lib/ansible_test/_internal/commands/shell/__init__.py19
1 files changed, 18 insertions, 1 deletions
diff --git a/test/lib/ansible_test/_internal/commands/shell/__init__.py b/test/lib/ansible_test/_internal/commands/shell/__init__.py
index 5733ff2fe8..5e8c101abb 100644
--- a/test/lib/ansible_test/_internal/commands/shell/__init__.py
+++ b/test/lib/ansible_test/_internal/commands/shell/__init__.py
@@ -9,6 +9,8 @@ from ...util import (
ApplicationError,
OutputStream,
display,
+ SubprocessError,
+ HostConnectionError,
)
from ...config import (
@@ -115,4 +117,19 @@ def command_shell(args: ShellConfig) -> None:
else:
cmd = []
- con.run(cmd, capture=False, interactive=True)
+ try:
+ con.run(cmd, capture=False, interactive=True)
+ except SubprocessError as ex:
+ if isinstance(con, SshConnection) and ex.status == 255:
+ # 255 indicates SSH itself failed, rather than a command run on the remote host.
+ # In this case, report a host connection error so additional troubleshooting output is provided.
+ if not args.delegate and not args.host_path:
+ def callback() -> None:
+ """Callback to run during error display."""
+ target_profile.on_target_failure() # when the controller is not delegated, report failures immediately
+ else:
+ callback = None
+
+ raise HostConnectionError(f'SSH shell connection failed for host {target_profile.config}: {ex}', callback) from ex
+
+ raise