Cyber Deals - Get up to 65% off on CKA, CKAD, CKS, KCNA, KCSA exams and courses!

Ansible wait for methods

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
      wait_for:
        host: "{{ inventory_hostname }}"
        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 {{ ansible_user_id }} -m ping {{ inventory_hostname }}
      register: result
      until: result.rc == 0
      retries: 30
      delay: 10

    - name: Wait for VMs to boot with SSH
      local_action:
        module: wait_for host={{ inventory_hostname }} port=22 delay=10 connect_timeout=5 timeout=300
Disclaimer: Views expressed in articles are those of the respective authors and do not necessarily reflect the views of their employers or this site. While we aim for accuracy, please verify information before relying on it, and let us know if you spot an error.
Share:

Related Posts

Cloud

AWS Summit Online - 2020

Hands on Labs Build, Run and Deploy a Containerized Web Application using Docker and Amazon Elastic Container Service (ECS) - …

Ansible for Security

Ansible for Security

Ansible Security Hardening Playbook content RedHatOfficial/ansible-role-rhel7-cis RedHatOfficial/ansible-role-rhel8-cis …

Ansible LightSpeed

Ansible LightSpeed

Introduction Ansible Lightspeed is a generative AI service designed to streamline the creation and maintenance of Ansible Playbooks. Here’s a …

CheatSheets for DevOps Tools

CheatSheets for DevOps Tools

Ansible Cheatsheet kubectl & oc Cheatsheet Docker & Podman Cheatsheet AWS CLI Cheatsheet Vim Editor Cheatsheet Logical Volume Manager (LVM) …

Ansible Automation Platform - Disaster Recovery

Ansible Automation Platform - Disaster Recovery

These are official references to implement Disaster Recovery (DR) designs for Ansible Automation Platform.

Ansible and Terraform

Ansible and Terraform

cloud.terraform collection github.com/ansible-collections/cloud.terraform