# Ubuntu Controller with Windows Host

**URL:** <https://forum.ansible.com/t/ubuntu-controller-with-windows-host/16002>\
**Category:** Ansible Project\
**Tags:** windows, ubuntu\
**Created:** [August 21, 2014, 6:29pm UTC](https://forum.ansible.com/t/ubuntu-controller-with-windows-host/16002 "2014-08-21T18:29:23Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![Avinash\_Singh](https://avatars.discourse-cdn.com/v4/letter/a/b5ac83/32.png) [@Avinash\_Singh](https://forum.ansible.com/u/Avinash_Singh)\
**Post date:** [August 21, 2014, 6:29pm UTC](https://forum.ansible.com/t/ubuntu-controller-with-windows-host/16002/1 "2014-08-21T18:29:23Z")

</div>

Hi,

I have installed ansible on my linux controller, however I am unable to win\_ping my windows host machine.  
The controller and host are virtual machines hosted on my physical machine.

I am able to ping each machine in both directions from cmd prompt and the terminal, to verify that the machines can see each other.

I have followed all the steps from here :[http://docs.ansible.com/intro\_windows.html](http://docs.ansible.com/intro_windows.html)

When running the command below I get a connection refused.

```auto
ansible windows -i /etc/anisible/hosts -m win_ping --ask-vault-pass -vvvv

```

I have also tried using a playbook. However I get some cows 🙂 and connection could be established.

ansible-playbook site.yml

with the following site.xml contents:

---

<div class="post-metadata">

**Author:** ![Paul\_Durivage](https://avatars.discourse-cdn.com/v4/letter/p/94ad74/32.png) [@Paul\_Durivage](https://forum.ansible.com/u/Paul_Durivage)\
**Post date:** [August 21, 2014, 7:01pm UTC](https://forum.ansible.com/t/ubuntu-controller-with-windows-host/16002/2 "2014-08-21T19:01:04Z")

</div>

You said you’re getting a connection refused, so check the firewall and winrm settings on the Windows machine.

There’s an example script ([https://github.com/ansible/ansible/blob/devel/examples/scripts/ConfigureRemotingForAnsible.ps1](https://github.com/ansible/ansible/blob/devel/examples/scripts/ConfigureRemotingForAnsible.ps1)) that takes care of WinRM making sure the box allows remote powershell exec, among other things. Likely you’re missing a step preparing the Windows machine to accept remote winrm connections.

---

<div class="post-metadata">

**Author:** ![Avinash\_Singh](https://avatars.discourse-cdn.com/v4/letter/a/b5ac83/32.png) [@Avinash\_Singh](https://forum.ansible.com/u/Avinash_Singh)\
**Post date:** [August 22, 2014, 7:04am UTC](https://forum.ansible.com/t/ubuntu-controller-with-windows-host/16002/3 "2014-08-22T07:04:50Z")

</div>

I have disabled the firewall.

Output from Host machine when running remoting script:

> VERBOSE: Verifying WS-MAN  
> VERBOSE: PS remoting is already active and running  
> VERBOSE: SSL-based remoting already active  
> VERBOSE: basic auth already enabled  
> Ok.
> 
> VERBOSE: PS Remoting successfully setup for AnsibleEnter code here…

This is the error on the controller:

---

<div class="post-metadata">

**Author:** ![Avinash\_Singh](https://avatars.discourse-cdn.com/v4/letter/a/b5ac83/32.png) [@Avinash\_Singh](https://forum.ansible.com/u/Avinash_Singh)\
**Post date:** [August 22, 2014, 7:33am UTC](https://forum.ansible.com/t/ubuntu-controller-with-windows-host/16002/4 "2014-08-22T07:33:02Z")

</div>

Heres a log of my latest error:

\<10.1.11.40\> ESTABLISH WINRM CONNECTION FOR USER: Administrator on PORT 5986 TO 10.1.11.40  
\<10.1.11.40\> WINRM CONNECT: transport=plaintext endpoint=[https://10.1.11.40:5986/wsman](https://10.1.11.40:5986/wsman)  
10.1.11.40 | FAILED =\> Traceback (most recent call last):  
File “/usr/local/lib/python2.7/dist-packages/ansible-1.8-py2.7.egg/ansible/runner/ **init**.py”, line 563, in \_executor  
exec\_rc = self.\_executor\_internal(host, new\_stdin)  
File “/usr/local/lib/python2.7/dist-packages/ansible-1.8-py2.7.egg/ansible/runner/ **init**.py”, line 672, in \_executor\_internal  
return self.\_executor\_internal\_inner(host, self.module\_name, self.module\_args, inject, port, complex\_args=complex\_args)  
File “/usr/local/lib/python2.7/dist-packages/ansible-1.8-py2.7.egg/ansible/runner/ **init**.py”, line 843, in \_executor\_internal\_inner  
conn = self.connector.connect(actual\_host, actual\_port, actual\_user, actual\_pass, actual\_transport, actual\_private\_key\_file)  
File “/usr/local/lib/python2.7/dist-packages/ansible-1.8-py2.7.egg/ansible/runner/connection.py”, line 44, in connect  
self.active = conn.connect()  
File “/usr/local/lib/python2.7/dist-packages/ansible-1.8-py2.7.egg/ansible/runner/connection\_plugins/winrm.py”, line 132, in connect  
self.protocol = self.\_winrm\_connect()  
File “/usr/local/lib/python2.7/dist-packages/ansible-1.8-py2.7.egg/ansible/runner/connection\_plugins/winrm.py”, line 90, in \_winrm\_connect  
err\_msg = str(exc.args[0])  
IndexError: tuple index out of range

---

<div class="post-metadata">

**Author:** ![Michael\_DeHaan1](https://avatars.discourse-cdn.com/v4/letter/m/5e9695/32.png) [@Michael\_DeHaan1](https://forum.ansible.com/u/Michael_DeHaan1)\
**Post date:** [August 22, 2014, 11:07am UTC](https://forum.ansible.com/t/ubuntu-controller-with-windows-host/16002/5 "2014-08-22T11:07:32Z")

</div>

When you say “remote windows machine”, what version of Windows, what is the version of Ansible (ansible --version exact output), and did you run the setup script above or set it up manually?

Thanks!

---

<div class="post-metadata">

**Author:** ![Avinash\_Singh](https://avatars.discourse-cdn.com/v4/letter/a/b5ac83/32.png) [@Avinash\_Singh](https://forum.ansible.com/u/Avinash_Singh)\
**Post date:** [August 22, 2014, 12:42pm UTC](https://forum.ansible.com/t/ubuntu-controller-with-windows-host/16002/6 "2014-08-22T12:42:19Z")

</div>

Windows 2012 Server.  
Ansible 1.8

I have run the setup script.

---

<div class="post-metadata">

**Author:** ![Avinash\_Singh](https://avatars.discourse-cdn.com/v4/letter/a/b5ac83/32.png) [@Avinash\_Singh](https://forum.ansible.com/u/Avinash_Singh)\
**Post date:** [August 22, 2014, 12:56pm UTC](https://forum.ansible.com/t/ubuntu-controller-with-windows-host/16002/7 "2014-08-22T12:56:03Z")

</div>

I can remote into into my windows host machine from another windows machine using

> Invoke-Command -ComputerName AnsibleHost1 -ScriptBlock { Get-childitem c:} -credential $cred

I have also tried(not using https):

> > winrm identify -r:[http://10.1.11.40:5985/wsman](http://10.1.11.40:5985/wsman) -auth:basic -u:administrator -p:password -encoding:utf-8  
> > IdentifyResponse  
> > ProtocolVersion = [http://schemas.dmtf.org/wbem/wsman/1/wsman.xsd](http://schemas.dmtf.org/wbem/wsman/1/wsman.xsd)  
> > ProductVendor = Microsoft Corporation  
> > ProductVersion = OS: 6.2.9200 SP: 0.0 Stack: 3.0  
> > SecurityProfiles  
> > SecurityProfileName = [http://schemas.dmtf.org/wbem/wsman/1/wsman/secprofile/http/basic](http://schemas.dmtf.org/wbem/wsman/1/wsman/secprofile/http/basic), [http://schemas.dmtf.org/](http://schemas.dmtf.org/)  
> > wbem/wsman/1/wsman/secprofile/https/basic, [http://schemas.dmtf.org/wbem/wsman/1/wsman/secprofile/http/spnego-kerberos](http://schemas.dmtf.org/wbem/wsman/1/wsman/secprofile/http/spnego-kerberos), h  
> > ttp://schemas.dmtf.org/wbem/wsman/1/wsman/secprofile/https/spnego-kerberos

Im think it has something to do with pywinrm, because when i trying running it on my linux machine through python i get the following error:

---

<div class="post-metadata">

**Author:** ![john\_zenou](https://avatars.discourse-cdn.com/v4/letter/j/6de8d8/32.png) [@john\_zenou](https://forum.ansible.com/u/john_zenou)\
**Post date:** [August 23, 2014, 8:10pm UTC](https://forum.ansible.com/t/ubuntu-controller-with-windows-host/16002/8 "2014-08-23T20:10:29Z")

</div>

Hi all

I have exactly the same problem and I agree too that all points to an pywinrm issue.  
Does anyone know what is causing this and how to solve it ?

Server controle : Ansible 1.7 running on Ubuntu 12.04  
Node : Windows 2008 r2

---

<div class="post-metadata">

**Author:** ![Chris\_Church1](https://avatars.discourse-cdn.com/v4/letter/c/ac8455/32.png) [@Chris\_Church1](https://forum.ansible.com/u/Chris_Church1)\
**Post date:** [August 25, 2014, 2:23am UTC](https://forum.ansible.com/t/ubuntu-controller-with-windows-host/16002/9 "2014-08-25T02:23:37Z")

</div>

The latest pywinrm (as of [https://github.com/diyan/pywinrm/commit/1bb5ee32a559624f9e2c08ba3b1b2f4bdf0d8bcb](https://github.com/diyan/pywinrm/commit/1bb5ee32a559624f9e2c08ba3b1b2f4bdf0d8bcb)) has issues when using the winrm.Session class and the URL contains an IP address, so I wouldn’t expect your example above to work at the moment.

As mentioned in the other ansible-project thread, the IndexError should be fixed as of [https://github.com/ansible/ansible/commit/07f12539eee2faac5fe831cd31f1f0a5d3e7e661](https://github.com/ansible/ansible/commit/07f12539eee2faac5fe831cd31f1f0a5d3e7e661) (which was committed Friday afternoon EDT).

Trying to use win\_ping (or any other windows module) from a playbook was also broken until my commit earlier this evening ([https://github.com/ansible/ansible/commit/57dee4545b3c34d1e66943def8d5e45ee95d66bd](https://github.com/ansible/ansible/commit/57dee4545b3c34d1e66943def8d5e45ee95d66bd)) – That bug would’ve given you the error “Processing -File ‘C’ failed because the file does not have a ‘.ps1’ extension. Specify a valid Windows PowerShell script file name, and then try again.”

---

<div class="post-metadata">

**Author:** ![Michael\_DeHaan1](https://avatars.discourse-cdn.com/v4/letter/m/5e9695/32.png) [@Michael\_DeHaan1](https://forum.ansible.com/u/Michael_DeHaan1)\
**Post date:** [August 25, 2014, 10:29pm UTC](https://forum.ansible.com/t/ubuntu-controller-with-windows-host/16002/10 "2014-08-25T22:29:12Z")

</div>

Per another thread on this list, downgrading winrm is the temporary answer. The issue needs to be brought up with wirm upstream.

See the thread entitled “[Ansible to Windows] IndexError: tuple index out of range”

[https://groups.google.com/d/msg/ansible-project/XCKgXFIOras/TogpnNtuXL4J](https://groups.google.com/d/msg/ansible-project/XCKgXFIOras/TogpnNtuXL4J)
