The docker scenario installs gnupg in prepare to sign its stand-in APT repository, which costs an apt update and an install in every run (about 10 s of its 12 s prepare); system_baseline installs it among its essential packages. It is now part of the image, version 0.1.6. Image input only: the consumers' pins, the docker prepare task and the image-smoke contract move in the pin follow-up pull request, once the build on main has printed the new digest. Co-Authored-By: Claude Sonnet 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_014uGZTNmHMc85bomfevwUDG
83 lines
4.0 KiB
Markdown
83 lines
4.0 KiB
Markdown
# molecule-ubuntu2404
|
|
|
|
A disposable **Ubuntu 24.04** test target for the molecule scenarios of the
|
|
[`mortis.kamino`](https://git.rkdr.net/mortis/kamino) Ansible Collection: a container that behaves like a small
|
|
24.04 host (systemd as PID 1), so a role can be converged and verified in it without a VM.
|
|
It is the release of the home lab's LXC hosts today.
|
|
|
|
## What is in it
|
|
|
|
- Ubuntu 24.04 (the official `ubuntu:24.04` image, pinned by digest in the Dockerfile).
|
|
- systemd as the init system (`systemd`, `systemd-sysv`), D-Bus, `sudo`, `iproute2`,
|
|
`ca-certificates`.
|
|
- Python for Ansible on the target: `python3`, `python3-apt`, `python3-systemd`.
|
|
- The packages the roles manage, preinstalled so a converge makes no network calls:
|
|
`iptables`, `ufw`, `fail2ban`, `openssh-server` (the `ssh` unit is enabled), and `gnupg`
|
|
(the docker scenario signs its stand-in APT repository with it).
|
|
- Throwaway SSH host keys and a machine-id generated at build time. They are not secrets and the
|
|
image is a test target that must never be exposed to a network.
|
|
|
|
Package versions are not pinned: they are whatever the 24.04 archive held at build time.
|
|
`image-smoke`-style checks (below) assert the contract, not versions.
|
|
|
|
## How to use it
|
|
|
|
In a molecule scenario (`extensions/molecule/*/molecule.yml` or `roles/*/molecule/*/molecule.yml`)
|
|
with the docker driver:
|
|
|
|
```yaml
|
|
driver:
|
|
name: docker
|
|
platforms:
|
|
- name: instance
|
|
image: ${MOLECULE_IMAGE} # git.rkdr.net/mortis/molecule-ubuntu2404:<version>@sha256:<digest>, set by molecule.yml
|
|
pre_build_image: true
|
|
pull: true
|
|
command: /sbin/init
|
|
cgroupns_mode: host
|
|
volumes:
|
|
- /sys/fs/cgroup:/sys/fs/cgroup:rw
|
|
tmpfs:
|
|
- /run
|
|
- /run/lock
|
|
capabilities:
|
|
- NET_ADMIN
|
|
security_opts:
|
|
- apparmor=unconfined
|
|
```
|
|
|
|
systemd needs a writable cgroup (`cgroupns_mode: host`, the `/sys/fs/cgroup` mount and tmpfs on `/run`), the
|
|
firewall tools need `NET_ADMIN`, AppArmor is left unconfined for the container (`apparmor=unconfined`), and
|
|
nothing runs privileged. The docker driver needs molecule's docker plugin, which the runner provides.
|
|
|
|
The scenario `extensions/molecule/image-smoke` tests this image against that contract (release,
|
|
systemd, packages, the `dbus` and `ssh` units, the Python bindings, `NET_ADMIN`).
|
|
|
|
## Tags and pinning
|
|
|
|
- `<version>` is semver (`MAJOR.MINOR.PATCH`), 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 and is for looking, not for pinning.
|
|
- Pin `molecule-ubuntu2404:<version>@sha256:<digest>`; the digest is what is enforced. Consumers here:
|
|
`.gitea/workflows/molecule.yml`.
|
|
- Renovate is configured to move the pin to a new version after the image is built on `main` (the rule is in
|
|
`renovate.json`; the first pin of a brand-new image is made by hand).
|
|
|
|
## How it is built and kept up to date
|
|
|
|
`.gitea/workflows/image.yml` builds it with kaniko. The workflow runs on pushes to `main` that touch `images/**`,
|
|
`requirements-dev.txt`, `.pre-commit-config.yaml` or the workflow itself, never on a pull request, and builds an
|
|
image only when its `version:` in the workflow's matrix is not yet published. A change under
|
|
`images/molecule-ubuntu2404/` therefore needs a new `version:` (Lint enforces it) and the merge builds the image. The
|
|
Ubuntu release is fixed by the name: a new Ubuntu release is a new image (`molecule-ubuntuNNNN`), and the roles
|
|
are tested on every release the hosts run or are moving to.
|
|
|
|
## 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-ubuntu2404/Dockerfile`. Licence: GPL-3.0-or-later.
|