Raise Exception("Cannot import pyOpenSSL")

Hi there,
I’m getting this error when running ansible.

[root@localhost ansible]# ansible windows -i hosts -m win_ping -vvv
Using /etc/ansible/ansible.cfg as config file
An exception occurred during task execution. The full traceback is:
Traceback (most recent call last):
File “/usr/lib/python2.7/site-packages/ansible/executor/task_executor.py”, line 126, in run
res = self._execute()
File “/usr/lib/python2.7/site-packages/ansible/executor/task_executor.py”, line 453, in _execute
self._connection = self._get_connection(variables=variables, templar=templar)
File “/usr/lib/python2.7/site-packages/ansible/executor/task_executor.py”, line 699, in _get_connection
connection = self._shared_loader_obj.connection_loader.get(conn_type, self._play_context, self._new_stdin)
File “/usr/lib/python2.7/site-packages/ansible/plugins/init.py”, line 339, in get
self._module_cache[path] = self._load_module_source(‘.’.join([self.package, name]), path)
File “/usr/lib/python2.7/site-packages/ansible/plugins/init.py”, line 324, in _load_module_source
module = imp.load_source(name, path, module_file)
File “/usr/lib/python2.7/site-packages/ansible/plugins/connection/winrm.py”, line 46, in
import winrm
File “/usr/lib/python2.7/site-packages/winrm/init.py”, line 6, in
from winrm.protocol import Protocol
File “/usr/lib/python2.7/site-packages/winrm/protocol.py”, line 11, in
from winrm.transport import Transport
File “/usr/lib/python2.7/site-packages/winrm/transport.py”, line 42, in
from requests_credssp import HttpCredSSPAuth
File “/usr/lib/python2.7/site-packages/requests_credssp/init.py”, line 1, in
from .credssp import HttpCredSSPAuth
File “/usr/lib/python2.7/site-packages/requests_credssp/credssp.py”, line 8, in
raise Exception(“Cannot import pyOpenSSL”)
Exception: Cannot import pyOpenSSL

windows2012.contoso.com | FAILED! => {
“failed”: true,
“msg”: “Unexpected failure during module execution.”,
“stdout”: “”
}

I check everthying but not able to pass this error.

The SO wis a RHEL 7.3

thanks
Tiago

I have the same issue

might want to run with -vvvvv to get winrm info as well; what auth are you doing.

I saw a similar issue and when i tried to user kerberos auth to AD

some version of pyopenssl was installed so i tried to upgrade.

`
pip install pyopenssl --upgrade

`

received some errors with openssl/opensslv.h.
`
yum provides ‘*openssl/opensslv.h’

`

and found it was part of package openssl-devel (rhel7 here)

After that I was able to connect with kerberos AD account.

Basic auth was working fine already.

If you are on Ubuntu:
sudo apt-get install libffi-dev
pip install cryptography

Good luck!

Hey

The package pyOpenSSL is used by the requests-credssp package. Even if you are not using CredSSP it will try and load the library if it is there and fail if it doesn't exist. There is a newer version of requests-credssp that doesn't fail outright if you aren't using credssp auth so try pip install -U requests-credssp to get that.

Otherwise https://github.com/jborean93/requests-credssp shows the packages that must be installed for it to work and contains the minimum pyOpenSSL version that requests-credssp needs.

Thanks

Jordan