Loading...

Watch: 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 Playbook 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](/articles/test-host-availability-ansible-module-ping).

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

``yaml

---

  • name: win_ping module Playbook

hosts: all

become: false

gather_facts: false

tasks:

- name: test connection

ansible.windows.win_ping:

``

[code with ❤️ in GitHub](https://github.com/lucab85/ansible-pilot/tree/master/test%20host%20availability)

Conclusion

Now you know better the Ansible module win_ping and you could use it successfully in your playbook.

Read the full tutorial: Test Windows host availability - Ansible module win_ping