Last active
March 5, 2026 07:07
-
-
Save jonashackt/99d37aa542bbb767fdf713938504a072 to your computer and use it in GitHub Desktop.
Molecule cheatsheed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| ### error : | |
| Validation completed successfully. | |
| --> Test matrix | |
| └── default | |
| ├── create | |
| └── prepare | |
| --> Scenario: 'default' | |
| --> Action: 'create' | |
| [WARNING]: Skipping plugin (/usr/local/lib/python2.7/site- | |
| packages/molecule/provisioner/ansible/plugins/filters/molecule_core.py) as it | |
| seems to be invalid: No module named 'molecule' | |
| # fix with upgrading Ansible to latest brew installed version with | |
| pip3 install ansible --upgrade | |
| pip3 install docker --upgrade | |
| pip3 install docker-py --upgrade | |
| ### error | |
| }, | |
| "mode": "0644", | |
| "owner": "jonashecht", | |
| "path": "/var/folders/5p/l1cc1kqd69n_qxrftgln7xdm0000gn/T/molecule/docker/default/Dockerfile_ubuntu_bionic", | |
| "size": 855, | |
| "state": "file", | |
| "uid": 501 | |
| }, | |
| "msg": "Failed to import docker or docker-py - No module named 'docker'. Try `pip install docker` or `pip install docker-py` (Python 2.6)" | |
| } | |
| PLAY RECAP ********************************************************************* | |
| localhost : ok=1 changed=0 unreachable=0 failed=1 | |
| ### thats a problem of doubled problem | |
| # 1. docker & docker-py are the same packages and Ansible doesn't know, which it should use | |
| # see https://medium.com/dronzebot/ansible-and-docker-py-path-issues-and-resolving-them-e3834d5bb79a | |
| # https://github.com/ansible/ansible/issues/20492 | |
| # solve it, by uninstall docker-py docker docker-compose and all docker-related packages with | |
| pip uninstall docker docker-py docker-compose docker-pycreds | |
| # then we need to do a fresh install of docker package only (which is the successor to docker-py!) | |
| # BUT: we also need to use Ansible, that uses Python 3.x itself - because otherwise, it won't find the new Docker package correctly | |
| # and the error will remain. Therefore ALWAYS STICK TO pip3!!! | |
| # brew installs Python 2 ('pip') and Python3 ('pip3'). In order to install Ansible using Python 3, uninstall all other Ansible packages | |
| brew uninstall ansible | |
| pip uninstall ansible | |
| pip3 install ansible | |
| # check the Python version is correct (3!) in Ansible | |
| ansible --version | |
| # should look like | |
| ansible 2.7.5 | |
| config file = None | |
| configured module search path = ['/Users/jonashecht/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules'] | |
| ansible python module location = /usr/local/lib/python3.7/site-packages/ansible | |
| executable location = /usr/local/bin/ansible | |
| python version = 3.7.2 (default, Jan 1 2019, 17:59:04) [Clang 10.0.0 (clang-1000.11.45.5)] | |
| # now install molecule & docker (NOT docker-py!) using pip3 (3!) | |
| pip3 install molecule docker | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment