Test Windows host availability - Ansible module win_ping
Deep dive into the Ansible module win_ping in the collection ansible.windows to test the access to a managed Windows host and that that there is a shell usually PowerShell available. Live demo and Ansible playbook included.
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.
- data string - pong
Main Return Values
- ping string success pong
People usually don’t specify any parameters or use the return value.
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.
The Best Resources For Ansible
- Learn Ansible Automation in 250+examples & practical lessons: Learn Ansible with some real-life examples of how to use the most common modules and Ansible Playbook
- Ansible by Examples: 200+ Automation Examples For Linux and Windows System Administrator and DevOps
- Ansible For Windows By Examples: 50+ Automation Examples For Windows System Administrator And DevOps
- Ansible For Linux by Examples: 100+ Automation Examples For Linux System Administrator and DevOps
- Ansible Linux Filesystem By Examples: 40+ Automation Examples on Linux File and Directory Operation for Modern IT Infrastructure
- Ansible For Containers and Kubernetes By Examples: 20+ Automation Examples To Automate Containers, Kubernetes and OpenShift
- Ansible For Security by Examples: 100+ Automation Examples to Automate Security and Verify Compliance for IT Modern Infrastructure
- Ansible Tips and Tricks: 10+ Ansible Examples to Save Time and Automate More Tasks
- Ansible Linux Users & Groups By Examples: 20+ Automation Examples on Linux Users and Groups Operation for Modern IT Infrastructure
- Ansible For PostgreSQL by Examples: 10+ Examples To Automate Your PostgreSQL database
- Ansible For Amazon Web Services AWS By Examples: 10+ Examples To Automate Your AWS Modern Infrastructure
Are you ready to make your hands dirty? Let’s jump in a quick live demo of a playbook about the win_ping module.
--- - name: win_ping module demo hosts: all become: false gather_facts: false tasks: - name: test connection ansible.windows.win_ping:
code with ❤️ in GitHub
Now you know better the Ansible module win_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.
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
Want to keep this project going? Please donate