Connection problem with a windows client from redhat server

Im new to ansible .Getting connection refused error while doing ping to windows client machines. Could any one help me where i am doing wrong.

ansible server OS version: REDHAT 6.7

client os: windows 2012 R2
client firewall status: disabled
Im able to do ping /telnet to client machine from server.

getting connection error while doing ping

`
[root@stonecold ansible]# ansible windows -i hosts -m win_ping -vvvvv
/usr/lib/python2.6/site-packages/pycrypto-2.6.1-py2.6-linux-x86_64.egg/Crypto/Util/number.py:57: PowmInsecureWarning: Not using mpz_powm_sec. You should rebuild using libgmp >= 5 to avoid timing attack vulnerability.
_warn(“Not using mpz_powm_sec. You should rebuild using libgmp >= 5 to avoid timing attack vulnerability.”, PowmInsecureWarning)
No config file found; using defaults
Loaded callback minimal of type stdout, v2.0
Using module file /usr/lib/python2.6/site-packages/ansible-2.2.0-py2.6.egg/ansible/modules/core/windows/win_ping.ps1
<my_machine> ESTABLISH WINRM CONNECTION FOR USER: Administrator on PORT 5986 TO my_machine
<my_mahcine> WINRM CONNECT: transport=ssl endpoint=https://my_machine:5986/wsman
<my_machine> WINRM CONNECTION ERROR: 500 WinRMTransport. [Errno 111] Connection refused
Traceback (most recent call last):
File “/usr/lib/python2.6/site-packages/ansible-2.2.0-py2.6.egg/ansible/plugins/connection/winrm.py”, line 152, in _winrm_connect
self.shell_id = protocol.open_shell(codepage=65001) # UTF-8
File “/usr/lib/python2.6/site-packages/winrm/protocol.py”, line 121, in open_shell
rs = self.send_message(xmltodict.unparse(rq))
File “/usr/lib/python2.6/site-packages/winrm/protocol.py”, line 193, in send_message
return self.transport.send_message(message)
File “/usr/lib/python2.6/site-packages/winrm/transport.py”, line 138, in send_message
raise WinRMTransportError(‘http’, ex.reason)
WinRMTransportError: 500 WinRMTransport. [Errno 111] Connection refused

my_machine | UNREACHABLE! => {
“changed”: false,
“msg”: “ssl: 500 WinRMTransport. [Errno 111] Connection refused”,
“unreachable”: true
}
`

Host file:

[windows] my_machine

Yaml file:
`

ansible_user: Administrator
ansible_pass: my_pass
ansible_port: 5986
ansible_connection: winrm
ansible_winrm_server_cert_validation: ignore
`

Regards,
Mahi

There have been lots of threads here recently regarding windows
targets, search the archive for winrm.

Maybe Jeff, Matt and Mike can help...

Johannes

Have you run the configure for ansible powershell script from the Ansible documentation?

Thanks for reply Mike.

Yes. its working fine after running ps1 script in windows machine. (source: https://github.com/ansible/ansible/blob/devel/examples/scripts/ConfigureRemotingForAnsible.ps1).

Could you please confirm, do i need to run on every windows machine to access.(one time) ?

Regards,
Mahi.

Hello Mahi,

Yes, that is correct you need to run the script once on each host you want Ansible to manage. You can use Group Policy to push the script to your hosts and after that Ansible takes care of the management.

Thanks…