# i CANT connect to a windows server

**URL:** <https://forum.ansible.com/t/i-cant-connect-to-a-windows-server/23018>\
**Category:** Ansible Project\
**Tags:** windows\
**Created:** [November 14, 2016, 1:21pm UTC](https://forum.ansible.com/t/i-cant-connect-to-a-windows-server/23018 "2016-11-14T13:21:15Z")\
**Posts on this page:** 12\
**Page:** 1

<div class="post-metadata">

**Author:** ![Aitor\_Gomez](https://avatars.discourse-cdn.com/v4/letter/a/ccd318/32.png) [@Aitor\_Gomez](https://forum.ansible.com/u/Aitor_Gomez)\
**Post date:** [November 14, 2016, 1:21pm UTC](https://forum.ansible.com/t/i-cant-connect-to-a-windows-server/23018/1 "2016-11-14T13:21:15Z")

</div>

i configured **host**

[windows]  
[server.domain.es](http://server.domain.es/)

**Windows.yml**

ansible\_user: domain\user  
ansible\_password: passw  
ansible\_port: 5986  
ansible\_connection: winrm  
ansible\_winrm\_server\_cert\_validation: ignore

I’ve tried it too:  
ansible\_user: localuser (in the server)

**BUT when i run the playbook:**

1. \<[server.domain.es](http://server.domain.es/)\> ESTABLISH SSH CONNECTION FOR USER: USER

2. \<[server.domain.es](http://server.domain.es/)\> SSH: ansible.cfg set ssh\_args: (-o)(ControlMaster=auto)(-o)(ControlPersist=60s)

3. \<[server.domain.es](http://server.domain.es/)\> SSH: ANSIBLE\_HOST\_KEY\_CHECKING/host\_key\_checking disabled: (-o)(StrictHostKeyChecking=no)

4. \<[server.domain.es](http://server.domain.es/)\> SSH: ANSIBLE\_REMOTE\_USER/remote\_user/ansible\_user/user/-u set: (-o)(User=USER)

5. \<[server.domain.es](http://server.domain.es/)\> SSH: ANSIBLE\_TIMEOUT/timeout set: (-o)(ConnectTimeout=10)

6. \<[server.domain.es](http://server.domain.es/)\> SSH: PlayContext set ssh\_common\_args: ()

7. \<[server.domain.es](http://server.domain.es/)\> SSH: PlayContext set ssh\_extra\_args: ()

8. \<[server.domain.es](http://server.domain.es/)\> SSH: found only ControlPersist; added ControlPath: (-o)(ControlPath=/tmp/ansible\_tower\_CMbKBj/cp/ansible-ssh-%h-%p-%r)

9. \<[server.domain.es](http://server.domain.es/)\> SSH: EXEC sshpass -d19 ssh -C -vvv -o ControlMaster=auto -o ControlPersist=60s -o StrictHostKeyChecking=no -o User=USER -o ConnectTimeout=10 -o ControlPath=/tmp/ansible\_tower\_CMbKBj/cp/ansible-ssh-%h-%p-%r [server.domain.es](http://server.domain.es/) ‘/bin/sh -c ‘"’"’( umask 77 && mkdir -p “`echo $HOME/.ansible/tmp/ansible-tmp-1479111892.51-133707384640152`” && echo ansible-tmp-1479111892.51-133707384640152=“`echo $HOME/.ansible/tmp/ansible-tmp-1479111892.51-133707384640152`” ) && sleep 0’“'”‘’

10. fatal: [[server.domain.es](http://server.domain.es/)]: UNREACHABLE! =\> {“changed”: false, “msg”: “Failed to connect to the host via ssh.”, “unreachable”: true}

11. [WARNING]: Could not create

---

<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:** [November 14, 2016, 7:39pm UTC](https://forum.ansible.com/t/i-cant-connect-to-a-windows-server/23018/2 "2016-11-14T19:39:40Z")

</div>

The user isn't in the correct user@domain format firstly. Have you setup kerberos as per the Ansible documentation? It might also be an idea to check what version of pywinrm you're running. What version of Ansible is the server running?

---

<div class="post-metadata">

**Author:** ![Aitor\_Gomez](https://avatars.discourse-cdn.com/v4/letter/a/ccd318/32.png) [@Aitor\_Gomez](https://forum.ansible.com/u/Aitor_Gomez)\
**Post date:** [November 15, 2016, 8:02am UTC](https://forum.ansible.com/t/i-cant-connect-to-a-windows-server/23018/3 "2016-11-15T08:02:41Z")

</div>

No i not configure kerberos (other partner install ansible ansible 2.1.1.0 in our organization and tell us is not necesary install kerberos). pywinrm-0.2.1

---

<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:** [November 15, 2016, 8:06am UTC](https://forum.ansible.com/t/i-cant-connect-to-a-windows-server/23018/4 "2016-11-15T08:06:42Z")

</div>

It might be an idea to take a look at the Ansible documentation in that case [http://docs.ansible.com/ansible/intro\_windows.html](http://docs.ansible.com/ansible/intro_windows.html) . That will give you the rundown of what is needed.

---

<div class="post-metadata">

**Author:** ![j.r.hawkesworth](https://avatars.discourse-cdn.com/v4/letter/j/a3d4f5/32.png) [@j.r.hawkesworth](https://forum.ansible.com/u/j.r.hawkesworth)\
**Post date:** [November 15, 2016, 8:07am UTC](https://forum.ansible.com/t/i-cant-connect-to-a-windows-server/23018/5 "2016-11-15T08:07:32Z")

</div>

Please show us your playbook.

Your group\_vars file must be called ‘windows.yml’ not ‘Windows.yml’ otherwise the group name you have defined will not match (it is case-sensitive) and ansible will default to ssh connection.

Also check your playbook looks like

`

---

<div class="post-metadata">

**Author:** ![Aitor\_Gomez](https://avatars.discourse-cdn.com/v4/letter/a/ccd318/32.png) [@Aitor\_Gomez](https://forum.ansible.com/u/Aitor_Gomez)\
**Post date:** [November 15, 2016, 8:37am UTC](https://forum.ansible.com/t/i-cant-connect-to-a-windows-server/23018/6 "2016-11-15T08:37:20Z")

</div>

yes the file name windows.yml

**This is my playbook**

- name: raw module example  
hosts: [server.domain.es](http://server.domain.es/)  
tasks:
- name: Move file on remote Windows Server from one location to another  
raw: CMD /C “MOVE /Y D:\origen\prueba.txt D:\destino\prueba.txt”

**RESULT:**  
**.**  
**.**  
**.**  
**.**  
fatal: [[s](http://srwbdwp02.mutua.es/)erver.domain.is]: UNREACHABLE! =\> {“changed”: false, “msg”: “Failed to connect to the host via ssh.”, “unreachable”: true}

**if i change to**

- name: raw module example  
hosts: windows  
tasks:
- name: Move file on remote Windows Server from one location to another  
raw: CMD /C “MOVE /Y D:\origen\prueba.txt D:\destino\prueba.txt”

**RESULT** :succesfull but all skipped

Using /etc/ansible/ansible.cfg as config file  
SSH password:  
Loaded callback default of type stdout, v2.0  
PLAYBOOK: pruebaaitorwin.yml \*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*  
1 plays in pruebaaitorwin.yml  
PLAY [raw module example] \*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*  
skipping: no hosts matched  
PLAY RECAP \*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*

---

<div class="post-metadata">

**Author:** ![Aitor\_Gomez](https://avatars.discourse-cdn.com/v4/letter/a/ccd318/32.png) [@Aitor\_Gomez](https://forum.ansible.com/u/Aitor_Gomez)\
**Post date:** [November 15, 2016, 8:52am UTC](https://forum.ansible.com/t/i-cant-connect-to-a-windows-server/23018/7 "2016-11-15T08:52:19Z")

</div>

yeah thanks… i will ask if i can install kerbeos module… but the partnet said me is not neccesary… im very begginer with this… thanks

---

<div class="post-metadata">

**Author:** ![j.r.hawkesworth](https://avatars.discourse-cdn.com/v4/letter/j/a3d4f5/32.png) [@j.r.hawkesworth](https://forum.ansible.com/u/j.r.hawkesworth)\
**Post date:** [November 15, 2016, 12:54pm UTC](https://forum.ansible.com/t/i-cant-connect-to-a-windows-server/23018/8 "2016-11-15T12:54:25Z")

</div>

Ok it looks like your inventory and group vars aren’t matching up at the moment.

Please show your ansible-playbook command line.

Your ansible hosts file should be in in  
/etc/ansible/hosts

and group vars in  
/etc/ansible/group\_vars/windows.yml

(You can use other locations but must use -i /path/to/ansible/hosts/file and the group\_vars must be in sub directory under wherever your ansible inventory file is).

You can also configure in ansible.cfg so worth checking that ansible is configured in the default way.

Also you must use a local account name e.g. Administrator if you have not set up kerberos.

If you are using kerberos, please use username@realm (not username\realm or username/realm) otherwise kerberos will not be used.

Hope this helps,

Jon

---

<div class="post-metadata">

**Author:** ![Aitor\_Gomez](https://avatars.discourse-cdn.com/v4/letter/a/ccd318/32.png) [@Aitor\_Gomez](https://forum.ansible.com/u/Aitor_Gomez)\
**Post date:** [November 15, 2016, 1:27pm UTC](https://forum.ansible.com/t/i-cant-connect-to-a-windows-server/23018/9 "2016-11-15T13:27:35Z")

</div>

thanks ok y will try with a local administrator

In host file… i must configure servername.domain.es or IP ?

---

<div class="post-metadata">

**Author:** ![Aitor\_Gomez](https://avatars.discourse-cdn.com/v4/letter/a/ccd318/32.png) [@Aitor\_Gomez](https://forum.ansible.com/u/Aitor_Gomez)\
**Post date:** [November 15, 2016, 2:59pm UTC](https://forum.ansible.com/t/i-cant-connect-to-a-windows-server/23018/10 "2016-11-15T14:59:05Z")

</div>

ok… works when i execute in ansible (whit local user)

But in Tower not works… i will check again the Tower configuration

---

<div class="post-metadata">

**Author:** ![Aitor\_Gomez](https://avatars.discourse-cdn.com/v4/letter/a/ccd318/32.png) [@Aitor\_Gomez](https://forum.ansible.com/u/Aitor_Gomez)\
**Post date:** [November 18, 2016, 12:43pm UTC](https://forum.ansible.com/t/i-cant-connect-to-a-windows-server/23018/11 "2016-11-18T12:43:27Z")

</div>

is posible confugure LDAP and not Kerberos?

---

<div class="post-metadata">

**Author:** ![j.r.hawkesworth](https://avatars.discourse-cdn.com/v4/letter/j/a3d4f5/32.png) [@j.r.hawkesworth](https://forum.ansible.com/u/j.r.hawkesworth)\
**Post date:** [November 25, 2016, 1:11pm UTC](https://forum.ansible.com/t/i-cant-connect-to-a-windows-server/23018/12 "2016-11-25T13:11:05Z")

</div>

Not something I have heard of anyone trying.

If you have working on command line but not in Tower, I suggest you contact Tower support for help.

Jon
