# pinging both Windows and Linux hosts

**URL:** <https://forum.ansible.com/t/pinging-both-windows-and-linux-hosts/33534>\
**Category:** Ansible Project\
**Tags:** windows\
**Created:** [July 31, 2020, 5:04am UTC](https://forum.ansible.com/t/pinging-both-windows-and-linux-hosts/33534 "2020-07-31T05:04:09Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Ed\_Wong](https://avatars.discourse-cdn.com/v4/letter/e/87869e/32.png) [@Ed\_Wong](https://forum.ansible.com/u/Ed_Wong)\
**Post date:** [July 31, 2020, 5:04am UTC](https://forum.ansible.com/t/pinging-both-windows-and-linux-hosts/33534/1 "2020-07-31T05:04:09Z")

</div>

I have a mixed platform environment and have set up two Windows system (for testing out Ansible) along with the usual linux boxes.

I don’t know if I’m forgetting or misremembering; but I thought I had “ansible all -m ping” working for all hosts[Linux and Windows].

Just now, I tried “ansible winhost10 -m ping” and it failed.

winhost10 | FAILED! =\> {  
“ansible\_facts”: {  
“discovered\_interpreter\_python”: “/usr/bin/python”  
},  
“changed”: false,  
“module\_stderr”: "Exception calling "Create" with "1" argument(s): "At line:4 char:21\r\n+ def \_ansiballz\_main():\r\n+ ~\r\nAn expression was expected after ‘(’.\r\nAt line:13 char:27\r\n+ except (AttributeError, OSError):\r\n+ ~\r\nMissing argument in parameter list.\r\nAt line:15 char:29\r\n+ excludes = set((‘’, ‘.’, scriptdir))\r\n+ ~\r\nMissing expression after ‘,’.\r\nAt line:15 char:30\r\n+ excludes = set((‘’, ‘.’, scriptdir))\r\n+ ~~~~~~~~~\r\nUnexpected token ‘scriptdir’ in expression or statement.\r\nAt line:15 char:29\r\n+ excludes = set((‘’, ‘.’, scriptdir))\r\n+ ~\r\nMissing closing ‘)’ in expression.\r\nAt line:15 char:39\r\n+ excludes = set((‘’, ‘.’, scriptdir))\r\n+ ~\r\nUnexpected token ‘)’ in expression or statement.\r\nAt line:15 char:40\r\n+ excludes = set((‘’, ‘.’, scriptdir))\r\n+ ~\r\nUnexpected token ‘)’ in expression or statement.\r\nAt line:22 char:7\r\n+ if sys.version\_info \< (3,):\r\n+ ~\r\nMissing ‘(’ after ‘if’ in if statement.\r\nAt line:22 char:30\r\n+ if sys.version\_info \< (3,):\r\n+ ~\r\nMissing expression after ‘,’.\r\nAt line:22 char:25\r\n+ if sys.version\_info \< (3,):\r\n+ ~\r\nThe ‘\<’ operator is reserved for future use.\r\nNot all parse errors were reported. Correct the reported errors and try \r\nagain."\r\nAt line:10 char:1\r\n+ $exec\_wrapper = [ScriptBlock]::Create($split\_parts[0])\r\n+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\r\n + CategoryInfo : NotSpecified: (🙂 , MethodInvocationException\r\n + FullyQualifiedErrorId : ParseException\r\n \r\nThe expression after ‘&’ in a pipeline element produced an object that was not \r\nvalid. It must result in a command name, a script block, or a CommandInfo \r\nobject.\r\nAt line:11 char:2\r\n+ &$exec\_wrapper\r\n+ ~~~~~~~~~~~~~ \r\n + CategoryInfo : InvalidOperation: (🙂 , RuntimeException\r\n + FullyQualifiedErrorId : BadExpression\r\n ",  
“module\_stdout”: “”,  
“msg”: “MODULE FAILURE\nSee stdout/stderr for the exact error”,  
“rc”: 1  
}

So I’m guessing I’m misremembering.

So I did a “ansible winhost10 -m win\_ping” and it worked.

So is it possible when I do a “ansible all -m ping”, to get ansible to use “win\_ping” for Windows hosts and “ping” for the others?

Thanks

Ed

---

<div class="post-metadata">

**Author:** ![j.r.hawkesworth](https://avatars.discourse-cdn.com/v4/letter/j/a3d4f5/32.png) [@j.r.hawkesworth](https://forum.ansible.com/u/j.r.hawkesworth)\
**Post date:** [August 4, 2020, 4:25pm UTC](https://forum.ansible.com/t/pinging-both-windows-and-linux-hosts/33534/2 "2020-08-04T16:25:38Z")

</div>

Rather than ping/win\_ping you can use the cross-platform wait\_for\_connection module [https://docs.ansible.com/ansible/latest/modules/wait\_for\_connection\_module.html](https://docs.ansible.com/ansible/latest/modules/wait_for_connection_module.html)

ansible all -m wait\_for\_connection

Hope this helps

Jon
