# Connection issues to Windows Server - Host not Reachable

**URL:** <https://forum.ansible.com/t/connection-issues-to-windows-server-host-not-reachable/22249>\
**Category:** Ansible Project\
**Tags:** windows\
**Created:** [August 9, 2016, 7:16pm UTC](https://forum.ansible.com/t/connection-issues-to-windows-server-host-not-reachable/22249 "2016-08-09T19:16:15Z")\
**Posts on this page:** 14\
**Page:** 1

<div class="post-metadata">

**Author:** ![Anfield](https://avatars.discourse-cdn.com/v4/letter/a/dec6dc/32.png) [@Anfield](https://forum.ansible.com/u/Anfield)\
**Post date:** [August 9, 2016, 7:16pm UTC](https://forum.ansible.com/t/connection-issues-to-windows-server-host-not-reachable/22249/1 "2016-08-09T19:16:15Z")

</div>

Trying to connect from Ansible server to windows host and getting connection errors

[root@localhost ansible]# ansible -i hosts -m ping all  
10.10.128.0 | UNREACHABLE! =\> {  
“changed”: false,  
“msg”: “Failed to connect to the host via ssh.”,  
“unreachable”: true

-Configured windows.yml, added the windows host in the ansible hosts file, and can ping both machines from each other. Also ran the powershell script on the windows box

Is there something I am missing?

---

<div class="post-metadata">

**Author:** ![Justin\_Dugan](https://avatars.discourse-cdn.com/v4/letter/j/9de053/32.png) [@Justin\_Dugan](https://forum.ansible.com/u/Justin_Dugan)\
**Post date:** [August 9, 2016, 8:27pm UTC](https://forum.ansible.com/t/connection-issues-to-windows-server-host-not-reachable/22249/2 "2016-08-09T20:27:01Z")

</div>

The error states it’s trying to use ssh so you are missing some configuration entries from the windows documentation page ([http://docs.ansible.com/ansible/intro\_windows.html](http://docs.ansible.com/ansible/intro_windows.html)). One of the entries would be:

ansible\_connection: winrm

---

<div class="post-metadata">

**Author:** ![Anfield](https://avatars.discourse-cdn.com/v4/letter/a/dec6dc/32.png) [@Anfield](https://forum.ansible.com/u/Anfield)\
**Post date:** [August 9, 2016, 8:31pm UTC](https://forum.ansible.com/t/connection-issues-to-windows-server-host-not-reachable/22249/3 "2016-08-09T20:31:48Z")

</div>

Thanks. I think I have those configured though

ansible\_ssh\_user: User  
ansible\_ssh\_pass: Pass  
ansible\_ssh\_port: 5986  
ansible\_connection: winrm

---

<div class="post-metadata">

**Author:** ![Justin\_Dugan](https://avatars.discourse-cdn.com/v4/letter/j/9de053/32.png) [@Justin\_Dugan](https://forum.ansible.com/u/Justin_Dugan)\
**Post date:** [August 9, 2016, 8:46pm UTC](https://forum.ansible.com/t/connection-issues-to-windows-server-host-not-reachable/22249/4 "2016-08-09T20:46:48Z")

</div>

It shouldn’t be using ssh for windows. Here are some other entries I am using:

ansible\_winrm\_transport: kerberos

ansible\_winrm\_kerberos\_delegation: true

I’m not familiar with you configuration, so I’m not sure if these apply.

---

<div class="post-metadata">

**Author:** ![Anfield](https://avatars.discourse-cdn.com/v4/letter/a/dec6dc/32.png) [@Anfield](https://forum.ansible.com/u/Anfield)\
**Post date:** [August 9, 2016, 10:05pm UTC](https://forum.ansible.com/t/connection-issues-to-windows-server-host-not-reachable/22249/5 "2016-08-09T22:05:08Z")

</div>

I agree!. I am new to Ansible… I just have two virtual machines on my desktop and all that I have configured is listed below -

-Configured windows.yml - with the following -

ansible\_ssh\_user: User  
ansible\_ssh\_pass: Pass  
ansible\_ssh\_port: 5986  
ansible\_connection: winrm

, added the windows host in the ansible hosts file under [windows], and can ping both machines from each other. Also ran the powershell script on the windows box.

I havent got anything else configured so it would have to use the local admin acct on the windows box.

Any suggestions?

Thanks!

---

<div class="post-metadata">

**Author:** ![Anfield](https://avatars.discourse-cdn.com/v4/letter/a/dec6dc/32.png) [@Anfield](https://forum.ansible.com/u/Anfield)\
**Post date:** [August 10, 2016, 1:27pm UTC](https://forum.ansible.com/t/connection-issues-to-windows-server-host-not-reachable/22249/6 "2016-08-10T13:27:21Z")

</div>

Hi - any further thoughts?

---

<div class="post-metadata">

**Author:** ![Mike\_Fennemore](https://avatars.discourse-cdn.com/v4/letter/m/45deac/32.png) [@Mike\_Fennemore](https://forum.ansible.com/u/Mike_Fennemore)\
**Post date:** [August 10, 2016, 1:32pm UTC](https://forum.ansible.com/t/connection-issues-to-windows-server-host-not-reachable/22249/7 "2016-08-10T13:32:38Z")

</div>

You made mention of the windows.yml. Are you making use of group\_vars?

---

<div class="post-metadata">

**Author:** ![Mike\_Fennemore](https://avatars.discourse-cdn.com/v4/letter/m/45deac/32.png) [@Mike\_Fennemore](https://forum.ansible.com/u/Mike_Fennemore)\
**Post date:** [August 10, 2016, 1:49pm UTC](https://forum.ansible.com/t/connection-issues-to-windows-server-host-not-reachable/22249/8 "2016-08-10T13:49:43Z")

</div>

[http://docs.ansible.com/ansible/intro\_windows.html](http://docs.ansible.com/ansible/intro_windows.html)

Note

Ansible 2.0 has deprecated the “ssh” from `ansible_ssh_user`, `ansible_ssh_host`, and `ansible_ssh_port` to become `ansible_user`, `ansible_host`, and`ansible_port`. If you are using a version of Ansible prior to 2.0, you should continue using the older style variables (`ansible_ssh_*`). These shorter variables are ignored, without warning, in older versions of Ansible.

In group\_vars/windows.yml, define the following inventory variables:

```auto
# it is suggested that these be encrypted with ansible-vault:
# ansible-vault edit group_vars/windows.yml

ansible_user: Administrator
ansible_password: SecretPasswordGoesHere
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

```

---

<div class="post-metadata">

**Author:** ![Justin\_Dugan](https://avatars.discourse-cdn.com/v4/letter/j/9de053/32.png) [@Justin\_Dugan](https://forum.ansible.com/u/Justin_Dugan)\
**Post date:** [August 10, 2016, 1:54pm UTC](https://forum.ansible.com/t/connection-issues-to-windows-server-host-not-reachable/22249/9 "2016-08-10T13:54:37Z")

</div>

What version of ansible are you using?

---

<div class="post-metadata">

**Author:** ![Anfield](https://avatars.discourse-cdn.com/v4/letter/a/dec6dc/32.png) [@Anfield](https://forum.ansible.com/u/Anfield)\
**Post date:** [August 10, 2016, 2:25pm UTC](https://forum.ansible.com/t/connection-issues-to-windows-server-host-not-reachable/22249/10 "2016-08-10T14:25:46Z")

</div>

> > > Using version 2.1.0.0

Have not created group\_vars/windows.yml. I just created windows.yml under the ansible directory. Do I need to create the group\_vars directory first?

---

<div class="post-metadata">

**Author:** ![Mike\_Fennemore](https://avatars.discourse-cdn.com/v4/letter/m/45deac/32.png) [@Mike\_Fennemore](https://forum.ansible.com/u/Mike_Fennemore)\
**Post date:** [August 10, 2016, 2:47pm UTC](https://forum.ansible.com/t/connection-issues-to-windows-server-host-not-reachable/22249/11 "2016-08-10T14:47:43Z")

</div>

There are two ways of approaching it, either put the connection details into the inventory or create a group\_vars folder with your windows.yml file in it. Keep in mind that the group\_vars folder needs to be at the same level as your inventory file. So for instance if your hosts file is at /etc/ansible/hosts then your group\_vars folder would need to be /etc/ansible/group\_vars.

---

<div class="post-metadata">

**Author:** ![Anfield](https://avatars.discourse-cdn.com/v4/letter/a/dec6dc/32.png) [@Anfield](https://forum.ansible.com/u/Anfield)\
**Post date:** [August 10, 2016, 2:59pm UTC](https://forum.ansible.com/t/connection-issues-to-windows-server-host-not-reachable/22249/12 "2016-08-10T14:59:02Z")

</div>

> > Thanks for the update. I created the group\_vars and added the windows.yml in there/ Tried an ansible all -m ping -vvvv and get the following error

On the linux control machine when I look at the python version it is 2.7.5, do I need to update that?

Error msg -

Loaded callback minimal of type stdout, v2.0  
An exception occurred during task execution. The full traceback is:  
Traceback (most recent call last):  
File “/usr/lib/python2.7/site-packages/ansible/executor/task\_executor.py”, line 124, in run  
res = self.\_execute()  
File “/usr/lib/python2.7/site-packages/ansible/executor/task\_executor.py”, line 411, in \_execute  
self.\_connection = self.\_get\_connection(variables=variables, templar=templar)  
File “/usr/lib/python2.7/site-packages/ansible/executor/task\_executor.py”, line 636, in \_get\_connection  
connection = self.\_shared\_loader\_obj.connection\_loader.get(conn\_type, self.\_play\_context, self.\_new\_stdin)  
File “/usr/lib/python2.7/site-packages/ansible/plugins/ **init**.py”, line 333, in get  
self.\_module\_cache[path] = self.\_load\_module\_source(‘.’.join([self.package, name]), path)  
File “/usr/lib/python2.7/site-packages/ansible/plugins/ **init**.py”, line 319, in \_load\_module\_source  
module = imp.load\_source(name, path, module\_file)  
File “/usr/lib/python2.7/site-packages/ansible/plugins/connection/winrm.py”, line 28, in   
import xmltodict  
ImportError: No module named xmltodict

10.10.128.0 | FAILED! =\> {  
“failed”: true,  
“msg”: “Unexpected failure during module execution.”,  
“stdout”: “”

---

<div class="post-metadata">

**Author:** ![Mike\_Fennemore](https://avatars.discourse-cdn.com/v4/letter/m/45deac/32.png) [@Mike\_Fennemore](https://forum.ansible.com/u/Mike_Fennemore)\
**Post date:** [August 10, 2016, 4:01pm UTC](https://forum.ansible.com/t/connection-issues-to-windows-server-host-not-reachable/22249/13 "2016-08-10T16:01:49Z")

</div>

You used the ping module which is built for Linux systems. Try win\_ping instead.

---

<div class="post-metadata">

**Author:** ![Anfield](https://avatars.discourse-cdn.com/v4/letter/a/dec6dc/32.png) [@Anfield](https://forum.ansible.com/u/Anfield)\
**Post date:** [August 10, 2016, 4:26pm UTC](https://forum.ansible.com/t/connection-issues-to-windows-server-host-not-reachable/22249/14 "2016-08-10T16:26:06Z")

</div>

I thought the ping all command would literally ping all hosts. Anyway I tried → ansible 10.10.128.0 -m win\_ping, and I think this looks good

10.10.128.0 | **SUCCESS** =\> {  
“changed”: false,  
“ping”: “pong”  
}
