Ansible Pilot

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.

Main Parameters

Main Return Values

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.

demo

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

Recap

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 and Twitter to not miss the next episode of the Ansible Pilot.

Academy

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

Want to keep this project going? Please donate

Trustpilot
Follow me

Subscribe not to miss any new releases

August 20, 2021

FREE Top 10 Best Practices

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