forked from notthebee/infra
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathssh_juggle_port.yml
70 lines (61 loc) · 1.87 KB
/
ssh_juggle_port.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
---
- name: SSH Port Juggle | Try connecting via SSH
wait_for_connection:
timeout: 5
ignore_errors: true
register: _ssh_port_result
- name: SSH Port Juggle | Set the ansible_port to the fallback default port
set_fact:
ansible_ssh_port: "22"
when:
- _ssh_port_result is failed
- name: SSH Port Juggle | Try connecting again
wait_for_connection:
timeout: 5
ignore_errors: true
register: _ssh_port_default_result
when:
- _ssh_port_result is failed
- name: SSH Port Juggle | Set the ansible_port to the fallback default port and credentials
set_fact:
ansible_ssh_port: "22"
ansible_ssh_user: "pi"
ansible_ssh_password: "raspberry"
when:
- _ssh_port_result is failed
- _ssh_port_default_result is failed
- name: Try default credentials (for Raspberry Pi)
wait_for_connection:
timeout: 5
ignore_errors: true
register: _ssh_port_default_cred_result
when:
- _ssh_port_result is failed
- _ssh_port_default_result is failed
- name: SSH Port Juggle | Try root
set_fact:
ansible_ssh_port: "22"
ansible_ssh_user: "root"
when:
- _ssh_port_result is failed
- _ssh_port_default_result is failed
- _ssh_port_default_cred_result is failed
- name: Try root
wait_for_connection:
timeout: 5
ignore_errors: true
register: _ssh_port_default_cred_result
when:
- _ssh_port_result is failed
- _ssh_port_default_result is failed
- _ssh_port_default_cred_result is failed
- name: SSH Port Juggle | Fail
fail: msg="Neither the configured ansible_port {{ ansible_port }} nor the fallback port 22 were reachable"
when:
- _ssh_port_result is failed
- _ssh_port_default_result is defined
- _ssh_port_default_result is failed
- _ssh_port_default_cred_result is defined
- _ssh_port_default_cred_result is failed
- _ssh_port_root_result is defined
- _ssh_port_root_result is failed