Ansible wait for methods

Ansible sample methods to wait for a machine to boot or a port to be ready.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
    - name: Waits for SSH, don't start checking for 5 seconds
      wait_for:
        host: ""
        port: 22
        delay: 10
        timeout: 300
        state: started

    - name: Wait for VMs to boot up (300, 5)
      wait_for_connection:
        delay: 5
        timeout: 300
        sleep: 5

    - name: check SSH access
      local_action: shell ansible -u  -m ping 
      register: result
      until: result.rc == 0
      retries: 30
      delay: 10

    - name: Wait for VMs to boot with SSH
      local_action:
        module: wait_for host= port=22 delay=10 connect_timeout=5 timeout=300

comments powered by Disqus