Compare commits

..
Author SHA1 Message Date
Defame1297 0973f39831 feat: refresh the APT cache on distribution-only installs when stale
Build / build (pull_request) Successful in 29s
Molecule / molecule (pull_request) In progress
Lint / lint (pull_request) Successful in 2m18s
The docker prerequisites and the system_baseline packages install only
from the distribution's sources, yet refreshed the APT cache on every
run. They now pass cache_valid_time: 3600, as the system_baseline update
task and user_management already do.

The docker and tailscale installs from the role's own APT source keep
refreshing on every run, so a run that wrote the source line but failed
to fetch its lists heals on the next run. The update entry points are
unchanged.

The system_baseline README tells a consumer who adds a source just
before the role to refresh the cache themselves.

Assisted-by: Claude Code:claude-opus-5-5
2026-11-27 15:10:32 +00:00
6 changed files with 11 additions and 61 deletions

No files matched your search

@@ -0,0 +1,7 @@
---
minor_changes:
- >-
docker, system_baseline - The install tasks that only use the distribution's sources (docker's
prerequisites, system_baseline's packages) refresh the APT cache only when it is older than an
hour; before, every run refreshed it. Installs from a role's own APT source still refresh it on
every run.
@@ -12,7 +12,6 @@ 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
@@ -1,60 +0,0 @@
# 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.
+2
View File
@@ -7,6 +7,7 @@
- curl
state: present
update_cache: true
cache_valid_time: 3600
tags: [docker, install]
- name: Ensure APT keyrings directory exists
@@ -40,6 +41,7 @@
ansible.builtin.apt:
name: "{{ docker_packages }}"
state: present
# Always refreshed: a run that wrote the source line but failed to fetch its lists heals here.
update_cache: true
register: __docker_packages
notify: Restart docker
+1
View File
@@ -159,6 +159,7 @@ system_baseline_extra_remove_packages: [telnet]
```
- Each item is a Debian package name: lower-case letters, digits, `+`, `-` and `.`, two or more characters, starting with a letter or digit and not ending in `-` (apt reads a trailing minus as a removal). Anything else stops the run. Duplicates of the profile list are harmless.
- The role does not refresh an APT cache younger than an hour, so a package from a source you add just before the role (`ansible.builtin.deb822_repository` does not refresh) needs your own cache refresh first.
- An extra counts wherever the role looks for a package in the list: an extra `tmux` enables the tmux snippet and an extra `unattended-upgrades` the unattended-upgrades tasks, as a profile package does.
- A package that one input installs and another purges stops the run before any change: `system_baseline_extra_packages` against `system_baseline_remove_packages` or `system_baseline_extra_remove_packages`, and `system_baseline_extra_remove_packages` against `system_baseline_essential_packages`. The resolved lists are not checked against each other, so a consumer's own overlap there behaves as before.
+1
View File
@@ -4,6 +4,7 @@
name: "{{ __system_baseline_install_packages }}"
state: present
update_cache: true
cache_valid_time: 3600
become: true
- name: Gather installed packages