Hello. I’ve cloned a galaxy role that I would like to add a feature to. The role is supported by a suite of tests, run using molecule. I am having problems installing/configuring the docker driver, despite following various articles (all of which essentially provide the same set of instructions for how to get molecule and its docker driver working).
I’m using MacOS M1 Silicon, and python was installed using brew.
sysctl -n machdep.cpu.brand_string
Apple M1
which python3
/opt/homebrew/bin/python3
python3 --version
Python 3.12.3
In order to run molecule against the galaxy role, from within the role’s root directory, I am using a venv:
cd ansible-role-logrotate
python3 -m venv .venv
source .venv/bin/activate
Once the venv is activated, I then install the list of requirements, as I understand them.
(.venv) pip list
Package Version
------- -------
pip 24.0
(.venv) pip install ansible docker ansible-lint yamllint molecule molecule-plugins 'molecule-plugins[docker]'
...
Installing collected packages: resolvelib, zipp, urllib3, subprocess-tee, ruamel.yaml.clib, rpds-py, pyyaml, pygments, pycparser, pluggy, platformdirs, pathspec, packaging, mypy-extensions, mdurl, MarkupSafe, idna, filelock, click, charset-normalizer, certifi, bracex, attrs, yamllint, wcmatch, ruamel.yaml, requests, referencing, markdown-it-py, Jinja2, importlib-metadata, click-help-colors, cffi, black, rich, jsonschema-specifications, docker, cryptography, jsonschema, enrich, ansible-core, ansible-compat, ansible, molecule, ansible-lint, molecule-plugins
Successfully installed Jinja2-3.1.4 MarkupSafe-2.1.5 ansible-9.6.0 ansible-compat-24.5.1 ansible-core-2.16.7 ansible-lint-24.5.0 attrs-23.2.0 black-24.4.2 bracex-2.4 certifi-2024.2.2 cffi-1.16.0 charset-normalizer-3.3.2 click-8.1.7 click-help-colors-0.9.4 cryptography-42.0.7 docker-7.1.0 enrich-1.2.7 filelock-3.14.0 idna-3.7 importlib-metadata-7.1.0 jsonschema-4.22.0 jsonschema-specifications-2023.12.1 markdown-it-py-3.0.0 mdurl-0.1.2 molecule-24.2.1 molecule-plugins-23.5.3 mypy-extensions-1.0.0 packaging-24.0 pathspec-0.12.1 platformdirs-4.2.2 pluggy-1.5.0 pycparser-2.22 pygments-2.18.0 pyyaml-6.0.1 referencing-0.35.1 requests-2.32.2 resolvelib-1.0.1 rich-13.7.1 rpds-py-0.18.1 ruamel.yaml-0.18.6 ruamel.yaml.clib-0.2.8 subprocess-tee-0.4.1 urllib3-2.2.1 wcmatch-8.5.2 yamllint-1.35.1 zipp-3.18.2
(.venv) pip list
Package Version
------------------------- ---------
ansible 9.6.0
ansible-compat 24.5.1
ansible-core 2.16.7
ansible-lint 24.5.0
attrs 23.2.0
black 24.4.2
bracex 2.4
certifi 2024.2.2
cffi 1.16.0
charset-normalizer 3.3.2
click 8.1.7
click-help-colors 0.9.4
cryptography 42.0.7
docker 7.1.0
enrich 1.2.7
filelock 3.14.0
idna 3.7
importlib_metadata 7.1.0
Jinja2 3.1.4
jsonschema 4.22.0
jsonschema-specifications 2023.12.1
markdown-it-py 3.0.0
MarkupSafe 2.1.5
mdurl 0.1.2
molecule 24.2.1
molecule-plugins 23.5.3
mypy-extensions 1.0.0
packaging 24.0
pathspec 0.12.1
pip 24.0
platformdirs 4.2.2
pluggy 1.5.0
pycparser 2.22
Pygments 2.18.0
PyYAML 6.0.1
referencing 0.35.1
requests 2.32.2
resolvelib 1.0.1
rich 13.7.1
rpds-py 0.18.1
ruamel.yaml 0.18.6
ruamel.yaml.clib 0.2.8
subprocess-tee 0.4.1
urllib3 2.2.1
wcmatch 8.5.2
yamllint 1.35.1
zipp 3.18.2
At this point, the documentation that I have read suggests that the molecule, molecule-plugins, and in particular the molecule docker driver should be installed. However, when I read molecule --version
the docker driver is not listed:
(.venv) molecule --version
molecule 24.2.1 using python 3.12
ansible:2.16.7
default:24.2.1 from molecule
vagrant:2.0.0 from molecule_vagrant
And I think that as a result of that, when I run molecule create
, I receive an error as per the title that informs me that the docker driver cannot be found:
(.venv) molecule create
CRITICAL Driver 'docker' from state-file '/Users/<myusername>/.cache/molecule/ansible-role-logrotate/default/state.yml' is not available.
I’ve run cat against the referenced file, and its contents is as follows:
(.venv) cat /Users/<myusername>/.cache/molecule/ansible-role-logrotate/default/state.yml
# Molecule managed
---
converged: false
created: false
driver: docker
is_parallel: false
molecule_yml_date_modified: 1716491367.9140189
prepared: null
run_uuid: 7662a76e-d15a-4746-b74f-a8fa65b9881c
In subsequent experiments, based on other articles I’ve found, I have also installed docker-py
and even molecule-docker
despite the fact that using molecule-docker
seems to be deprecated in favour of molecule-plugins[docker]
:
(.venv) pip install docker-py molecule-docker
...
Installing collected packages: docker-py, molecule-docker
Successfully installed docker-py-1.10.6 molecule-docker-2.1.0
(.venv) molecule --version
molecule 24.2.1 using python 3.12
ansible:2.16.7
default:24.2.1 from molecule
vagrant:2.0.0 from molecule_vagrant
Lastly, I’ve also followed some other advice I found and ensured that the docker socket is available by running sudo ln -s -f /Users/<myusername>/.docker/run/docker.sock /var/run/docker.sock
and also ensured that docker is running in the correct context by running docker context use default
.
I’d really like to make a contribution to this galaxy role, and additionally, start to use molecule in my own workflow. However, I seem to be missing something (presumably very obvious) in what I am doing.
Could somebody put me out of my misery, please! Thank you.