AnsiblePilot — Master Ansible Automation

AnsiblePilot is the leading resource for learning Ansible automation, DevOps, and infrastructure as code. Browse over 1,100 tutorials covering Ansible modules, playbooks, roles, collections, and real-world examples. Whether you are a beginner or an experienced engineer, our step-by-step guides help you automate Linux, Windows, cloud, containers, and network infrastructure.

Popular Topics

About Luca Berton

Luca Berton is an Ansible automation expert, author of "Ansible for VMware by Examples" and "Ansible for Kubernetes by Example" published by Apress, and creator of the Ansible Pilot YouTube channel. He shares practical automation knowledge through tutorials, books, and video courses to help IT professionals and DevOps engineers master infrastructure automation.

Ansible win_ping Module: Test Windows Host Connectivity (Examples)

By Luca Berton · Published 2024-01-01 · Category: installation

How to test Windows host availability using Ansible's win_ping module. Includes WinRM setup, troubleshooting connection failures, and inventory configuration for Windows.

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

code with ❤️ in GitHub

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

Testing Windows Connectivity

Basic win_ping test

Expected output:

win_ping in a playbook

Windows Inventory Setup

Troubleshooting Connection Failures

Error: "winrm or requests is not installed"

Error: "connection refused" or timeout

Enable WinRM on the Windows host (run as Administrator in PowerShell):

Error: "certificate verify failed"

Error: "authentication failed"

Check credentials and WinRM auth settings:

win_ping vs ping

| Module | Target | Protocol | Tests | |--------|--------|----------|-------| | ansible.windows.win_ping | Windows | WinRM/PSRP | WinRM + PowerShell | | ansible.builtin.ping | Linux/Unix | SSH | SSH + Python |

⚠️ Never use ping for Windows hosts — it will fail because it tries SSH + Python.

FAQ

Can I use SSH instead of WinRM?

Yes, if OpenSSH is installed on the Windows host (Windows 10+ / Server 2019+):

How do I test connectivity for all hosts at once?

win_ping works but tasks fail — why?

win_ping only tests basic connectivity. Tasks can fail due to: • Insufficient permissions (need Administrator for many operations) • Missing Windows features or PowerShell modules • Execution policy restrictions

Related ArticlesAnsible Become GuideAnsible for Windows Guide

Category: installation

Watch the video: Ansible win_ping Module: Test Windows Host Connectivity (Examples) — Video Tutorial

Browse all Ansible tutorials · AnsiblePilot Home