WinRM - running ansible on widnows returning error

How can I let ansible run on windows node(windows server 2012 machine) ??
I ran the belwo commands on power shell before running the ansible script :

netsh advfirewall firewall add rule name=“Allow WinRM (Http)” dir=in localport=5985 protocol=tcp action=allow enable=yes

netsh advfirewall firewall add rule name=“Allow WinRM (Https)” dir=in localport=5986 protocol=tcp action=allow enable=yes

I am recieving the below error

fatal: [uat_cdxdb]: UNREACHABLE! => {

“changed”: false,

“msg”: “ssl: HTTPSConnectionPool(host=‘10.1.116.151’, port=5986): Max retries exceeded with url: /wsman (Caused by NewConnectionError(‘<urllib3.connection.VerifiedHTTPSConnection object at 0x108cfd450>: Failed to establish a new connection: [Errno 61] Connection refused’,))”,

“unreachable”: true

}

Run this PowerShell script on your windows machine: https://github.com/ansible/ansible/blob/devel/examples/scripts/ConfigureRemotingForAnsible.ps1

That will configure the necessary changes to allow Ansible to connect to windows.

is thier another way like doing manual steps or rules.
The client will not allow us to run the script on his amchines
could you please help or advice ?

You can look at the script and see what it does to enable the firewall rules. I find it amusing they won’t allow scripts when you can still run arbitrary commands.

Thanks

Jordan

I am enabling the below rules:

netsh advfirewall firewall add rule name=“Allow WinRM (Http)” dir=in localport=5985 protocol=tcp action=allow enable=yes

netsh advfirewall firewall add rule name=“Allow WinRM (Https)” dir=in localport=5986 protocol=tcp action=allow enable=yes

but it seems on https a certificate is needed !? cause I am still not able to run ansible on the windows server

Can you share winrm configuration?

I have not done it manually.

My be take a look at below article: https://www.virtualtothecore.com/en/configuring-windows-machines-for-ansible/

It looks like he was using SolarWinds Remote Execution Enabler for PowerShell: https://www.solarwinds.com/free-tools/remote-execution-enabler-for-powershell

Please find below the screent shot
I run the two rules command for http and https listener
and I run winrm qc

but its listining only to http

Yes you need a certificate for https just like any https endpoint. The Configure script will generate a self signed one for you as it is needlessly complex in older versions of PowerShell to generate your own.