Skip to content

Instantly share code, notes, and snippets.

@jonashackt
Last active May 29, 2020 13:18
Show Gist options
  • Save jonashackt/99d37aa542bbb767fdf713938504a072 to your computer and use it in GitHub Desktop.
Save jonashackt/99d37aa542bbb767fdf713938504a072 to your computer and use it in GitHub Desktop.
Molecule cheatsheed
### 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 with another 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
### error:
$ molecule --debug verify
--> Validating schema /Users/jonashecht/dev/molecule-ansible-docker-vagrant/docker/molecule/vagrant-ubuntu/molecule.yml.
Validation completed successfully.
--> Validating schema /Users/jonashecht/dev/molecule-ansible-docker-vagrant/docker/molecule/aws-ec2-ubuntu/molecule.yml.
Validation completed successfully.
--> Validating schema /Users/jonashecht/dev/molecule-ansible-docker-vagrant/docker/molecule/default/molecule.yml.
Validation completed successfully.
--> Test matrix
└── default
└── verify
--> Scenario: 'default'
--> Action: 'verify'
Traceback (most recent call last):
File "/usr/local/bin/molecule", line 11, in <module>
sys.exit(main())
File "/usr/local/lib/python3.7/site-packages/click/core.py", line 722, in __call__
return self.main(*args, **kwargs)
File "/usr/local/lib/python3.7/site-packages/click/core.py", line 697, in main
rv = self.invoke(ctx)
File "/usr/local/lib/python3.7/site-packages/click/core.py", line 1066, in invoke
return _process_result(sub_ctx.command.invoke(sub_ctx))
File "/usr/local/lib/python3.7/site-packages/click/core.py", line 895, in invoke
return ctx.invoke(self.callback, **ctx.params)
File "/usr/local/lib/python3.7/site-packages/click/core.py", line 535, in invoke
return callback(*args, **kwargs)
File "/usr/local/lib/python3.7/site-packages/click/decorators.py", line 17, in new_func
return f(get_current_context(), *args, **kwargs)
File "/usr/local/lib/python3.7/site-packages/molecule/command/verify.py", line 97, in verify
base.execute_subcommand(scenario.config, action)
File "/usr/local/lib/python3.7/site-packages/molecule/command/base.py", line 100, in execute_subcommand
return command(config).execute()
File "/usr/local/lib/python3.7/site-packages/molecule/command/verify.py", line 72, in execute
self._config.verifier.execute()
File "/usr/local/lib/python3.7/site-packages/molecule/verifier/testinfra.py", line 183, in execute
self.bake()
File "/usr/local/lib/python3.7/site-packages/molecule/verifier/testinfra.py", line 162, in bake
self._testinfra_command = sh.Command('py.test').bake(
File "/usr/local/lib/python3.7/site-packages/sh.py", line 1202, in __init__
raise CommandNotFound(path)
sh.CommandNotFound: py.test
### Python on Mac-Hell again!
# According to https://bugzilla.redhat.com/show_bug.cgi?id=1653777 the problem seems to be, that only python2-pytest provides py.test -
# and Python3 does not. So the only thing left, was to install molecule also on pip (homebrew Python2) again
# (pip install pytest wan't enough!):
pip install molecule
# 13.01.2019: Raspbian needs Ansible Python 3, AWS Ansible Python 2 :(
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment