molecule 5.0.0 docker driver fails
Asked Answered
P

2

5

Since last week there is a new release of molecule 5.0.0.

My CI/CD pipeline wants to use that latest version, but I've trouble with it.

  1. installation

Earlier, it was possible to run pip install molecule[docker] to install all necessary libraries. But this fails with WARNING: molecule 5.0.0 does not provide the extra 'docker'.

So I switched to pip install molecule-docker, which works and molecule drivers shows that docker driver is available.

$ molecule --version
molecule 5.0.0 using python 3.11 
    ansible:2.14.5
    delegated:5.0.0 from molecule
    docker:2.1.0 from molecule_docker requiring collections: community.docker>=3.0.2 ansible.posix>=1.4.0
$ molecule drivers
  delegated                                                                     
  docker 
  1. run

But when I run molecule test, I'm getting a real big stack trace, saying that a driver.json file is missing within the molecule-docker package:

$ molecule test
Traceback (most recent call last):
  File "/usr/local/bin/molecule", line 8, in <module>
    sys.exit(main())
             ^^^^^^
  File "/usr/local/lib/python3.11/site-packages/click/core.py", line 1130, in __call__
    return self.main(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/click/core.py", line 1055, in main
    rv = self.invoke(ctx)
         ^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/click/core.py", line 1657, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
                           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/click/core.py", line 1404, in invoke
    return ctx.invoke(self.callback, **ctx.params)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/click/core.py", line 760, in invoke
    return __callback(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/click/decorators.py", line 26, in new_func
    return f(get_current_context(), *args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/molecule/command/test.py", line 113, in test
    base.execute_cmdline_scenarios(scenario_name, args, command_args, ansible_args)
  File "/usr/local/lib/python3.11/site-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.11/site-packages/molecule/command/base.py", line 185, in get_configs
    configs = [
              ^
  File "/usr/local/lib/python3.11/site-packages/molecule/command/base.py", line 186, in <listcomp>
    config.Config(
  File "/usr/local/lib/python3.11/site-packages/molecule/config.py", line 64, in __call__
    obj.after_init()
  File "/usr/local/lib/python3.11/site-packages/molecule/config.py", line 118, in after_init
    self._validate()
  File "/usr/local/lib/python3.11/site-packages/molecule/config.py", line 456, in _validate
    errors = schema_v3.validate(self.config)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/molecule/model/schema_v3.py", line 61, in validate
    with open(schema_file, encoding="utf-8") as f:
         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
FileNotFoundError: [Errno 2] No such file or directory: '/usr/local/lib/python3.11/site-packages/molecule_docker/driver.json'

This is my molecule.yml:

---
dependency:
  name: galaxy

driver:
  name: docker

platforms:
  - name: instance1
    image: "docker.io/geerlingguy/docker-debian11-ansible"
    pre_build_image: true
    privileged: true
    cgroupns_mode: host
    command: "/lib/systemd/systemd"
    volumes:
      - "/sys/fs/cgroup:/sys/fs/cgroup:rw"
      - "/var/lib/containerd"
    tmpfs:
      - "/run"
      - "/tmp"
  - name: instance2
    image: "docker.io/geerlingguy/docker-debian11-ansible"
    pre_build_image: true
    privileged: true
    cgroupns_mode: host
    command: "/lib/systemd/systemd"
    volumes:
      - "/sys/fs/cgroup:/sys/fs/cgroup:rw"
      - "/var/lib/containerd"
    tmpfs:
      - "/run"
      - "/tmp"

provisioner:
  name: ansible
  lint:
    name: ansible-lint
  inventory:
    links:
      hosts: inventory.yml

verifier:
  name: ansible

The documentation is not really helpful anymore about how to setup the environment with docker. I've used the default settings more or less from molecule 4.x. before and there it works as expected. Is there somewhere a migration documentation available? Because the release is so young, I cannot find newer documentations.

Pathan answered 29/4, 2023 at 11:14 Comment(2)
I have the very same problem. Downgrading to 4.0.4 works for me. But apparently the project is not active anymore, as the repository was archived: github.com/ansible-community/molecule-docker Not sure where to look now.Babul
@Babul The repo is archived because its functionality is moved to/present in github.com/ansible-community/molecule-plugins.Curran
P
13

Since Molecule 5, it looks like you require the molecule-plugins[docker] package instead of molecule[docker].

Source: https://dailystuff.nl/blog/2023/switch-to-molecule-plugins

Prot answered 30/4, 2023 at 8:13 Comment(1)
yepp, thats it.Pathan
C
0

In addition to @Samk answer: on arch based linux destribution python-docker package needed

pacman -S python-docker
Cutaway answered 5/8 at 9:2 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.