# connection with windows

**URL:** <https://forum.ansible.com/t/connection-with-windows/18563>\
**Category:** Ansible Project\
**Tags:** windows, ubuntu\
**Created:** [June 22, 2015, 9:51am UTC](https://forum.ansible.com/t/connection-with-windows/18563 "2015-06-22T09:51:54Z")\
**Posts on this page:** 15\
**Page:** 1

<div class="post-metadata">

**Author:** ![Guillaume\_Querso](https://avatars.discourse-cdn.com/v4/letter/g/cdc98d/32.png) [@Guillaume\_Querso](https://forum.ansible.com/u/Guillaume_Querso)\
**Post date:** [June 22, 2015, 9:51am UTC](https://forum.ansible.com/t/connection-with-windows/18563/1 "2015-06-22T09:51:54Z")

</div>

Hello, i am running ansible 1.9.1 on a Ubuntu server 14.04.2, my remote machine is a windows 7 sp1.  
i have the following files and error message, i don’t understand where the issue is…

/etc/ansible/group\_vars/windows.yml

ansible\_ssh\_user: AnsibleUser  
ansible\_ssh\_pass: ansiblepass  
ansible\_ssh\_port: 5986  
ansible\_connection: winrm

/etc/ansible/winplaybook.yml

- hosts: WIN-F6531IBP8HG tasks:
  - name: unarchive unarchive: src=/tmp/hello.txt.zip dest=C:\Users\Querso\Desktop

/etc/ansible/hosts

WIN-F6531IBP8HG

i have python 2.7.6 and i have the following error message:  
ansible-playbook /etc/ansible/winplaybook.yml -i WIN-F6531IBP8HG,

PLAY [WIN-F6531IBP8HG] \*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*

GATHERING FACTS \*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*  
fatal: [WIN-F6531IBP8HG] =\> SSH Error: Permission denied (publickey,password,keyboard-interactive).  
while connecting to 192.168.79.133:22  
It is sometimes useful to re-run the command using -vvvv, which prints SSH debug output to help diagnose the issue.

TASK: [unarchive] \*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*  
FATAL: no hosts matched or all hosts have already failed – aborting

PLAY RECAP \*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*  
to retry, use: --limit @/home/guillaume/winplaybook.retry

WIN-F6531IBP8HG : ok=0 changed=0 unreachable=1 failed=0

if i try to ping windows:  
ansible WIN-F6531IBP8HG -m win\_ping  
WIN-F6531IBP8HG | FAILED =\> SSH Error: Permission denied (publickey,password,keyboard-interactive).  
while connecting to 192.168.79.133:22  
It is sometimes useful to re-run the command using -vvvv, which prints SSH debug output to help diagnose the issue.

thanks for your help!!

---

<div class="post-metadata">

**Author:** ![Guillaume\_Querso](https://avatars.discourse-cdn.com/v4/letter/g/cdc98d/32.png) [@Guillaume\_Querso](https://forum.ansible.com/u/Guillaume_Querso)\
**Post date:** [June 22, 2015, 12:45pm UTC](https://forum.ansible.com/t/connection-with-windows/18563/2 "2015-06-22T12:45:03Z")

</div>

EDIT: my files are now

/etc/ansible/group\_vars/windows/windows.yml  
ansible\_ssh\_user: AnsibleUser  
ansible\_ssh\_pass: ansiblepass  
ansible\_ssh\_port: 5986  
ansible\_connection: winrm

/etc/ansible/hosts  
[windows]  
WIN-F6531IBP8NG

the ping is working but sometimes it fails with this message:  
WIN-F6531IBP8HG | FAILED \>\> {  
“failed”: true,  
“msg”: “\nProcess is terminated due to StackOverflowException.\n”,  
“parsed”: false  
}  
or this one:  
WIN-F6531IBP8HG | FAILED \>\> {  
“failed”: true,  
“msg”: “”,  
“parsed”: false  
}

but when i run the playbook, it still tries to connect via ssh and not winrm so it doesn’t seem to see my windows.yml file but i don’t know how to deal with this issue…

---

<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:** [June 22, 2015, 12:48pm UTC](https://forum.ansible.com/t/connection-with-windows/18563/3 "2015-06-22T12:48:43Z")

</div>

Looks like you just need to add your server into a group called windows - the example here shows the group  
[http://docs.ansible.com/intro\_windows.html#inventory](http://docs.ansible.com/intro_windows.html#inventory)

So your inventory file needs to look like this:

[windows]  
WIN-F6531IBP8HG

The group vars will then take effect for your host and ansible will know to connect via winrm instead of ssh, which it is trying at the moment (which isn’t going to work as Windows doesn’t understand SSH).

Hope this helps,

Jon

---

<div class="post-metadata">

**Author:** ![Guillaume\_Querso](https://avatars.discourse-cdn.com/v4/letter/g/cdc98d/32.png) [@Guillaume\_Querso](https://forum.ansible.com/u/Guillaume_Querso)\
**Post date:** [June 22, 2015, 12:56pm UTC](https://forum.ansible.com/t/connection-with-windows/18563/4 "2015-06-22T12:56:30Z")

</div>

i have done this as said in my edit but it is not working for the playbook. do i have anything else to do to make it run properly?

---

<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:** [June 22, 2015, 1:50pm UTC](https://forum.ansible.com/t/connection-with-windows/18563/5 "2015-06-22T13:50:22Z")

</div>

Looks like you have hit the windows management framework 3.0 bug described in the blue box here:

[http://docs.ansible.com/intro\_windows.html#windows-system-prep](http://docs.ansible.com/intro_windows.html#windows-system-prep)

Since win\_ping is working for you now, you just need to install the hotfix to get up and running:

[http://support.microsoft.com/kb/2842230](http://support.microsoft.com/kb/2842230)

Jon

---

<div class="post-metadata">

**Author:** ![Guillaume\_Querso](https://avatars.discourse-cdn.com/v4/letter/g/cdc98d/32.png) [@Guillaume\_Querso](https://forum.ansible.com/u/Guillaume_Querso)\
**Post date:** [June 22, 2015, 2:17pm UTC](https://forum.ansible.com/t/connection-with-windows/18563/6 "2015-06-22T14:17:29Z")

</div>

i can’t install the hotfix, i am stuck on the terms ans conditions page…  
is this bug related to ansible-playbook because i can make a ping but not run my playbook?

---

<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:** [June 22, 2015, 3:22pm UTC](https://forum.ansible.com/t/connection-with-windows/18563/7 "2015-06-22T15:22:50Z")

</div>

It is a bug in windows management framework which incorrectly sets the amount of memory available to processes connected via winrm - its really outside Ansible’s domain.

If you can’t install the hotfix another way to get round it is to install windows managment framework 4, which doesn’t have this particular bug (and has the advantage of giving you powershell 4.0 which has a number of useful extra features over powershell 3.0).

Hope this helps

Jon

---

<div class="post-metadata">

**Author:** ![Trond\_Hindenes](https://avatars.discourse-cdn.com/v4/letter/t/96bed5/32.png) [@Trond\_Hindenes](https://forum.ansible.com/u/Trond_Hindenes)\
**Post date:** [June 22, 2015, 11:48pm UTC](https://forum.ansible.com/t/connection-with-windows/18563/8 "2015-06-22T23:48:03Z")

</div>

On a side note: To me it looks like you’re trying to use the “unarchive” module on a windows node. That won’t work. You need to use a module listed in “Windows modules”: [http://docs.ansible.com/list\_of\_windows\_modules.html](http://docs.ansible.com/list_of_windows_modules.html)

---

<div class="post-metadata">

**Author:** ![Guillaume\_Querso](https://avatars.discourse-cdn.com/v4/letter/g/cdc98d/32.png) [@Guillaume\_Querso](https://forum.ansible.com/u/Guillaume_Querso)\
**Post date:** [June 23, 2015, 8:54am UTC](https://forum.ansible.com/t/connection-with-windows/18563/9 "2015-06-23T08:54:31Z")

</div>

thank you for your answer, indeed it is not a windows package but sadly it didn’t solved my problem…

---

<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:** [June 23, 2015, 9:05am UTC](https://forum.ansible.com/t/connection-with-windows/18563/10 "2015-06-23T09:05:14Z")

</div>

Maybe try different web browser to download the hotfix?  
You either need the hotfix or Windows Management Framework 4.0 as far as I can tell.  
Jon

---

<div class="post-metadata">

**Author:** ![Guillaume\_Querso](https://avatars.discourse-cdn.com/v4/letter/g/cdc98d/32.png) [@Guillaume\_Querso](https://forum.ansible.com/u/Guillaume_Querso)\
**Post date:** [June 23, 2015, 9:36am UTC](https://forum.ansible.com/t/connection-with-windows/18563/11 "2015-06-23T09:36:07Z")

</div>

i have powershell 4 now, but it is still not working porperly. it seems that ansible cannot find my windows.yml file. even if is set those variables in my hosts file, it doesn’t work.

---

<div class="post-metadata">

**Author:** ![Guillaume\_Querso](https://avatars.discourse-cdn.com/v4/letter/g/cdc98d/32.png) [@Guillaume\_Querso](https://forum.ansible.com/u/Guillaume_Querso)\
**Post date:** [June 23, 2015, 9:37am UTC](https://forum.ansible.com/t/connection-with-windows/18563/12 "2015-06-23T09:37:34Z")

</div>

not sure if this can help you but i am running windows locally as a vm.

---

<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:** [June 23, 2015, 11:30am UTC](https://forum.ansible.com/t/connection-with-windows/18563/13 "2015-06-23T11:30:42Z")

</div>

Running windows as a vm should not in itself be a problem.

What error are you getting now?

---

<div class="post-metadata">

**Author:** ![Guillaume\_Querso](https://avatars.discourse-cdn.com/v4/letter/g/cdc98d/32.png) [@Guillaume\_Querso](https://forum.ansible.com/u/Guillaume_Querso)\
**Post date:** [June 23, 2015, 12:30pm UTC](https://forum.ansible.com/t/connection-with-windows/18563/14 "2015-06-23T12:30:47Z")

</div>

i have the following files:

/etc/ansible/hosts

[windows]

WIN-F5631IBP8HG ansible\_connection=winrm ansible\_ssh\_user=AnsibleUser ansible\_ssh\_pass=ansiblepass ansible\_ssh\_port=5986

etc/ansible/winplaybook.yml

- name: Run powershell script

hosts: windows

gather\_facts: false

connection: winrm

tasks:

- name: Run powershell script

script: C:/Users/AnsibleUser/Desktop/helloworld.ps1

the ping is working perfectly (thanks to powershell 4) and i have the following message:

ansible-playbook /etc/ansible/winplaybook.yml -i windows, -vvvv

PLAY [Run powershell script] \*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*

TASK: [Run powershell script] \*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*

ESTABLISH WINRM CONNECTION FOR USER: guillaume on PORT 5986 TO windows

WINRM CONNECT: transport=plaintext endpoint=[https://windows:5986/wsman](https://windows:5986/wsman)

WINRM CONNECTION ERROR: 500 WinRMTransport. [Errno 111] Connection refused

fatal: [windows] =\> 500 WinRMTransport. [Errno 111] Connection refused

FATAL: all hosts have already failed – aborting

PLAY RECAP \*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*

to retry, use: --limit @/home/guillaume/winplaybook.retry

windows : ok=0 changed=0 unreachable=1 failed=0

---

<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:** [June 23, 2015, 1:41pm UTC](https://forum.ansible.com/t/connection-with-windows/18563/15 "2015-06-23T13:41:27Z")

</div>

Not sure why this is failing for you but here’s some things you can try

1/ Check you have run the setup script on your windows host:

[https://github.com/ansible/ansible/blob/devel/examples/scripts/ConfigureRemotingForAnsible.ps1](https://github.com/ansible/ansible/blob/devel/examples/scripts/ConfigureRemotingForAnsible.ps1)  
(linked from here: [http://docs.ansible.com/intro\_windows.html#windows-system-prep](http://docs.ansible.com/intro_windows.html#windows-system-prep))

2/ Try checking the event log on your windows machine to see if you can see why connection is being refused.

3/ check the firewall configuration to ensure that it is possible to connect to port 5986 on your windows machine from your ansible controller.

Hope this helps

Jon
