I have been stuck with Ansible window module. I am just trying to ping windows machine.But i get 'connect timeout'
hosts
[windows]
192.168.1.13
group_vars/windows.yaml
ansible_user: raja
ansible_password: myPassword
ansible_port: 5986
ansible_connection: winrm
ansible_winrm_server_cert_validation: ignore
And While I run : ansible windows -vvv -i hosts -m win_ping
Using /etc/ansible/ansible.cfg as config file
<192.168.1.13> ESTABLISH WINRM CONNECTION FOR USER: raja on PORT 5986 TO 192.168.1.13
192.168.1.13 | UNREACHABLE! => {
"changed": false,
"msg": "ssl: HTTPSConnectionPool(host='192.168.1.13', port=5986): Max retries exceeded with url: /wsman (Caused by ConnectTimeoutError(<requests.packages.urllib3.connection.VerifiedHTTPSConnection object at 0x7fcb12024a90>, 'Connection to 192.168.1.13 timed out. (connect timeout=30)'))",
"unreachable": true
}
However I can ping that windows machine using ping 192.168.1.13
You need to prep your windows machine for PowerShell remote management, otherwise ansible won't be able to connect to it. For most features to work you will need at least PowerShell 3.0 installed (which is only supported on Windows 7 SP1 or Windows Server 2008 SP1 and later versions), and also run this script, which will not only enable WinRM, but also install some necessary certificates for the connection to work.
Once you donwload the ConfigureRemotingForAnsible.ps1
file the following command from command line should do the job:
powershell.exe -File ConfigureRemotingForAnsible.ps1