-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathssh.yaml
More file actions
34 lines (32 loc) · 828 Bytes
/
ssh.yaml
File metadata and controls
34 lines (32 loc) · 828 Bytes
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
---
- name: Determine SSH port
hosts: all
gather_facts: no
tasks:
- name: "Check port {{ ansible_port }}"
wait_for:
port: "{{ ansible_port }}"
state: "started"
host: "{{ ansible_host }}"
connect_timeout: "5"
timeout: "5"
delegate_to: "localhost"
ignore_errors: "yes"
register: ssh_port
- name: "Check port 22"
wait_for:
port: "22"
state: "started"
host: "{{ ansible_host }}"
connect_timeout: "5"
timeout: "5"
delegate_to: "localhost"
ignore_errors: "yes"
register: ssh_port_default
when:
- ssh_port is defined
- ssh_port.state is undefined
- name: Set SSH port to 22
set_fact:
ansible_port: "22"
when: ssh_port_default.state is defined