In Ansible, How to connect to windows host?
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
If you using fresh azure vm and aws ec2 and facing issue
"changed": false,
"msg": "ssl: HTTPSConnectionPool(host='IP Address', port=5986): Max retries exceeded with url: /wsman (Caused by NewConnectionError('<urllib3.connection.VerifiedHTTPSConnection object at 0x7f9650462390>: Failed to establish a new connection: [Errno 111] Connection refused',))",
"unreachable": true" "
Solution: Just add below rules in windows VM in Inbound rules.
- WINRM-HTTPS
- ICMP4