molecule test default role - ERROR! Unexpected Exception, this is probably a bug: 'module' object has no attribute 'SSL_ST_INIT'

Created on 25 Sep 2017  ·  21Comments  ·  Source: ansible-community/molecule

Issue Type

  • Bug report

Molecule and Ansible details

> ansible --version
ansible 2.5.0
  config file = /etc/ansible/ansible.cfg
  configured module search path = [u'/home/ash/.ansible/plugins/modules', u'/usr/share/ansible/plugins/modules']
  ansible python module location = /usr/local/lib/python2.7/dist-packages/ansible
  executable location = /usr/local/bin/ansible
  python version = 2.7.12 (default, Nov 19 2016, 06:48:10) [GCC 5.4.0 20160609]

> molecule --version
molecule, version 2.1.0
  • Molecule installation method: pip
  • Ansible installation method: from sources on devel branch.

Desired Behaviour

I expected the default generator to succeed.

Actual Behaviour (Bug report only)

In order to reproduce, run these bash commands:

molecule init role --role-name foo
cd foo
molecule test

The error I have is:

--> Initializing new role foo...
Initialized role in /home/ash/foo successfully.
--> Test matrix

└── default
    ├── destroy
    ├── dependency
    ├── syntax
    ├── create
    ├── converge
    ├── idempotence
    ├── lint
    ├── side_effect
    ├── verify
    └── destroy
--> Scenario: 'default'
--> Action: 'destroy'
ERROR! Unexpected Exception, this is probably a bug: 'module' object has no attribute 'SSL_ST_INIT'
    to see the full traceback, use -vvv
ERROR: 

Maybe this is due to the ansible version?

Most helpful comment

Run molecule --debug test to see why.

All 21 comments

I've had this before... removing and reinstalling PyOpenSSL fixed this for me.

@kireledan, removing and reinstalling PyOpenSSL with sudo -H pip uninstall PyOpenSSL ; sudo -H pip install PyOpenSSL and then re-run the steps to reproduced I gave leads to an other error:

--> Initializing new role foo...
Initialized role in /home/ash/foo successfully.
--> Test matrix

└── default
    ├── destroy
    ├── dependency
    ├── syntax
    ├── create
    ├── converge
    ├── idempotence
    ├── lint
    ├── side_effect
    ├── verify
    └── destroy
--> Scenario: 'default'
--> Action: 'destroy'

    PLAY [Destroy] *****************************************************************

    TASK [Destroy molecule instance(s)] ********************************************
    failed: [localhost] (item=(censored due to no_log)) => {"censored": "the output has been hidden due to the fact that 'no_log: true' was specified for this result"}

    PLAY RECAP *********************************************************************
    localhost                  : ok=0    changed=0    unreachable=0    failed=1   


ERROR: 

I'd go ahead and use ansible 2.3/2.2, >=2.4 are not supported IIRC

Same results for 2.3 (the last error I described).

And the same for 2.2... Maybe re-installing PyOpenSSL broke something? I also tried after uninstalling it but this doesn't seem to change anything.

Try removing it like this

rm -rf /usr/lib/python2.7/dist-packages/OpenSSL
rm -rf /usr/lib/python2.7/dist-packages/pyOpenSSL-0.15.1.egg-info
sudo pip install pyopenssl

And also try pinning that to version 16.2

Thank you for perseverance, unfortunately I get the same error again and again, even after pinning it to 16.2.

Might be the apt package too..
try this

apt-get --auto-remove --yes remove python-openssl
pip install pyOpenSSL

Hum, this triggers a new error (solved by re-installing Ansible):

Traceback (most recent call last):
  File "/usr/local/bin/molecule", line 7, in <module>
    from molecule.shell import main
  File "/usr/local/lib/python2.7/dist-packages/molecule/shell.py", line 29, in <module>
    from molecule import command
  File "/usr/local/lib/python2.7/dist-packages/molecule/command/__init__.py", line 25, in <module>
    from molecule.command import base  # noqa
  File "/usr/local/lib/python2.7/dist-packages/molecule/command/base.py", line 27, in <module>
    from molecule import config
  File "/usr/local/lib/python2.7/dist-packages/molecule/config.py", line 28, in <module>
    from molecule import scenario
  File "/usr/local/lib/python2.7/dist-packages/molecule/scenario.py", line 24, in <module>
    from molecule import scenarios
  File "/usr/local/lib/python2.7/dist-packages/molecule/scenarios.py", line 26, in <module>
    from molecule import util
  File "/usr/local/lib/python2.7/dist-packages/molecule/util.py", line 24, in <module>
    import jinja2
  File "/usr/local/lib/python2.7/dist-packages/jinja2/__init__.py", line 33, in <module>
    from jinja2.environment import Environment, Template
  File "/usr/local/lib/python2.7/dist-packages/jinja2/environment.py", line 15, in <module>
    from jinja2 import nodes
  File "/usr/local/lib/python2.7/dist-packages/jinja2/nodes.py", line 19, in <module>
    from jinja2.utils import Markup
  File "/usr/local/lib/python2.7/dist-packages/jinja2/utils.py", line 624, in <module>
    from markupsafe import Markup, escape, soft_unicode
ImportError: No module named markupsafe
./start.bash: line 5: cd: foo: No such file or directory
Traceback (most recent call last):
  File "/usr/local/bin/molecule", line 7, in <module>
    from molecule.shell import main
  File "/usr/local/lib/python2.7/dist-packages/molecule/shell.py", line 29, in <module>
    from molecule import command
  File "/usr/local/lib/python2.7/dist-packages/molecule/command/__init__.py", line 25, in <module>
    from molecule.command import base  # noqa
  File "/usr/local/lib/python2.7/dist-packages/molecule/command/base.py", line 27, in <module>
    from molecule import config
  File "/usr/local/lib/python2.7/dist-packages/molecule/config.py", line 28, in <module>
    from molecule import scenario
  File "/usr/local/lib/python2.7/dist-packages/molecule/scenario.py", line 24, in <module>
    from molecule import scenarios
  File "/usr/local/lib/python2.7/dist-packages/molecule/scenarios.py", line 26, in <module>
    from molecule import util
  File "/usr/local/lib/python2.7/dist-packages/molecule/util.py", line 24, in <module>
    import jinja2
  File "/usr/local/lib/python2.7/dist-packages/jinja2/__init__.py", line 33, in <module>
    from jinja2.environment import Environment, Template
  File "/usr/local/lib/python2.7/dist-packages/jinja2/environment.py", line 15, in <module>
    from jinja2 import nodes
  File "/usr/local/lib/python2.7/dist-packages/jinja2/nodes.py", line 19, in <module>
    from jinja2.utils import Markup
  File "/usr/local/lib/python2.7/dist-packages/jinja2/utils.py", line 624, in <module>
    from markupsafe import Markup, escape, soft_unicode
ImportError: No module named markupsafe

Should really invest in some virtualenv usage. :)

Yeap, you are right...

go ahead and install those two python packages and try again

As I said, I already fixed these missing packages by re-installing Ansible. However the error came back to the one saying failed: [localhost] (item=(censored due to no_log)) => {"censored": "the output has been hidden due to the fact that 'no_log: true' was specified for this result"}.

Run molecule --debug test to see why.

Ah, something that sounds promising:

--> Test matrix

└── default
    ├── destroy
    ├── dependency
    ├── syntax
    ├── create
    ├── converge
    ├── idempotence
    ├── lint
    ├── side_effect
    ├── verify
    └── destroy
--> Scenario: 'default'
--> Action: 'destroy'
DEBUG: ANSIBLE ENVIRONMENT
---
ANSIBLE_CONFIG: /home/ash/foo/molecule/default/.molecule/ansible.cfg
ANSIBLE_FILTER_PLUGINS: /usr/local/lib/python2.7/dist-packages/molecule/provisioner/ansible/plugins/filters:/home/ash/foo/plugins/filters:/home/ash/foo/molecule/default/.molecule/plugins/filters
ANSIBLE_LIBRARY: /usr/local/lib/python2.7/dist-packages/molecule/provisioner/ansible/plugins/libraries:/home/ash/foo/library:/home/ash/foo/molecule/default/.molecule/library
ANSIBLE_ROLES_PATH: /home/ash:/home/ash/foo/molecule/default/.molecule/roles

DEBUG: MOLECULE ENVIRONMENT
---
MOLECULE_DEBUG: 'True'
MOLECULE_DEPENDENCY_NAME: galaxy
MOLECULE_DRIVER_NAME: docker
MOLECULE_EPHEMERAL_DIRECTORY: /home/ash/foo/molecule/default/.molecule
MOLECULE_FILE: /home/ash/foo/molecule/default/molecule.yml
MOLECULE_INSTANCE_CONFIG: /home/ash/foo/molecule/default/.molecule/instance_config.yml
MOLECULE_INVENTORY_FILE: /home/ash/foo/molecule/default/.molecule/ansible_inventory.yml
MOLECULE_LINT_NAME: yamllint
MOLECULE_PROVISIONER_NAME: ansible
MOLECULE_SCENARIO_DIRECTORY: /home/ash/foo/molecule/default
MOLECULE_SCENARIO_NAME: default
MOLECULE_VERIFIER_NAME: testinfra

DEBUG: COMMAND
/usr/local/bin/ansible-playbook --inventory=/home/ash/foo/molecule/default/.molecule/ansible_inventory.yml --diff /home/ash/foo/molecule/default/destroy.yml -vvv
    ansible-playbook 2.4.0.0
      config file = /home/ash/foo/molecule/default/.molecule/ansible.cfg
      configured module search path = [u'/usr/local/lib/python2.7/dist-packages/molecule/provisioner/ansible/plugins/libraries', u'/home/ash/foo/library', u'/home/ash/foo/molecule/default/.molecule/library']
      ansible python module location = /usr/local/lib/python2.7/dist-packages/ansible
      executable location = /usr/local/bin/ansible-playbook
      python version = 2.7.12 (default, Nov 19 2016, 06:48:10) [GCC 5.4.0 20160609]
    Using /home/ash/foo/molecule/default/.molecule/ansible.cfg as config file
    Parsed /home/ash/foo/molecule/default/.molecule/ansible_inventory.yml inventory source with yaml plugin

    PLAYBOOK: destroy.yml **********************************************************
    1 plays in /home/ash/foo/molecule/default/destroy.yml

    PLAY [Destroy] *****************************************************************
    META: ran handlers

    TASK [Destroy molecule instance(s)] ********************************************
    task path: /home/ash/foo/molecule/default/destroy.yml:11
    Using module file /usr/local/lib/python2.7/dist-packages/ansible/modules/cloud/docker/docker_container.py
    <127.0.0.1> ESTABLISH LOCAL CONNECTION FOR USER: ash
    <127.0.0.1> EXEC /bin/sh -c 'echo ~ && sleep 0'
    <127.0.0.1> EXEC /bin/sh -c '( umask 77 && mkdir -p "` echo /home/ash/.ansible/tmp/ansible-tmp-1506403250.08-137567298854534 `" && echo ansible-tmp-1506403250.08-137567298854534="` echo /home/ash/.ansible/tmp/ansible-tmp-1506403250.08-137567298854534 `" ) && sleep 0'
    <127.0.0.1> PUT /tmp/tmp7A7Lqc TO /home/ash/.ansible/tmp/ansible-tmp-1506403250.08-137567298854534/docker_container.py
    <127.0.0.1> EXEC /bin/sh -c 'chmod u+x /home/ash/.ansible/tmp/ansible-tmp-1506403250.08-137567298854534/ /home/ash/.ansible/tmp/ansible-tmp-1506403250.08-137567298854534/docker_container.py && sleep 0'
    <127.0.0.1> EXEC /bin/sh -c '/usr/bin/python /home/ash/.ansible/tmp/ansible-tmp-1506403250.08-137567298854534/docker_container.py; rm -rf "/home/ash/.ansible/tmp/ansible-tmp-1506403250.08-137567298854534/" > /dev/null 2>&1 && sleep 0'
    The full traceback is:
      File "/tmp/ansible_NEQeRG/ansible_module_docker_container.py", line 683, in <module>
        from docker import utils

    failed: [localhost] (item={'image': u'centos:7', 'name': u'instance'}) => {
        "changed": false, 
        "failed": true, 
        "invocation": {
            "module_args": {
                "api_version": null, 
                "auto_remove": false, 
                "blkio_weight": null, 
                "cacert_path": null, 
                "capabilities": null, 
                "cert_path": null, 
                "cleanup": false, 
                "command": null, 
                "cpu_period": null, 
                "cpu_quota": null, 
                "cpu_shares": null, 
                "cpuset_cpus": null, 
                "cpuset_mems": null, 
                "debug": false, 
                "detach": true, 
                "devices": null, 
                "dns_opts": null, 
                "dns_search_domains": null, 
                "dns_servers": null, 
                "docker_host": null, 
                "entrypoint": null, 
                "env": null, 
                "env_file": null, 
                "etc_hosts": null, 
                "exposed_ports": null, 
                "filter_logger": false, 
                "force_kill": true, 
                "groups": null, 
                "hostname": null, 
                "ignore_image": false, 
                "image": null, 
                "interactive": false, 
                "ipc_mode": null, 
                "keep_volumes": true, 
                "kernel_memory": null, 
                "key_path": null, 
                "kill_signal": null, 
                "labels": null, 
                "links": null, 
                "log_driver": null, 
                "log_options": null, 
                "mac_address": null, 
                "memory": "0", 
                "memory_reservation": null, 
                "memory_swap": null, 
                "memory_swappiness": null, 
                "name": "instance", 
                "network_mode": null, 
                "networks": null, 
                "oom_killer": null, 
                "oom_score_adj": null, 
                "paused": false, 
                "pid_mode": null, 
                "privileged": false, 
                "published_ports": null, 
                "pull": false, 
                "purge_networks": false, 
                "read_only": false, 
                "recreate": false, 
                "restart": false, 
                "restart_policy": null, 
                "restart_retries": null, 
                "security_opts": null, 
                "shm_size": null, 
                "ssl_version": null, 
                "state": "absent", 
                "stop_signal": null, 
                "stop_timeout": null, 
                "sysctls": null, 
                "timeout": null, 
                "tls": null, 
                "tls_hostname": null, 
                "tls_verify": null, 
                "tmpfs": null, 
                "trust_image_content": false, 
                "tty": false, 
                "ulimits": null, 
                "user": null, 
                "uts": null, 
                "volume_driver": null, 
                "volumes": null, 
                "volumes_from": null, 
                "working_dir": null
            }
        }, 
        "item": {
            "image": "centos:7", 
            "name": "instance"
        }, 
        "msg": "Failed to import docker-py - No module named docker. Try `pip install docker-py`"
    }

    PLAY RECAP *********************************************************************
    localhost                  : ok=0    changed=0    unreachable=0    failed=1   


ERROR:

And after running sudo -H pip install docker-py, the error becomes:

--> Test matrix

└── default
    ├── destroy
    ├── dependency
    ├── syntax
    ├── create
    ├── converge
    ├── idempotence
    ├── lint
    ├── side_effect
    ├── verify
    └── destroy
--> Scenario: 'default'
--> Action: 'destroy'
DEBUG: ANSIBLE ENVIRONMENT
---
ANSIBLE_CONFIG: /home/ash/foo/molecule/default/.molecule/ansible.cfg
ANSIBLE_FILTER_PLUGINS: /usr/local/lib/python2.7/dist-packages/molecule/provisioner/ansible/plugins/filters:/home/ash/foo/plugins/filters:/home/ash/foo/molecule/default/.molecule/plugins/filters
ANSIBLE_LIBRARY: /usr/local/lib/python2.7/dist-packages/molecule/provisioner/ansible/plugins/libraries:/home/ash/foo/library:/home/ash/foo/molecule/default/.molecule/library
ANSIBLE_ROLES_PATH: /home/ash:/home/ash/foo/molecule/default/.molecule/roles

DEBUG: MOLECULE ENVIRONMENT
---
MOLECULE_DEBUG: 'True'
MOLECULE_DEPENDENCY_NAME: galaxy
MOLECULE_DRIVER_NAME: docker
MOLECULE_EPHEMERAL_DIRECTORY: /home/ash/foo/molecule/default/.molecule
MOLECULE_FILE: /home/ash/foo/molecule/default/molecule.yml
MOLECULE_INSTANCE_CONFIG: /home/ash/foo/molecule/default/.molecule/instance_config.yml
MOLECULE_INVENTORY_FILE: /home/ash/foo/molecule/default/.molecule/ansible_inventory.yml
MOLECULE_LINT_NAME: yamllint
MOLECULE_PROVISIONER_NAME: ansible
MOLECULE_SCENARIO_DIRECTORY: /home/ash/foo/molecule/default
MOLECULE_SCENARIO_NAME: default
MOLECULE_VERIFIER_NAME: testinfra

DEBUG: COMMAND
/usr/local/bin/ansible-playbook --inventory=/home/ash/foo/molecule/default/.molecule/ansible_inventory.yml --diff /home/ash/foo/molecule/default/destroy.yml -vvv
    ansible-playbook 2.4.0.0
      config file = /home/ash/foo/molecule/default/.molecule/ansible.cfg
      configured module search path = [u'/usr/local/lib/python2.7/dist-packages/molecule/provisioner/ansible/plugins/libraries', u'/home/ash/foo/library', u'/home/ash/foo/molecule/default/.molecule/library']
      ansible python module location = /usr/local/lib/python2.7/dist-packages/ansible
      executable location = /usr/local/bin/ansible-playbook
      python version = 2.7.12 (default, Nov 19 2016, 06:48:10) [GCC 5.4.0 20160609]
    Using /home/ash/foo/molecule/default/.molecule/ansible.cfg as config file
    Parsed /home/ash/foo/molecule/default/.molecule/ansible_inventory.yml inventory source with yaml plugin

    PLAYBOOK: destroy.yml **********************************************************
    1 plays in /home/ash/foo/molecule/default/destroy.yml

    PLAY [Destroy] *****************************************************************
    META: ran handlers

    TASK [Destroy molecule instance(s)] ********************************************
    task path: /home/ash/foo/molecule/default/destroy.yml:11
    Using module file /usr/local/lib/python2.7/dist-packages/ansible/modules/cloud/docker/docker_container.py
    <127.0.0.1> ESTABLISH LOCAL CONNECTION FOR USER: ash
    <127.0.0.1> EXEC /bin/sh -c 'echo ~ && sleep 0'
    <127.0.0.1> EXEC /bin/sh -c '( umask 77 && mkdir -p "` echo /home/ash/.ansible/tmp/ansible-tmp-1506403413.26-26819405152008 `" && echo ansible-tmp-1506403413.26-26819405152008="` echo /home/ash/.ansible/tmp/ansible-tmp-1506403413.26-26819405152008 `" ) && sleep 0'
    <127.0.0.1> PUT /tmp/tmpvEri1L TO /home/ash/.ansible/tmp/ansible-tmp-1506403413.26-26819405152008/docker_container.py
    <127.0.0.1> EXEC /bin/sh -c 'chmod u+x /home/ash/.ansible/tmp/ansible-tmp-1506403413.26-26819405152008/ /home/ash/.ansible/tmp/ansible-tmp-1506403413.26-26819405152008/docker_container.py && sleep 0'
    <127.0.0.1> EXEC /bin/sh -c '/usr/bin/python /home/ash/.ansible/tmp/ansible-tmp-1506403413.26-26819405152008/docker_container.py; rm -rf "/home/ash/.ansible/tmp/ansible-tmp-1506403413.26-26819405152008/" > /dev/null 2>&1 && sleep 0'
    The full traceback is:
      File "/tmp/ansible_D8JJo7/ansible_modlib.zip/ansible/module_utils/docker_common.py", line 153, in __init__
        super(AnsibleDockerClient, self).__init__(**self._connect_params)
      File "/usr/local/lib/python2.7/dist-packages/docker/client.py", line 99, in __init__
        self._version = self._retrieve_server_version()
      File "/usr/local/lib/python2.7/dist-packages/docker/client.py", line 124, in _retrieve_server_version
        'Error while fetching server API version: {0}'.format(e)

    failed: [localhost] (item={'image': u'centos:7', 'name': u'instance'}) => {
        "changed": false, 
        "failed": true, 
        "invocation": {
            "module_args": {
                "api_version": null, 
                "auto_remove": false, 
                "blkio_weight": null, 
                "cacert_path": null, 
                "capabilities": null, 
                "cert_path": null, 
                "cleanup": false, 
                "command": null, 
                "cpu_period": null, 
                "cpu_quota": null, 
                "cpu_shares": null, 
                "cpuset_cpus": null, 
                "cpuset_mems": null, 
                "debug": false, 
                "detach": true, 
                "devices": null, 
                "dns_opts": null, 
                "dns_search_domains": null, 
                "dns_servers": null, 
                "docker_host": null, 
                "entrypoint": null, 
                "env": null, 
                "env_file": null, 
                "etc_hosts": null, 
                "exposed_ports": null, 
                "filter_logger": false, 
                "force_kill": true, 
                "groups": null, 
                "hostname": null, 
                "ignore_image": false, 
                "image": null, 
                "interactive": false, 
                "ipc_mode": null, 
                "keep_volumes": true, 
                "kernel_memory": null, 
                "key_path": null, 
                "kill_signal": null, 
                "labels": null, 
                "links": null, 
                "log_driver": null, 
                "log_options": null, 
                "mac_address": null, 
                "memory": "0", 
                "memory_reservation": null, 
                "memory_swap": null, 
                "memory_swappiness": null, 
                "name": "instance", 
                "network_mode": null, 
                "networks": null, 
                "oom_killer": null, 
                "oom_score_adj": null, 
                "paused": false, 
                "pid_mode": null, 
                "privileged": false, 
                "published_ports": null, 
                "pull": false, 
                "purge_networks": false, 
                "read_only": false, 
                "recreate": false, 
                "restart": false, 
                "restart_policy": null, 
                "restart_retries": null, 
                "security_opts": null, 
                "shm_size": null, 
                "ssl_version": null, 
                "state": "absent", 
                "stop_signal": null, 
                "stop_timeout": null, 
                "sysctls": null, 
                "timeout": null, 
                "tls": null, 
                "tls_hostname": null, 
                "tls_verify": null, 
                "tmpfs": null, 
                "trust_image_content": false, 
                "tty": false, 
                "ulimits": null, 
                "user": null, 
                "uts": null, 
                "volume_driver": null, 
                "volumes": null, 
                "volumes_from": null, 
                "working_dir": null
            }
        }, 
        "item": {
            "image": "centos:7", 
            "name": "instance"
        }, 
        "msg": "Error connecting: Error while fetching server API version: ('Connection aborted.', error(2, 'No such file or directory'))"
    }

    PLAY RECAP *********************************************************************
    localhost                  : ok=0    changed=0    unreachable=0    failed=1   


ERROR: 

What version of docker are you running?

> docker --version
Docker version 17.06.2-ce

Have I to install another one?

Maybe something has been broken somewhere doing investigations (or maybe it was broken due to the non isolated environment in which I am trying). I'll test to run it in a VM in the next few days and tell what happens.

Closing this issue. No longer a Molecule issue rather a system dependency issue.

Yeap, so I just tried with a fresh new Ubuntu16.04 and all is working as expected, thank you all for your help and work, molecule is very useful!

Was this page helpful?
0 / 5 - 0 ratings

Related issues

dj-wasabi picture dj-wasabi  ·  3Comments

beenje picture beenje  ·  4Comments

srizzling picture srizzling  ·  3Comments

surfer190 picture surfer190  ·  3Comments

dfinninger picture dfinninger  ·  5Comments