Ansible wait for methods

Follow · 1 min read
Share this

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

    - name: Waits for SSH, don't start checking for 5 seconds
        host: ""
        port: 22
        delay: 10
        timeout: 300
        state: started

    - name: Wait for VMs to boot up (300, 5)
        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
        module: wait_for host= port=22 delay=10 connect_timeout=5 timeout=300

Latest Stories

How to attend Red Hat Remote Exam ? Every details you need to know

In August 2020, Red Hat announced the availability of Remote exams for students and the entire Learning community were so happy, yes we can attend Red Hat exams from our home or offic...

In redhat, Nov 09, 2020
How to Import Existing VMWare VM’s into Terraform

Terraform is an amazing tool for your infrastructure automation. Everything about your infrastructure can be write as code and maintain by team; means your infrastructure is transpare...

In terraform, Nov 04, 2020
Connecting Ansible Tower to Git Server with Self Signed Certificates

So many questioned me when I mention git server in an Ansible Tower environment; and later I realized that, most of them are keeping their projects inside Ansible Tower !!!

In Ansible, Oct 12, 2020
HashiCorp Certified Terraform Associate – Learning & Exam Tips

I started using Terraform somewhere in 2018, but very limited usage as I thought it is just another tool for provisioning infrastructure and other services – or a variant of Vagrant; ...

In terraform, Sep 18, 2020
How to Pass CKA & CKAD Exams ? 10 Tips for Kubernetes Exams

Here see the best tips for Kubernetes Exams - Certified Kubernetes Administrator (CKA) & Certified Kubernetes Application Developer (CKAD).

In kubernetes, Aug 15, 2020