Skip to content

Commit e1a9b02

Browse files
Merge pull request #235 from DinMouMou/master
Modify check_ssh role to use wait_for_connection module
2 parents fd7676d + f37c97f commit e1a9b02

File tree

2 files changed

+5
-24
lines changed

2 files changed

+5
-24
lines changed
+1-2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,2 @@
1-
ssh_retries: 100
1+
ssh_timeout: 600
22
ssh_retry_delay: 6
3-
host: "{{ hostvars[inventory_hostname]['ansible_host'] | default(inventory_hostname) }}"

cinch/roles/check_ssh/tasks/main.yml

+4-22
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,5 @@
1-
- block:
2-
- name: verify that configured SSH private key is a file and has permissions of 0600
3-
local_action: file path="{{ ansible_ssh_private_key_file }}" state=file mode=0600
4-
tags:
5-
- skip_ansible_lint
6-
7-
- name: construct command line for SSH check
8-
set_fact:
9-
check_ssh_cmd: >-
10-
ansible --ssh-extra-args='-o StrictHostKeyChecking=no'
11-
-i '{{ inventory_dir }}/{{ (inventory_file | string | default('')) | basename }}'
12-
{{ host }} -m ping
13-
14-
- name: check for SSH connectivity and authentication
15-
local_action: shell {{ check_ssh_cmd }}
16-
register: result
17-
changed_when: "result.rc != 0"
18-
until: result.rc == 0
19-
retries: "{{ ssh_retries }}"
20-
delay: "{{ ssh_retry_delay }}"
21-
tags:
22-
- skip_ansible_lint
1+
- name: wait for ssh connection
2+
wait_for_connection:
3+
sleep: '{{ ssh_retry_delay }}'
4+
timeout: '{{ ssh_timeout }}'
235
when: ansible_connection == 'ssh'

0 commit comments

Comments
 (0)