How to test Windows host availability?
Today we’re going to talk about the simplest way to test if a Windows-managed host is available to receive our commands. I’m Luca Berton and welcome to today’s episode of Ansible Pilot.
Ansible module win_ping
Today we’re talking about Ansible module win_ping.
The full name is ansible.windows.win_ping
, which means that is part of the collection of the “windows” modules of ansible. Previously was part of the built-in collection.
It’s a module pretty stable and out for years.
It verifies the ability of Ansible to login to the managed host and that there is a shell, usually PowerShell, that is able to execute our code.
So it’s pretty different for the ping in the network context.
It’s the Windows corresponding to the Ansible ping module.
Main Parameters
- data string - pong
Main Return Values
- ping string success pong
People usually don’t specify any parameters or use the return value.
The win_ping
module usually delivers the pong
text to the endpoint.
It’s possible to personalize the text using the “data” parameter.
The return value is the “ping” string, that contains the same string of the data input parameter.
If we keep the default value we are going to use “pong” as a parameter and as the return value.
Playbook
Are you ready to make your hands dirty? Let’s jump in a quick live Playbook of a playbook about the win_ping module.
- win_ping.yml
---
- name: win_ping module Playbook
hosts: all
become: false
gather_facts: false
tasks:
- name: test connection
ansible.windows.win_ping:
Conclusion
Now you know better the Ansible module win_ping and you could use it successfully in your playbook. Subscribe to the YouTube channel, Medium, and Website, X (formerly Twitter) to not miss the next episode of the Ansible Pilot.
Academy
Learn the Ansible automation technology with some real-life examples in my Udemy 300+ Lessons Video Course.
My book Ansible By Examples: 200+ Automation Examples For Linux and Windows System Administrator and DevOps
Donate
Want to keep this project going? Please donate