Ansible Pilot

Test host availability - Ansible module ping

Deep dive into the Ansible module ping in the collection ansible.builtin to test the access to a managed host and that Python is installed. Live demo and Ansible playbook included.

July 27, 2021
Access the Complete Video Course and Learn Quick Ansible by 200+ Practical Lessons

Ansible module ping. Today we’re going to talk about the simplest way to test if a managed host is available to receive our commands. I’m Luca Berton and welcome to today’s episode of Ansible Pilot.

Ansible module ping

Today we’re talking about Ansible module ping. The full name is ansible.builtin.ping, which means that is part of the collection of modules “builtin” with ansible and shipped with it. It’s a module pretty stable and out for years. It verify the ability of Ansible to login to the managed host and that there is a Python interpreter that is able to execute our code. So it’s pretty different for the ping in the network context. It’s the Linux corresponding to the Ansible win_ping module.

Main parameters and return values

People usually don’t specify any parameters or use the return value. For the parameter, it’s possible to change the behavior from the default “pong” to the “crash” that raises an exception in case of failure.

The return value default is the “pong” string, but you could customize it with the data parameter.

Demo

Are you ready to make your hands dirty? Let’s jump in a quick live demo of a playbook about the ping module.

---
- name: ping module demo
  hosts: all
  become: false
  tasks:
    - name: test connection
      ansible.builtin.ping:

code with ❤️ in GitHub

Recap

Now you know better the Ansible module ping and you could use it successfully in your playbook. Subscribe to the YouTube channel, Medium, Website, Twitter, and Substack to not miss the next episode of the Ansible Pilot.

Academy

Learn the Ansible automation technology with some real-life examples in my

My book Ansible By Examples: 200+ Automation Examples For Linux and Windows System Administrator and DevOps

BUY the Complete PDF BOOK to easily Copy and Paste the 200+ Ansible code

Want to keep this project going? Please donate

Access the Complete Video Course and Learn Quick Ansible by 200+ Practical Lessons
Trustpilot
Follow me

Subscribe not to miss any new releases

FREE Top 10 Best Practices

Top 10 Best Practices of Ansible Automation: save time, reduce errors and stress