pinging both Windows and Linux hosts

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: (:slight_smile: , 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: (:slight_smile: , 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

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

ansible all -m wait_for_connection

Hope this helps

Jon