Files
Kamino/docs/images/molecule-controller.md
T
Defame1297 fd448d7e9e ci(images): add the molecule-controller image
ADR 0003 moves Molecule out of the ci image, so a ci bump for a tool
only Lint uses stops selecting every scenario. This builds and publishes
the image; nothing pins it yet (#431).

It bakes requirements-molecule.lock (ansible-core, molecule,
molecule-plugins[docker]) on the Python of .python-version and the
collections of both requirements.yml files, and records their checksums
in /opt/molecule-pins.sha256. Its last RUN checks the tool versions
against the lock, the Docker driver, every pinned collection and the
pin record, so a broken image fails its build. It has no image-smoke
scenario: it is the controller of every scenario, and the full run of
its pin pull request proves it; images/AGENTS.md records the exception.

check_image_versions.py pins now checks the Python header of both locks
and fails when their ansible-core pins differ, so Lint and Molecule
judge the code with one ansible-core. The new requirements files stay
off the selector's IGNORED list, so a bump there runs every scenario.

Refs #477

Assisted-by: Claude Code
2026-11-29 17:03:35 +00:00

62 lines
3.9 KiB
Markdown

# molecule-controller
The **Molecule controller image** of the [`mortis.kamino`](https://git.rkdr.net/mortis/kamino) Collection:
the tools and collections Molecule runs with, and nothing Lint uses, so a tool bump that only Lint needs leaves
this image alone ([ADR 0003](../adr/0003-molecule-controller-image.md)). It is the controller: the scenarios'
target containers come from the `molecule-ubuntu*` images.
## What is in it
Ubuntu 26.04 with:
- **Python tools** in `/opt/venv` (on `PATH`; it runs on Python 3.14, the version of `.python-version`, from a
baked copy and not from the distribution's `python3`), from `requirements-molecule.lock` (the hashed lock of
`requirements-molecule.txt`, installed with `pip install --require-hashes`): `ansible-core`, `molecule` and
`molecule-plugins[docker]` (the Docker driver, with the `docker` Python SDK). Its `ansible-core` is the one of
`requirements-dev.lock`: `check_image_versions.py pins` fails when the two locks differ.
- **The collections the scenarios call** in `/opt/collections` (`ANSIBLE_COLLECTIONS_PATH` is set to it): those of
`requirements.yml` (`community.general`, `ansible.posix`, `community.proxmox`), which the roles call, and of
`extensions/molecule/requirements.yml` (`community.docker`), which the Docker driver's own playbooks call.
- `python3`, `python3-venv` and `ca-certificates` from the distribution. The image runs as root and sets no
working directory.
- `/opt/molecule-pins.sha256`: the checksums of the four pin files this image was built from.
It has no Docker CLI and no `git`: mount the host's Docker CLI and socket, and the checkout.
## How to use it
On the `kamino-molecule` runner, a host executor, start it with `docker run` as the runner user, with the Docker
socket, the host's Docker CLI and the checkout mounted at the same path (molecule hands the daemon paths in the
checkout). In the checkout root, run `sha256sum --quiet -c /opt/molecule-pins.sha256`: when it passes, use
`/opt/venv/bin` and `/opt/collections` as they are; when a pull request changed `requirements-molecule.txt`,
`requirements-molecule.lock`, `requirements.yml` or `extensions/molecule/requirements.yml`, install the pinned tools
and collections for that run first (slower, same result), until the image is rebuilt from `main`.
No workflow consumes it yet; the Molecule workflow still runs in the [`ci`](ci.md) image until its first pin is made
by hand.
## Tags and pinning
- `<version>` is semver, independent of the Collection's version. A published version is never moved or
rebuilt, so one digest belongs to exactly one version. `latest` is the newest version, for looking only.
- Pin `molecule-controller:<version>@sha256:<digest>`; the digest decides what is pulled.
## How it is built and kept up to date
`.gitea/workflows/image.yml` builds it with kaniko (repository root as build context, because the pin files are
copied in) on pushes to `main` that touch its inputs, never on a pull request, and publishes the next patch of the
matrix's `base:` when its inputs differ from those of its newest published version. Its last build step checks
itself: the tools run on the pinned Python at the locked versions, the Docker driver loads, every pinned collection
is installed and the pin record verifies. It has no image-smoke scenario: the full Molecule run of its pin pull
request proves it. The build prints the compressed size of each layer directory, and each pushed layer stays below
100 MB (Cloudflare's request limit).
## Image metadata
The `org.opencontainers.image.*` labels (title, description, version, revision, created, source,
documentation, licenses, authors) and `net.rkdr.mortis.*` labels (what it is for, what it contains,
how to use it; the base image is `base.name`) are listed on the package page of the registry; `version`,
`revision` and `created` are set by the build.
Source: [https://git.rkdr.net/mortis/kamino](https://git.rkdr.net/mortis/kamino), `images/molecule-controller/Dockerfile`. Licence: GPL-3.0-or-later.