WinRM Connection Error

Trying to ping a windows machine, and I’m running into an ambiguous error from one of the python modules. Any suggestion on how to fix this?

That’s a new one on me, but I have a few suggestions of things you can try.

Try using a hostname instead of an ip address.

Try not running ansible from a venv (should be fine, but just peeling back a layer).

Check the event log on the target windows box (eventvwr.msc) and see if there is any evidence of a successful login from the lanadmin user.

Also, what version of windows are you targeting? If I recall Server 2008/Server 2008R2 had some issues which are only fixed when SP1 is installed or its fully up to date with windows updates.

Try a complete uninistall and reinstall of ansible.

Hope this helps

Jon

Can you give us the output of pip list, seems like pywinrm is receiving a None value where it is expecting a string.

Thanks

Jordan

I have the same issue that I rolled back to 2.4.1.
I have updated the packer.py for the connection_plugsins from github and updated win_udpates from the github, both didn’t worked at all.
However, 2.4.1, I was able to create ami without having the winrm timeout along with packer v1.2.3.
Good luck.

John.

John Roh, this would be unrelated to the packer issues. It is already known that Packer’s connection plugin is problematic with connecting to Windows hosts due to how their architecture is set up.

Thanks

Jordan

pip list

Package Version


ansible 2.6.2

asn1crypto 0.24.0

backports.ssl-match-hostname 3.5.0.1

bcrypt 3.1.4

cached-property 1.4.3

certifi 2018.4.16

cffi 1.11.5

chardet 3.0.4

cryptography 2.3

docker 3.4.1

docker-compose 1.22.0

docker-pycreds 0.3.0

dockerpty 0.4.1

docopt 0.6.2

enum34 1.1.6

functools32 3.2.3.post2

idna 2.6

ipaddress 1.0.22

Jinja2 2.10

jsonschema 2.6.0

MarkupSafe 1.0

ntlm-auth 1.2.0

paramiko 2.4.1

pip 18.0

pyasn1 0.4.4

pycparser 2.18

PyNaCl 1.2.1

pywinrm 0.3.0

PyYAML 3.13

requests 2.18.4

requests-ntlm 1.1.0

setuptools 40.0.0

six 1.11.0

texttable 0.9.1

urllib3 1.22

websocket-client 0.48.0

wheel 0.31.1

xmltodict 0.11.0

Same error is raised regardless of hostname, even if I put an erroneous one. Event log shows an alert to an ntlm authentication but I can’t find anything as far as a successful login I’m targeting Server 2012R2. Ran a clean install and still run into the issue

Ok a couple of other ideas…

See if the s2012r2 target firewall is blocking traffic to/from port 5985
If I recall the configure for remoting script adds a rule for this but worth checking all the profiles.

Also worth checking for any firewalling on your ansible host as well while you are at it.

Try using pywinrm without ansible - see the code examples near the bottom of this page: https://github.com/diyan/pywinrm

Were you able to try without venv?

Jon

+1
getting the same error, didn’t get the solution yet.
please post here if anyone resolved the following error.

pip list :

Package Version


ansible 2.6.4
asn1crypto 0.24.0
Babel 0.9.6
backports.ssl-match-hostname 3.5.0.1
certifi 2018.8.24
cffi 1.11.5
chardet 3.0.4
configobj 4.7.2
cryptography 2.3.1
decorator 3.4.0
enum34 1.1.6
httplib2 0.9.2
idna 2.7
iniparse 0.4
ipaddr 2.1.11
ipaddress 1.0.22
javapackages 1.0.0
Jinja2 2.7.2
jmespath 0.9.0
kitchen 1.1.1
libvirt-python 3.9.0
lxml 3.2.1
MarkupSafe 0.11
ntlm-auth 1.2.0
paramiko 2.1.1
passlib 1.6.5
perf 0.1
pip 18.0
ply 3.4
pyasn1 0.1.9
pycparser 2.18
pycurl 7.19.0
pygobject 3.22.0
pygpgme 0.3
pykerberos 1.2.1
pyliblzma 0.5.3
python-linux-procfs 0.4.9
pyudev 0.15
pywinrm 0.3.0
pyxattr 0.5.1
PyYAML 3.10
requests 2.19.1
requests-kerberos 0.12.0
requests-ntlm 1.1.0
schedutils 0.4
setuptools 0.9.8
six 1.11.0
slip 0.4.0
slip.dbus 0.4.0
SSSDConfig 1.16.0
urlgrabber 3.10
urllib3 1.23
virtualenv 15.1.0
wheel 0.31.1
xmltodict 0.11.0
yum-metadata-parser 1.1.4

ansible 2.6.4
config file = /etc/ansible/ansible.cfg
configured module search path = [u’/root/.ansible/plugins/modules’, u’/usr/share/ansible/plugins/modules’]
ansible python module location = /usr/lib/python2.7/site-packages/ansible
executable location = /bin/ansible
python version = 2.7.5 (default, Jul 13 2018, 13:06:57) [GCC 4.8.5 20150623 (Red Hat 4.8.5-28)]

ansible windows -m win_ping -vvvv

“changed”: false,
“msg”: “kerberos: must be string or read-only buffer, not None”,
“unreachable”: true

Can you run

ansible windows -m win_ping -vvvvv

This should return the stack trace.

My guess is one of your keberos-related dependencies is out of date. Sometimes the kerberous libraries are installed with the operating system, so you may need to double check the dependencies you have installed. See https://docs.ansible.com/ansible/2.3/intro_windows.html#installing-python-kerberos-dependencies

Jon

Try adding the following and recheck with ntlm
ansible_winrm_message_encryption: auto

Thank you @Hawkesworth.

Yeah this might be the dependensy issue with winrm on latest ansible version.

i worked absolutely fine when i used ansible 2.4.2.1 version with pywinrm[0.2.0] with basic authentication.

But kerberos authentication is not supported in that version.

I will try this Ankit.
Thank you.