I am new to using Molecule and I'm having an issue trying to simply 'create' the docker image. The only files I have chanced within the molecule folder structure is 'molecule.yml', as seen below.
I have tried to re-setup molecule on multiple systems (mac/Ubuntu) but have encountered the same issue. Just to get going I just want to get the 'create' working and that would be great!
molecule.yml
---
dependency:
name: galaxy
driver:
name: docker
lint:
name: yamllint
platforms:
- name: instance
image: centos:7
pre_build_image: true
provisioner:
name: ansible
verifier:
name: ansible
Error:
Traceback (most recent call last):
File "/usr/local/bin/molecule", line 8, in <module>
sys.exit(main())
File "/usr/lib/python3/dist-packages/click/core.py", line 1128, in __call__
return self.main(*args, **kwargs)
File "/usr/lib/python3/dist-packages/click/core.py", line 1053, in main
rv = self.invoke(ctx)
File "/usr/lib/python3/dist-packages/click/core.py", line 1659, in invoke
return _process_result(sub_ctx.command.invoke(sub_ctx))
File "/usr/lib/python3/dist-packages/click/core.py", line 1395, in invoke
return ctx.invoke(self.callback, **ctx.params)
File "/usr/lib/python3/dist-packages/click/core.py", line 754, in invoke
return __callback(*args, **kwargs)
File "/usr/lib/python3/dist-packages/click/decorators.py", line 26, in new_func
return f(get_current_context(), *args, **kwargs)
File "/usr/local/lib/python3.10/dist-packages/molecule/command/reset.py", line 46, in reset
base.execute_cmdline_scenarios(scenario_name, args, command_args)
File "/usr/local/lib/python3.10/dist-packages/molecule/command/base.py", line 94, in execute_cmdline_scenarios
get_configs(args, command_args, ansible_args, glob_str),
File "/usr/local/lib/python3.10/dist-packages/molecule/command/base.py", line 185, in get_configs
configs = [
File "/usr/local/lib/python3.10/dist-packages/molecule/command/base.py", line 186, in <listcomp>
config.Config(
File "/usr/local/lib/python3.10/dist-packages/molecule/config.py", line 64, in __call__
obj.after_init()
File "/usr/local/lib/python3.10/dist-packages/molecule/config.py", line 116, in after_init
self.config = self._reget_config()
File "/usr/local/lib/python3.10/dist-packages/molecule/config.py", line 308, in _reget_config
env = util.merge_dicts(os.environ, self.env)
File "/usr/local/lib/python3.10/dist-packages/molecule/config.py", line 201, in env
"MOLECULE_INSTANCE_CONFIG": self.driver.instance_config,
File "/usr/lib/python3.10/functools.py", line 981, in __get__
val = self.func(instance)
File "/usr/local/lib/python3.10/dist-packages/molecule/config.py", line 185, in driver
driver = api.drivers(config=self)[driver_name]
File "/usr/local/lib/python3.10/dist-packages/molecule/api.py", line 29, in __getitem__
return self.__dict__[i]
KeyError: 'docker'
I have tried to setup molecule on my system from scratch. After I had created a test role and changed the driver from delegated
to docker
, I got the exact same error as you.
I referred this doc. Looks like, I was missing the, molecule
plugin for docker
. I installed that, using the command below command.
python3 -m pip install --user "molecule-plugins[docker]"
After that, the error has gone away. Can you please give it a try, if you haven't already?