Bootstrap FreeKB - Ansible - Windows ping module (win_ping)
Ansible - Windows ping module (win_ping)

Updated:   |  Ansible articles

If you are not familiar with modules, check out Ansible - Getting Started with Modules.

The ping module will ping Linux nodes whereas the win_ping module is used to ping Windows hosts. In this example, the Ansible ad hoc command is used to ping every Windows node defined in win_hosts.yml using win_ping.

~]# ansible all --inventory win_hosts.yml --module win_ping
server1.example.com | SUCCESS => {
    "changed": false,
    "ping": "pong"
}

 

Or, like this, in a playbook.

---
- hosts: all
  tasks:
  - win_ping:
...

 

Running this playbook will return something like this.

PLAY [all]

TASK [Gathering Facts]
ok: [server1.example.com]

TASK [ping]
ok: [server1.example.com]

PLAY RECAP
server1.example.com   : ok=2  changed=0  unreachable=0  failed=0

 

It's important to recognize that the register module will not be able to register the ping output. For example, let's say you've this playbook.

---
- hosts: all
  tasks:
  - win_ping:
    register: out

  - debug:
      var: out

 

Running this playbook should return the following where we can see that the ping output is not being captured.

PLAY [all]

TASK [Gathering Facts]
ok: [server1.example.com]

TASK [ping]
ok: [server1.example.com]

TASK [debug]
ok: [server1.example.com] => {
    "out": {
        "changed": false,
        "failed": false,
        "ping": "pong"
    }
}

PLAY RECAP
server1.example.com   : ok=3  changed=0  unreachable=0  failed=0

 

 




Did you find this article helpful?

If so, consider buying me a coffee over at Buy Me A Coffee



Comments


Add a Comment


Please enter 868b79 in the box below so that we can be sure you are a human.