Raise Exception("Cannot import pyOpenSSL")

255 views
Skip to first unread message

Tiago Pimpão

unread,
Mar 11, 2017, 7:34:35 PM3/11/17
to Ansible Project
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 <module>
    import winrm
  File "/usr/lib/python2.7/site-packages/winrm/__init__.py", line 6, in <module>
    from winrm.protocol import Protocol
  File "/usr/lib/python2.7/site-packages/winrm/protocol.py", line 11, in <module>
    from winrm.transport import Transport
  File "/usr/lib/python2.7/site-packages/winrm/transport.py", line 42, in <module>
    from requests_credssp import HttpCredSSPAuth
  File "/usr/lib/python2.7/site-packages/requests_credssp/__init__.py", line 1, in <module>
    from .credssp import HttpCredSSPAuth
  File "/usr/lib/python2.7/site-packages/requests_credssp/credssp.py", line 8, in <module>
    raise Exception("Cannot import pyOpenSSL")
Exception: Cannot import pyOpenSSL

    "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

Sumanth Reddy

unread,
Mar 15, 2017, 9:50:38 AM3/15/17
to Ansible Project
I have the same issue

cupcake

unread,
Mar 16, 2017, 11:50:56 AM3/16/17
to Ansible Project
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. 

Karthik Bhat

unread,
Sep 8, 2017, 7:53:54 AM9/8/17
to Ansible Project
If you are on Ubuntu:
sudo apt-get install libffi-dev
pip install cryptography

Good luck!

Jordan Borean

unread,
Sep 8, 2017, 8:02:56 AM9/8/17
to Ansible Project
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

Reply all
Reply to author
Forward
0 new messages