Ansible Windows

274 views
Skip to first unread message

Bryan Cochrane

unread,
Oct 17, 2014, 11:02:06 AM10/17/14
to ansible...@googlegroups.com
I am trying to setup windows remoting for ansible.

I have Ansible version 1.7.2, ee-bryan is Windows 8.1, ee-csg is Windows Server 2012. Both have Powershell 4.

under /etc/ansible I have created hosts as
[windows]
ee-bryan
ee-csg

and I have created /etc/ansible/group_vars/windows.yml with

#It is suggested that these be encrypted with ansible-vault:
# ansible-vault edit group_vars/windows.yml
#
 ansible_ssh_user: Administrator
 ansible_ssh_pass: password
 ansible_ssh_port: 5986
 ansible_connection: winrm

but on testing I get 

# ansible windows -m win_ping
ee-csg.ee.ic.ac.uk | FAILED => Traceback (most recent call last):
  File "/usr/lib/python2.7/site-packages/ansible/runner/__init__.py", line 561, in _executor
    exec_rc = self._executor_internal(host, new_stdin)
  File "/usr/lib/python2.7/site-packages/ansible/runner/__init__.py", line 666, in _executor_internal
    return self._executor_internal_inner(host, self.module_name, self.module_args, inject, port, complex_args=complex_args)
  File "/usr/lib/python2.7/site-packages/ansible/runner/__init__.py", line 837, in _executor_internal_inner
    conn = self.connector.connect(actual_host, actual_port, actual_user, actual_pass, actual_transport, actual_private_key_file)
  File "/usr/lib/python2.7/site-packages/ansible/runner/connection.py", line 34, in connect
    self.active = conn.connect()
  File "/usr/lib/python2.7/site-packages/ansible/runner/connection_plugins/winrm.py", line 132, in connect
    self.protocol = self._winrm_connect()
  File "/usr/lib/python2.7/site-packages/ansible/runner/connection_plugins/winrm.py", line 90, in _winrm_connect
    err_msg = str(exc.args[0])
IndexError: tuple index out of range

ee-bryan.ee.ic.ac.uk | FAILED => Traceback (most recent call last):
  File "/usr/lib/python2.7/site-packages/ansible/runner/__init__.py", line 561, in _executor
    exec_rc = self._executor_internal(host, new_stdin)
  File "/usr/lib/python2.7/site-packages/ansible/runner/__init__.py", line 666, in _executor_internal
    return self._executor_internal_inner(host, self.module_name, self.module_args, inject, port, complex_args=complex_args)
  File "/usr/lib/python2.7/site-packages/ansible/runner/__init__.py", line 837, in _executor_internal_inner
    conn = self.connector.connect(actual_host, actual_port, actual_user, actual_pass, actual_transport, actual_private_key_file)
  File "/usr/lib/python2.7/site-packages/ansible/runner/connection.py", line 34, in connect
    self.active = conn.connect()
  File "/usr/lib/python2.7/site-packages/ansible/runner/connection_plugins/winrm.py", line 132, in connect
    self.protocol = self._winrm_connect()
  File "/usr/lib/python2.7/site-packages/ansible/runner/connection_plugins/winrm.py", line 90, in _winrm_connect
    err_msg = str(exc.args[0])
IndexError: tuple index out of range

Trond Hindenes

unread,
Oct 19, 2014, 2:44:20 PM10/19/14
to ansible...@googlegroups.com
Have you prepared your Windows nodes as per documentation? Basically, yuu need to enable WinRM connections over HTTPS, and enable Baisc auth for your WinRm endpoint. Look at the documentation, there's a script that will do those things for you. I've uploaded a newer version of that script here: https://gist.github.com/trondhindenes/2cd162d4b17c2c28ec40

_Trond

Michael DeHaan

unread,
Oct 20, 2014, 4:58:17 PM10/20/14
to ansible...@googlegroups.com
This is probably a good error to file upstream with winrm, such that on this error it can present something better to the user.

We could catch it, but an IndexError is the wrong sort of exception to be catching here.



--
You received this message because you are subscribed to the Google Groups "Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ansible-proje...@googlegroups.com.
To post to this group, send email to ansible...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/5a2d00b4-3009-4912-abe9-28c9764dc9f8%40googlegroups.com.

For more options, visit https://groups.google.com/d/optout.

Chris Church

unread,
Oct 25, 2014, 3:47:20 PM10/25/14
to ansible...@googlegroups.com
That IndexError has been fixed in ansible devel.  It's not really a pywinrm issue, but an ansible issue in trying to handle the HTTPError from pywinrm.

It happens when the HTTPError from urllib2 isn't a file-like object (despite what the docs say in https://docs.python.org/2/library/urllib2.html#urllib2.HTTPError).


Peter Daly-Dickson

unread,
Nov 20, 2014, 10:56:45 AM11/20/14
to ansible...@googlegroups.com
I get exactly the same...

 |staging:e38026ddcaae | → ansible -i ./provisioning/hosts windows -m win_ping

54.67.74.52 | FAILED => Traceback (most recent call last):

  File "/usr/local/lib/python2.7/site-packages/ansible-1.7.2-py2.7.egg/ansible/runner/__init__.py", line 561, in _executor

    exec_rc = self._executor_internal(host, new_stdin)

  File "/usr/local/lib/python2.7/site-packages/ansible-1.7.2-py2.7.egg/ansible/runner/__init__.py", line 666, 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/site-packages/ansible-1.7.2-py2.7.egg/ansible/runner/__init__.py", line 837, 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/site-packages/ansible-1.7.2-py2.7.egg/ansible/runner/connection.py", line 34, in connect

    self.active = conn.connect()

  File "/usr/local/lib/python2.7/site-packages/ansible-1.7.2-py2.7.egg/ansible/runner/connection_plugins/winrm.py", line 132, in connect

    self.protocol = self._winrm_connect()

  File "/usr/local/lib/python2.7/site-packages/ansible-1.7.2-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


I installed ansible on my Macbook Pro via homebrew. What's the best/quickest/easiest way to get the fix for this?

Thanks.

P.

Peter Daly-Dickson

unread,
Nov 20, 2014, 11:08:53 AM11/20/14
to ansible...@googlegroups.com
I installed ansible from source, and it now works a treat!

|staging:e38026ddcaae | → ansible -i ./provisioning/hosts production -m win_ping

54.67.74.52 | success >> {

    "changed": false, 

    "ping": "pong"

}


Thanks for ansible, and for great resources to fix issues.

cheers

P.

On Saturday, 25 October 2014 20:47:20 UTC+1, Chris Church wrote:

Geoff Webster

unread,
Dec 3, 2014, 2:06:04 PM12/3/14
to ansible...@googlegroups.com
Are there plans on supporting the kerbros authentication so this works in domain environments?

J Hawkesworth

unread,
Dec 4, 2014, 3:07:50 PM12/4/14
to ansible...@googlegroups.com
Yes, there is a thread on the Ansible Development list detailing progress on this.

Reply all
Reply to author
Forward
0 new messages