Merge pull request 'docs(adr): run Molecule in its own controller image' (#437) from docs/adr-molecule-controller-image into main

Reviewed-on: #437
This commit was merged in pull request #437.
This commit is contained in:
Defame1297 committed 2026-11-27 16:06:47 +00:00
commit 4a6db3382c
2 files changed
+61

No files matched your search

@@ -12,6 +12,7 @@ and pin updates. The choice is hard to undo once every workflow pins an image.
- **We build our own images:** a `ci` image, and one Dockerfile per molecule image (one per Ubuntu
release, and later the Debian 13 one).
Molecule's controller image is added by [ADR 0003](0003-molecule-controller-image.md).
- **The molecule images bake in everything except what a role installs itself.** The test
fixtures a scenario's `prepare.yml` needs are baked in. Packages a role installs are still
downloaded, because that install path is what the test exercises. A converge is not kept off
@@ -0,0 +1,60 @@
# 0003. Molecule runs in its own controller image, not the `ci` image
Status: accepted
## Context
[ADR 0002](0002-self-built-ci-and-molecule-images.md) built one `ci` image that bakes every CI
tool, and Lint, Build and Molecule all pin it. A change to a tool only Lint uses (apm-cli,
antsibull-changelog, a pre-commit hook environment) publishes a new `ci` version, and its pin
pull request moves `CI_IMAGE` in `molecule.yml`. The scenario selector cannot tell what changed
inside an image, so it runs every scenario. 9 of 18 `ci` pin pull requests over two weeks
were Lint-only. Images are built only on push to `main`, so a bump and its pin never share a pull
request.
## Decision
- **Molecule runs in a `molecule-controller` image**, separate from `ci`. It bakes only what
Molecule needs: ansible-core, molecule, molecule-plugins, the Python packages of the Docker
connection, and the collections of `requirements.yml` and
`extensions/molecule/requirements.yml`.
- **Its Python packages come from a requirements file and hash-pinned lock of its own.**
- **`molecule.yml` pins it instead of `ci`**; Lint and Build keep `ci`.
- **It follows ADR 0002 otherwise:** built by `image.yml`, versioned by CI, pinned by
`<version>@sha256:<digest>`, moved by Renovate. This adds to ADR 0002's set of images; the
rest of ADR 0002 stands.
## Reason
A `ci` pin pull request then touches only paths the selector ignores and runs no scenario. A
`molecule-controller` pin pull request still runs every scenario, which is right: it changes
Molecule's tools.
The cost: one more image and lock to maintain, its layers to estimate against the 100 MB limit,
a hand-made first pin, and ansible-core pinned in two locks that must stay equal. A collection
bump is an input of both images, so it publishes two versions and two pin pull requests.
The controller's requirements file and lock must not be on the selector's IGNORED list, so a
bump of ansible-core or molecule there runs every scenario before it merges. Today
`requirements-dev.txt` and `requirements-dev.lock` are on IGNORED, so such a bump selects no
scenario unless it edits `meta/runtime.yml`; this decision does not change that list.
The implementation updates: `image.yml` (matrix, and its push `paths` unless the new files live
under `images/`), `molecule.yml`,
`scripts/run_molecule_in_ci_image.sh` (its pin comparison reads the `ci` image's checksums),
`scripts/check_image_versions.py`, `scripts/check_bot_pr_diff.py` and
`scripts/lock-requirements.sh` (they know only `requirements-dev.lock`), their tests, the
`pip-compile` patterns in `renovate.json`, `images/AGENTS.md` (the consumer list, and "each
molecule image is one Ubuntu release"), the Molecule rules in `.gitea/workflows/AGENTS.md`,
`docs/images/` (a new page, and `ci.md`, which names Molecule as a consumer), the `ci`
Dockerfile's description label, `docs/contributing/setup.md` if the clone's tools change, and the
[Accepted risks](../../SECURITY.md#accepted-risks) entry "Pin bumps first behaviour-tested after
they merge", which counts on the `ci` pin pull request running every scenario.
## Not done
- **The selector classifies the packages a lock change moves, to decide whether a `CI_IMAGE`
bump matters:** a heuristic package list inside a script that judges pull requests.
- **Status quo:** every Lint-only tool change keeps costing a full Molecule run.
- **Grouping pin pull requests only:** adopted separately; it lowers the number of full runs
but not the cause.