Skip to content

Commit 795b001

Browse files
dguidoclaude
andcommitted
Add pre-flight SSH connectivity check before update-users
When running ./algo update-users, if the server is unreachable, users previously saw cryptic Ansible SSH retry errors like: ssh_retry: attempt: 3, ssh return code is 255 This adds a pre-flight check that tests SSH connectivity before running the full playbook. If the connection fails, it provides a helpful error message with: - Clear explanation of what failed - Possible causes (server not running, IP changed, firewall blocking) - Diagnostic commands to run (nc, ssh -vvv) Fixes #14878 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <[email protected]>
1 parent 3e62871 commit 795b001

File tree

1 file changed

+26
-0
lines changed

1 file changed

+26
-0
lines changed

users.yml

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,32 @@
5151
include_vars:
5252
file: configs/{{ algo_server }}/.config.yml
5353

54+
- name: Test SSH connectivity to server
55+
wait_for:
56+
host: "{{ algo_server }}"
57+
port: "{{ ansible_ssh_port | default(ssh_port) | int }}"
58+
timeout: 10
59+
register: ssh_check
60+
ignore_errors: true
61+
when: algo_server != 'localhost'
62+
63+
- name: Fail with helpful message if server unreachable
64+
fail:
65+
msg: |
66+
Cannot connect to {{ algo_server }} on port {{ ansible_ssh_port | default(ssh_port) }}.
67+
68+
Possible causes:
69+
- Server is not running (check your cloud provider console)
70+
- IP address changed (common after EC2 restart without Elastic IP)
71+
- Firewall/security group blocking port {{ ansible_ssh_port | default(ssh_port) }}
72+
73+
To diagnose:
74+
nc -zv {{ algo_server }} {{ ansible_ssh_port | default(ssh_port) }}
75+
ssh -vvv -p {{ ansible_ssh_port | default(ssh_port) }} -i configs/algo.pem {{ server_user | default('algo') }}@{{ algo_server }}
76+
when:
77+
- algo_server != 'localhost'
78+
- ssh_check is failed
79+
5480
- when: ipsec_enabled
5581
block:
5682
- name: CA password prompt

0 commit comments

Comments
 (0)