win_ping issue

665 views
Skip to first unread message

skinnedknuckles

unread,
Sep 24, 2014, 10:51:28 AM9/24/14
to ansible...@googlegroups.com

I'm having trouble getting win_ping to work.  Here is my info:
Fedora 20
Ansible 1.7.1
Remote node running windows 7
The WinRM script by Trond runs without errors on the remote node
Control and Remote Machines are both on Lan with common domain w/o firewalls
So far as I can tell I've installed everything on control and remote machine as described in documentation

My inventory file contains
[ads800s]
ADS-6999 ansible_ssh_host=123.123.123.123

My windows.yml file is in the group_vars directory and contains
ansible_ssh_user: ansmgr
ansible_ssh_pass: ansiblepw
ansible_ssh_port: 5986
ansible_connection: winrm

Can you tell what I'm doing wrong?  Do you need any more information?

Here is the debugging output of my win_ping command (with -c winrm is below)

[ansmgr@LinuxControlMachine ansible]$ ansible ADS-6999 -m win_ping -vvvv
<123.123.123.123> ESTABLISH CONNECTION FOR USER: ansmgr
<123.123.123.123> REMOTE_MODULE win_ping
<123.123.123.123> EXEC ['ssh', '-C', '-tt', '-vvv', '-o', 'ControlMaster=auto', '-o', 'ControlPersist=60s', '-o', 'ControlPath=/home/ansmgr/.ansible/cp/ansible-ssh-%h-%p-%r', '-o', 'Port=22', '-o', 'KbdInteractiveAuthentication=no', '-o', 'PreferredAuthentications=gssapi-with-mic,gssapi-keyex,hostbased,publickey', '-o', 'PasswordAuthentication=no', '-o', 'ConnectTimeout=10', '123.123.123.123', "/bin/sh -c 'mkdir -p $HOME/.ansible/tmp/ansible-tmp-1411567957.01-192759344617423 && chmod a+rx $HOME/.ansible/tmp/ansible-tmp-1411567957.01-192759344617423 && echo $HOME/.ansible/tmp/ansible-tmp-1411567957.01-192759344617423'"]
ADS-6999 | FAILED => SSH encountered an unknown error. The output was:
OpenSSH_6.4, OpenSSL 1.0.1e-fips 11 Feb 2013
debug1: Reading configuration data /etc/ssh/ssh_config
debug1: /etc/ssh/ssh_config line 51: Applying options for *
debug1: auto-mux: Trying existing master
debug1: Control socket "/home/ansmgr/.ansible/cp/ansible-ssh-123.123.123.123-22-ansmgr" does not exist
debug2: ssh_connect: needpriv 0
debug1: Connecting to 123.123.123.123 [123.123.123.123] port 22.
debug2: fd 3 setting O_NONBLOCK
debug1: connect to address 123.123.123.123 port 22: Connection refused
ssh: connect to host 123.123.123.123 port 22: Connection refused

Here is the debugging output of my win_ping command with -c winrm is below

[ansmgr@LinuxControlMachine ansible]$ ansible ADS-6999 -c winrm -m win_ping -vvvv
<123.123.123.123> ESTABLISH WINRM CONNECTION FOR USER: ansmgr on PORT 5986 TO 123.123.123.123
ADS-6999 | 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 71, in _winrm_connect
    cache_key = '%s:%s@%s:%d' % (self.user, hashlib.md5(self.password).hexdigest(), self.host, port)
TypeError: md5() argument 1 must be string or buffer, not None


Matt Martz

unread,
Sep 24, 2014, 11:33:39 AM9/24/14
to ansible...@googlegroups.com
It seems as though your group_vars is not being picked up.  Is your inventory file and your group_vars directory located in the same place?

By default this is where ansible looks, so both should be in the same directory.

--
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/d00f66cd-0469-4688-9429-bf9c45fec2e0%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.



--
Matt Martz
@sivel
sivel.net

skinnedknuckles

unread,
Sep 24, 2014, 12:02:50 PM9/24/14
to ansible...@googlegroups.com
Both the inventory file (hosts) and the group_vars folder are in /etc/ansible

J Hawkesworth

unread,
Sep 29, 2014, 6:36:19 AM9/29/14
to ansible...@googlegroups.com
Try not setting the ansible_ssh_host in your inventory - I think this might be forcing it to attempt ssh transport, which of course isn't going to work for windows hosts.

In other words, change

[ads800s]
ADS-6999 ansible_ssh_host=123.123.123.123

to

ads800s]
ADS-6999

and ensure ADS-6999 can either be resolved by your local dns or as an entry in /etc/hosts

Michael DeHaan

unread,
Sep 29, 2014, 8:03:07 AM9/29/14
to ansible...@googlegroups.com
ansible_ssh_host does not imply the transport.

Let's ask the starter question, "what's the output of ansible --version" ?



--
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.

Jonathan Anderson

unread,
Sep 29, 2014, 9:12:31 AM9/29/14
to ansible...@googlegroups.com
ansible 1.7.1  (this and other details are in the original posting)


--
You received this message because you are subscribed to a topic in the Google Groups "Ansible Project" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/ansible-project/mXsqZp6oiV0/unsubscribe.
To unsubscribe from this group and all its topics, send an email to ansible-proje...@googlegroups.com.

To post to this group, send email to ansible...@googlegroups.com.

Michael DeHaan

unread,
Sep 29, 2014, 9:20:24 AM9/29/14
to ansible...@googlegroups.com
Sorry for the confusion, I was replying to the incorrect assertion above and missed the scrollback.

Please make sure you file a ticket for this one as tracebacks in Ansible are definitely bugs, though it sounds like you need to either use --ask-pass or set ansible_ssh_pass -- though the variable name is named "ssh" it's not limited to being used just for SSH.




Jonathan Anderson

unread,
Sep 29, 2014, 11:22:00 AM9/29/14
to ansible...@googlegroups.com
My windows.yml file is in the group_vars directory and contains
---

ansible_ssh_user: ansmgr
ansible_ssh_pass: ansiblepw
ansible_ssh_port: 5986
ansible_connection: winrm

Here is my output

[ansmgr@LinuxControlMachine etc]$ ansible ADS-6999 -m win_ping -vvvv
<123.123.123.123> ESTABLISH CONNECTION FOR USER: ansmgr
<123.123.123.123> REMOTE_MODULE win_ping
<123.123.123.123> EXEC ['ssh', '-C', '-tt', '-vvv', '-o', 'ControlMaster=auto', '-o', 'ControlPersist=60s', '-o', 'ControlPath=/home/ansmgr/.ansible/cp/ansible-ssh-%h-%p-%r', '-o', 'Port=22', '-o', 'KbdInteractiveAuthentication=no', '-o', 'PreferredAuthentications=gssapi-with-mic,gssapi-keyex,hostbased,publickey', '-o', 'PasswordAuthentication=no', '-o', 'ConnectTimeout=50', '123.123.123.123', "/bin/sh -c 'mkdir -p $HOME/.ansible/tmp/ansible-tmp-1411997765.4-206807213502142 && chmod a+rx $HOME/.ansible/tmp/ansible-tmp-1411997765.4-206807213502142 && echo $HOME/.ansible/tmp/ansible-tmp-1411997765.4-206807213502142'"]
ADS-6999 | FAILED => SSH encountered an unknown error. The output was:
OpenSSH_6.4, OpenSSL 1.0.1e-fips 11 Feb 2013
debug1: Reading configuration data /etc/ssh/ssh_config
debug1: /etc/ssh/ssh_config line 51: Applying options for *
debug1: auto-mux: Trying existing master
debug1: Control socket "/home/ansmgr/.ansible/cp/ansible-ssh-123.123.123.123-22-ansmgr" does not exist
debug2: ssh_connect: needpriv 0
debug1: Connecting to 123.123.123.123 [123.123.123.123] port 22.
debug2: fd 3 setting O_NONBLOCK
debug1: connect to address 123.123.123.123 port 22: Connection refused
ssh: connect to host 123.123.123.123 port 22: Connection refused


Here is my output when I include --ask-pass

ansmgr@LinuxControlMachine group_vars]$ ansible ADS-6999 -m win_ping -k --ask-pass -vvvv
SSH password: 
<123.123.123.123> ESTABLISH CONNECTION FOR USER: ansmgr
<123.123.123.123> REMOTE_MODULE win_ping
<123.123.123.123> EXEC ['sshpass', '-d6', 'ssh', '-C', '-tt', '-vvv', '-o', 'ControlMaster=auto', '-o', 'ControlPersist=60s', '-o', 'ControlPath=/home/ansmgr/.ansible/cp/ansible-ssh-%h-%p-%r', '-o', 'Port=22', '-o', 'GSSAPIAuthentication=no', '-o', 'PubkeyAuthentication=no', '-o', 'ConnectTimeout=50', '123.123.123.123', "/bin/sh -c 'mkdir -p $HOME/.ansible/tmp/ansible-tmp-1412000604.71-243055722371675 && chmod a+rx $HOME/.ansible/tmp/ansible-tmp-1412000604.71-243055722371675 && echo $HOME/.ansible/tmp/ansible-tmp-1412000604.71-243055722371675'"]
ADS-6999 | FAILED => SSH encountered an unknown error. The output was:
OpenSSH_6.4, OpenSSL 1.0.1e-fips 11 Feb 2013
debug1: Reading configuration data /etc/ssh/ssh_config
debug1: /etc/ssh/ssh_config line 51: Applying options for *
debug1: auto-mux: Trying existing master
debug1: Control socket "/home/ansmgr/.ansible/cp/ansible-ssh-123.123.123.123-22-ansmgr" does not exist
debug2: ssh_connect: needpriv 0
debug1: Connecting to 123.123.123.123 [123.123.123.123] port 22.
debug2: fd 3 setting O_NONBLOCK
debug1: connect to address 123.123.123.123 port 22: Connection refused
ssh: connect to host 123.123.123.123 port 22: Connection refused


I examined the file /etc/ssh/ssh_config specifically line 51

Here is a portion of that file

20 # Host *
21 #   ForwardAgent no
22 #   ForwardX11 no
23 #   RhostsRSAAuthentication no...........

...........
47 #   PermitLocalCommand no
48 #   VisualHostKey no
49 #   ProxyCommand ssh -q -W %h:%p gateway.example.com
50 #   RekeyLimit 1G 1h
51 Host *


Is line 51 intended to be uncommented?

If I comment out line 51 I get this output.

[ansmgr@LinuxControlMachine ssh]$ ansible ADS-6999 -m win_ping -k --ask-pass -vvvv
SSH password: 
<123.123.123.123> ESTABLISH CONNECTION FOR USER: ansmgr
<123.123.123.123> REMOTE_MODULE win_ping
<123.123.123.123> EXEC ['sshpass', '-d6', 'ssh', '-C', '-tt', '-vvv', '-o', 'ControlMaster=auto', '-o', 'ControlPersist=60s', '-o', 'ControlPath=/home/ansmgr/.ansible/cp/ansible-ssh-%h-%p-%r', '-o', 'Port=22', '-o', 'GSSAPIAuthentication=no', '-o', 'PubkeyAuthentication=no', '-o', 'ConnectTimeout=50', '123.123.123.123', "/bin/sh -c 'mkdir -p $HOME/.ansible/tmp/ansible-tmp-1412000787.68-252576189555801 && chmod a+rx $HOME/.ansible/tmp/ansible-tmp-1412000787.68-252576189555801 && echo $HOME/.ansible/tmp/ansible-tmp-1412000787.68-252576189555801'"]
ADS-6999 | FAILED => SSH encountered an unknown error. The output was:
OpenSSH_6.4, OpenSSL 1.0.1e-fips 11 Feb 2013
debug1: Reading configuration data /etc/ssh/ssh_config
debug1: auto-mux: Trying existing master
debug1: Control socket "/home/ansmgr/.ansible/cp/ansible-ssh-123.123.123.123-22-ansmgr" does not exist
debug2: ssh_connect: needpriv 0
debug1: Connecting to 123.123.123.123 [123.123.123.123] port 22.
debug2: fd 3 setting O_NONBLOCK
debug1: connect to address 123.123.123.123 port 22: Connection refused
ssh: connect to host 123.123.123.123 port 22: Connection refused

Am I digging in the right place?

Chris Church

unread,
Sep 30, 2014, 1:27:51 PM9/30/14
to ansible...@googlegroups.com
It looks like it's still trying to use ssh instead of winrm, which indicates your group vars still aren't being used.  Based on your inventory from the messages below, your host doesn't appear to be listed in a "windows" group, so it won't use group_vars/windows.yml.

Try adding the following lines to your inventory to include your host in a windows group:

[windows]
ADS-6999



skinnedknuckles

unread,
Nov 7, 2014, 10:28:57 AM11/7/14
to ansible...@googlegroups.com
There must be a problem with my encryption because when I run this line in powershell it works.

winrm set winrm/config/service '@{AllowUnencrypted="true"}'

Bluesky

unread,
Jul 13, 2017, 1:59:59 PM7/13/17
to Ansible Project
hello,Skinnedknuckles
I ask you how the final solution to the problem? I also encountered this Error, hope you can get your help, thank you very much!

在 2014年9月24日星期三 UTC+8下午10:51:28,skinnedknuckles写道:

Jonathan Anderson

unread,
Jul 13, 2017, 10:05:59 PM7/13/17
to ansible...@googlegroups.com
check out this post for detailed items to check on your setup


--
You received this message because you are subscribed to a topic in the Google Groups "Ansible Project" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/ansible-project/mXsqZp6oiV0/unsubscribe.
To unsubscribe from this group and all its topics, send an email to ansible-project+unsubscribe@googlegroups.com.
To post to this group, send email to ansible-project@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/db6faca0-79bd-4180-9e00-fa9858c3dfb7%40googlegroups.com.
Reply all
Reply to author
Forward
0 new messages