Ansible win_ping module getting timed out in windows

ansible ping timeout
ansible windows
max retries exceeded with url: /wsman
ansible windows host unreachable
ansible winrm connection retry
how to connect to windows machine from linux using ansible
configureremotingforansible ps1

I am new to Ansible and trying to use win_ping module to ping a Windows Server 2016 (EC2 instance). Ansible is on RHEL 7.3 control machine, I have pip and pywinrm installed in control machine:

sudo pip install "pywinrm>=0.2.2"

This is my inventory file:

test ansible_connection=winrm ansible_host=




This is the command I tried:

ansible all -i inventory -m win_ping

I am getting this error:

test | UNREACHABLE! => {
    "changed": false,
    "msg": "ssl: HTTPSConnectionPool(host='', port=5986): Max retries exceeded with url: /wsman (Caused by ConnectTimeoutError(<urllib3.connection.VerifiedHTTPSConnection object at 0x30df350>, 'Connection to timed out. (connect timeout=30)'))",
    "unreachable": true

In Windows Server 2016, Server Manager Remoting is already enabled by default, I validated it using Configure-SMremoting.exe -enable command. I did not made any configurations at Windows Server since this remoting is already enabled. Please let me know how to resolve this issue.

EDIT: Not sure if these steps are required or notm but I tried enabling PowerShell Remoting using this command:

Enable-PSRemoting -Force

Then tried powershell.exe -File ConfigureRemotingForAnsible.ps1 and I an getting error:

At C:\Users\Administrator\Desktop\ConfigureRemotingForAnsible.ps1:128 char:13
+ </a>        <a href="/business" class="js-selected-navigation-item na ...
+             ~
The '<' operator is reserved for future use.
At C:\Users\Administrator\Desktop\ConfigureRemotingForAnsible.ps1:130 char:13
+ </a>        <a href="/explore" class="js-selected-navigation-item nav ...
+             ~
The '<' operator is reserved for future use.
At C:\Users\Administrator\Desktop\ConfigureRemotingForAnsible.ps1:132 char:17
+ </a>            <a href="/marketplace" class="js-selected-navigation- ...
+                 ~
The '<' operator is reserved for future use.
At C:\Users\Administrator\Desktop\ConfigureRemotingForAnsible.ps1:134 char:13
+ </a>        <a href="/pricing" class="js-selected-navigation-item nav ...
+             ~
The '<' operator is reserved for future use.
At C:\Users\Administrator\Desktop\ConfigureRemotingForAnsible.ps1:136 char:11
+ </a>      </nav>
+           ~
The '<' operator is reserved for future use.
At C:\Users\Administrator\Desktop\ConfigureRemotingForAnsible.ps1:3221 char:227
+ ... g:0;display:inline"><input name="utf8" type="hidden" value="&#x2713;" ...
+                                                                 ~
The ampersand (&) character is not allowed. The & operator is reserved for future use; wrap an ampersand in double
quotation marks ("&") to pass it as part of a string.
At C:\Users\Administrator\Desktop\ConfigureRemotingForAnsible.ps1:3224 char:10
+ </form>  </div>
+          ~
The '<' operator is reserved for future use.
At C:\Users\Administrator\Desktop\ConfigureRemotingForAnsible.ps1:3252 char:11
+       <li>&copy; 2017 <span title="0.13767s from github-fe-df0f95a.cp ...
+           ~
The ampersand (&) character is not allowed. The & operator is reserved for future use; wrap an ampersand in double
quotation marks ("&") to pass it as part of a string.
At C:\Users\Administrator\Desktop\ConfigureRemotingForAnsible.ps1:3252 char:23
+       <li>&copy; 2017 <span title="0.13767s from github-fe-df0f95a.cp ...
+                       ~
The '<' operator is reserved for future use.
At C:\Users\Administrator\Desktop\ConfigureRemotingForAnsible.ps1:3252 char:29
+ ...  2017 <span title="0.13767s from ...
+                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Unexpected token 'title="0.13767s from">GitHub</span>' in expression or statement.
Not all parse errors were reported.  Correct the reported errors and try again.
    + CategoryInfo          : ParserError: (:) [], ParentContainsErrorRecordException
    + FullyQualifiedErrorId : RedirectionNotSupported

I guess I need to configure enable Remote Power Shell in my Windows Server to resolve this issue but not sure how to since I get the above erorr - please suggest.

I would go over windows logs. If they do not contain info you need - increase the verbosity. Ping relies on winrm being up. WinRM needs execution policy changes, service configuration, ssl certificates, etc. Maybe the safest path is to reconfigure ansible using the documentation.

The powershell remoting must be configured, in ec2 you can do this by adding user-data, running the script there, just paste the commands there.

Also, your ansible master machine must be able to connect to your target host, usually done by allowing it via security group, and creating the instance in that group.

So, in order to debug your stuff you should present the code/actions you did to setup security groups, possibly routes, and instance creation.

Connect to windows host timing out � Issue #19965 � ansible/ansible , ISSUE TYPE Bug Report COMPONENT NAME win_ping ANSIBLE VERSION ansible config file = /etc/ansible/ansible.cfg configured module search path = Default w/o overrides Connect to windows host timing out #19965 I even tried same thing with windows server 2012 and I get same errors. The official documentation on the ping module. Examples ¶ # Test connectivity to a windows host # ansible winserver -m win_ping - name : Example from an Ansible Playbook win_ping : - name : Induce an exception to see what happens win_ping : data : crash

This is probably an AWS side issue not an ansible issue. Is your ansible server allowed to talk to your Windows EC2 instance via security group rules? By default everything is denied. You'll need to allow ICMP coming from the ansible server's address in the Windows EC2 instance's security group rules as well as from the windows server in the ansible server security group rules (if your ansible server is also an EC2 instance). If the ansible server is not an EC2 instance, make sure your firewall isn't blocking ICMP in or out for some reason.

Are these two servers on the same subnet/VPC within your account? If not, you'll have to create a VPC peering connection between the VPCs they are located on and edit route tables to point VPCs to the peering connection if traffic is coming from / going to the other VPC. The purpose of this is so that the two instances in separate VPCs can recognize and communicate with each other

Ansible error: the connection attempt timed out, Hi guys, I try to connect with winrm to a Windows server 2016: winrm is /usr/lib/ python2.7/site-packages/ansible/modules/windows/win_ping. ansible_password: my_pass ansible_port: 5986 ansible_connection: winrm # The following is necessary for Python 2.7.9+ when using default WinRM self-signed certificates: ansible_winrm_server_cert_validation: ignore. I also run the ConfigureRemotingForAnsible.ps1 on windows10 host to configure WinRM. However, when I run the win_ping module it

I am probably late to the party, but I noticed the error you got when running powershell.exe -File ConfigureRemotingForAnsible.ps1. It's complaining about the syntax, and as far as I can tell you have HTML in that file. Did you maybe save the GitLab HTML page from the script?

Download the raw file here: and try again.

wait_for_connection – Waits until remote system is reachable/usable , Retries the transport connection after a timeout of connect_timeout . This module makes use of internal ansible transport (and configuration) and the ping/ win_ping module to guarantee This module is also supported for Windows targets. I have installed Ansible on a CentOS linux and created 2 files namely web.yml and inventory.yml. inventory.yml [web] ip of my windows host. web.yml. ansible_user: root ansible_password: Ansible2! ansible_port: 5986 ansible_connection: winrm ansible_winrm_cert_validation: ignore. When i run ansible web -i inventory.yml -m win_ping -vvvv i get

win_ping, For Network targets, use the net_ping module instead. Examples�. # Test connectivity to a windows host # ansible winserver -m win_ping� Ok, so you installed Ansible, all is good, you exchanged ssh keys between hosts and configured the hosts you want to connect in /etc/ansible/hosts. However, when you try to connect, running the ansible module ping to test connectivity you get:

Connecting to a Windows Host, Welcome to the first installment of our Windows-specific Getting Started series! will be executing your chosen Windows modules from) needs to run Linux. type ansible [host_group_name_in_inventory_file] -i hosts -m win_ping . an HTTP 401 or HTTP 500 error, timeout issues or a connection refusal. To do this, go to your control node’s terminal and type ansible [host_group_name_in_inventory_file] -i hosts -m win_ping. Your output should look like this: Your output should look like this: Note: The win_ prefix on all of the Windows modules indicates that they are implemented in PowerShell and not Python.

ansible win_ping is getting an error, The error message is pretty clear: "msg": "kerberos: requested auth method is kerberos, but requests_kerberos is not installed. To make use of Ansible Windows� ansible_winrm_transport: Specify one or more authentication transport options as a comma-separated list. By default, Ansible will use kerberos, basic if the kerberos module is installed and a realm is defined, otherwise it will be plaintext; ansible_winrm_server_cert_validation: Specify the server certificate validation mode (ignore or validate).