From a6b8bc150d4a9b834c10905835d09c310976c184 Mon Sep 17 00:00:00 2001 From: Defame1297 Date: Wed, 25 Nov 2026 22:33:59 +0000 Subject: [PATCH] test(roles): run docker and gitea on 26.04 and check become in its smoke scenario molecule-ubuntu2604 0.1.7 lets become from root through and ships gnupg, so docker and gitea declare resolute like the other Ubuntu roles and the accepted exception goes. The 26.04 image-smoke scenario now checks become and gnupg, so a regression fails the image's own pin pull request. Assisted-by: Claude Code --- .../133-drop-jammy-and-ubuntu-all.yml | 3 +- changelogs/fragments/133-ubuntu-2604.yml | 6 ++-- .../molecule/image-smoke-2604/verify.yml | 12 +++++++ roles/AGENTS.md | 3 +- roles/docker/README.md | 6 ++-- roles/docker/meta/main.yml | 1 + roles/docker/molecule/default/molecule.yml | 28 ++++++++++++--- roles/gitea/README.md | 6 ++-- roles/gitea/meta/main.yml | 1 + roles/gitea/molecule/default/molecule.yml | 35 ++++++++++++++----- 10 files changed, 73 insertions(+), 28 deletions(-) diff --git a/changelogs/fragments/133-drop-jammy-and-ubuntu-all.yml b/changelogs/fragments/133-drop-jammy-and-ubuntu-all.yml index b8f0b9c..e26d49e 100644 --- a/changelogs/fragments/133-drop-jammy-and-ubuntu-all.yml +++ b/changelogs/fragments/133-drop-jammy-and-ubuntu-all.yml @@ -4,4 +4,5 @@ breaking_changes: sshd, system_baseline, systemd_hardening, ufw, user_management - No longer declare Ubuntu 22.04 (``jammy``). A platform a role declares is one it passes Molecule on in CI. - >- - docker - Declares Ubuntu 24.04 (``noble``) only instead of every Ubuntu release (``all``). + docker - Declares Ubuntu 24.04 (``noble``) and 26.04 (``resolute``) instead of every Ubuntu + release (``all``). diff --git a/changelogs/fragments/133-ubuntu-2604.yml b/changelogs/fragments/133-ubuntu-2604.yml index 2c71305..58b0543 100644 --- a/changelogs/fragments/133-ubuntu-2604.yml +++ b/changelogs/fragments/133-ubuntu-2604.yml @@ -1,6 +1,6 @@ --- minor_changes: - >- - cloudflared, fail2ban, gitea_runner, pihole, sshd, system_baseline, systemd_hardening, traefik, - ufw, user_management - Declare and are tested on Ubuntu 26.04 (``resolute``) next to 24.04 - (``noble``). + cloudflared, docker, fail2ban, gitea, gitea_runner, pihole, sshd, system_baseline, + systemd_hardening, traefik, ufw, user_management - Declare and are tested on Ubuntu 26.04 + (``resolute``) next to 24.04 (``noble``). diff --git a/extensions/molecule/image-smoke-2604/verify.yml b/extensions/molecule/image-smoke-2604/verify.yml index d38bf9a..a45cb09 100644 --- a/extensions/molecule/image-smoke-2604/verify.yml +++ b/extensions/molecule/image-smoke-2604/verify.yml @@ -33,6 +33,7 @@ - ufw - fail2ban - openssh-server + - gnupg - name: Query the units a role scenario relies on ansible.builtin.systemd: @@ -56,3 +57,14 @@ - name: NET_ADMIN is granted, so the firewall tools can work ansible.builtin.command: iptables -S changed_when: false + + - name: Run a task with become, as the role scenarios do + ansible.builtin.command: id -u + become: true + changed_when: false + register: kamino_smoke_become + + - name: Become reaches root + ansible.builtin.assert: + that: kamino_smoke_become.stdout == '0' + quiet: true diff --git a/roles/AGENTS.md b/roles/AGENTS.md index 657a35e..cf25c04 100644 --- a/roles/AGENTS.md +++ b/roles/AGENTS.md @@ -76,8 +76,7 @@ names a check that does not exist yet and its backlog issue. - **Declared means tested.** A platform in `meta/main.yml` is one the role passes Molecule on in CI; one used but untested goes only in a README "Untested platforms" line. Accepted until the - Debian image (#226) lands: `trixie` declared untested, and Debian `all` in network_interfaces; - and until the 26.04 molecule image is fixed (#376): `docker` and `gitea` declare `noble` only. + Debian image (#226) lands: `trixie` declared untested, and Debian `all` in network_interfaces. *Why:* no tool reads the declaration, so it is worth something only if true. *Held:* review. - **Platforms follow the target hosts.** Ubuntu-targeting roles declare exactly `noble` and `resolute`; Proxmox-targeting roles declare Debian `trixie`; each is tested on its own OS. diff --git a/roles/docker/README.md b/roles/docker/README.md index ffc4309..fb1435f 100644 --- a/roles/docker/README.md +++ b/roles/docker/README.md @@ -4,9 +4,7 @@ Installs Docker Engine from the upstream Docker APT repository, optionally updat ## Supported platforms -Ubuntu 24.04 (noble), the platform the molecule scenario runs on. The key and repository URLs point at `download.docker.com/linux/ubuntu`, and the source line uses `ansible_distribution_release`. The apt architecture is derived from the host (`x86_64` gives `amd64`, `aarch64` gives `arm64`); any other architecture fails the play until `docker_apt_arch` is set. A limited molecule scenario covers the role's own logic (see [Tests](#tests)); the real Docker Engine is not tested. - -Ubuntu 26.04 (resolute) is not declared yet: the 26.04 molecule image lacks gnupg, which the scenario needs. +Ubuntu 24.04 (noble) and 26.04 (resolute), the platforms the molecule scenario runs on. The key and repository URLs point at `download.docker.com/linux/ubuntu`, and the source line uses `ansible_distribution_release`. The apt architecture is derived from the host (`x86_64` gives `amd64`, `aarch64` gives `arm64`); any other architecture fails the play until `docker_apt_arch` is set. A limited molecule scenario covers the role's own logic (see [Tests](#tests)); the real Docker Engine is not tested. The role targets Ubuntu hosts only: it installs from Docker's Ubuntu repository, so it does not cover Debian trixie (Proxmox hosts). @@ -88,7 +86,7 @@ With any of `docker_daemon_options`, `docker_live_restore`, `docker_log_driver`, ## Tests -`molecule/default` runs in CI only (`.gitea/workflows/molecule.yml`, no local runner), on one platform: `${MOLECULE_IMAGE}` (Ubuntu 24.04). A real Docker Engine cannot run there: `dockerd` needs the bridge, iptables rules and a delegated cgroup, and the container has no privileged mode. So the scenario builds a local APT repository, signs it with a throwaway key, and points the role at it with `docker_gpg_url` and `docker_repo_base_url`. The repository holds empty stand-ins for `docker-ce`, `docker-ce-cli` and `containerd.io`. The stand-in `docker-ce` ships a stub `docker.service` (`sleep infinity`) and creates the `docker` group, as the real package does. +`molecule/default` runs in CI only (`.gitea/workflows/molecule.yml`, no local runner), on two platforms: `${MOLECULE_IMAGE}` (Ubuntu 24.04) and `${MOLECULE_IMAGE_2604}` (Ubuntu 26.04). A real Docker Engine cannot run there: `dockerd` needs the bridge, iptables rules and a delegated cgroup, and the container has no privileged mode. So the scenario builds a local APT repository, signs it with a throwaway key, and points the role at it with `docker_gpg_url` and `docker_repo_base_url`. The repository holds empty stand-ins for `docker-ce`, `docker-ce-cli` and `containerd.io`. The stand-in `docker-ce` ships a stub `docker.service` (`sleep infinity`) and creates the `docker` group, as the real package does. What it shows, with the role's tasks running unchanged: diff --git a/roles/docker/meta/main.yml b/roles/docker/meta/main.yml index 2e3bb29..571b35c 100644 --- a/roles/docker/meta/main.yml +++ b/roles/docker/meta/main.yml @@ -10,6 +10,7 @@ galaxy_info: - name: Ubuntu versions: - noble + - resolute galaxy_tags: - docker - containers diff --git a/roles/docker/molecule/default/molecule.yml b/roles/docker/molecule/default/molecule.yml index 3771cce..d7cfe21 100644 --- a/roles/docker/molecule/default/molecule.yml +++ b/roles/docker/molecule/default/molecule.yml @@ -1,9 +1,10 @@ --- -# Runs on the repository's own runner (label kamino-molecule), in the molecule-ubuntu2404 image -# (MOLECULE_IMAGE, the pin in .gitea/workflows/molecule.yml). No privileged mode: systemd needs a -# writable cgroup, nothing else. NET_ADMIN is kept so the platform matches the other scenarios; -# this role does not need it, because the Docker Engine is a stand-in package and no daemon, -# bridge or iptables rule is created. +# Runs on the repository's own runner (label kamino-molecule), in the molecule-ubuntu2404 +# (MOLECULE_IMAGE) and molecule-ubuntu2604 (MOLECULE_IMAGE_2604) images, pinned in +# .gitea/workflows/molecule.yml. No privileged mode: systemd needs a writable cgroup, nothing else. +# NET_ADMIN is kept so the platform matches the other scenarios; this role does not need it, +# because the Docker Engine is a stand-in package and no daemon, bridge or iptables rule is +# created. driver: name: docker platforms: @@ -24,6 +25,23 @@ platforms: - NET_ADMIN security_opts: - apparmor=unconfined + - name: ${KAMINO_RUN_ID:-local}-docker-2604-instance + labels: + net.rkdr.mortis.molecule-run: "${KAMINO_RUN_ID:-local}" + image: ${MOLECULE_IMAGE_2604} + 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 provisioner: name: ansible verifier: diff --git a/roles/gitea/README.md b/roles/gitea/README.md index 1b04754..6aee0c8 100644 --- a/roles/gitea/README.md +++ b/roles/gitea/README.md @@ -4,9 +4,7 @@ Installs the Gitea git service as a systemd-managed binary with a GPG-verified d ## Supported platforms -Ubuntu 24.04 (noble), the platform the molecule scenario runs on. The role uses `ansible.builtin.apt`, so Debian-family hosts only, and needs outbound access to dl.gitea.com for the binary and signature and to `gitea_gpg_key_url` (keys.openpgp.org over HTTPS by default) for the signing key. - -Ubuntu 26.04 (resolute) is not declared yet: the 26.04 molecule image lacks gnupg, which the scenario needs. +Ubuntu 24.04 (noble) and 26.04 (resolute), the platforms the molecule scenario runs on. The role uses `ansible.builtin.apt`, so Debian-family hosts only, and needs outbound access to dl.gitea.com for the binary and signature and to `gitea_gpg_key_url` (keys.openpgp.org over HTTPS by default) for the signing key. The role targets Ubuntu hosts that serve Gitea, not Proxmox nodes, so it does not cover Debian trixie. @@ -144,7 +142,7 @@ Update or remove: pass `-e gitea_update=true`, or `-e "gitea_remove=true gitea_r ## Tests -The `default` molecule scenario runs in CI only, on one platform: `${MOLECULE_IMAGE}` (Ubuntu 24.04). It never installs Gitea: converge applies nothing and every check is in `verify.yml` (see `molecule/default`). It covers: +The `default` molecule scenario runs in CI only, on two platforms: `${MOLECULE_IMAGE}` (Ubuntu 24.04) and `${MOLECULE_IMAGE_2604}` (Ubuntu 26.04). It never installs Gitea: converge applies nothing and every check is in `verify.yml` (see `molecule/default`). It covers: - The guard and no-op paths of the `mint` entry point: the confirm guard, the CI refusal under each of `GITHUB_ACTIONS`, `GITEA_ACTIONS` and `CI`, the no-op when `gitea_api_token` is set, and an empty token treated as missing under `--check`. All but the confirm guard run as child processes with a controlled environment. - The signature check of the download, against local files and throwaway keys: a signature by the pinned key places the binary; a signature by another key, a tampered binary and a key file without the pinned key each fail at the expected task; no download directory is left behind. diff --git a/roles/gitea/meta/main.yml b/roles/gitea/meta/main.yml index 5e8605a..6450c44 100644 --- a/roles/gitea/meta/main.yml +++ b/roles/gitea/meta/main.yml @@ -10,6 +10,7 @@ galaxy_info: - name: Ubuntu versions: - noble + - resolute galaxy_tags: - gitea - git diff --git a/roles/gitea/molecule/default/molecule.yml b/roles/gitea/molecule/default/molecule.yml index 90b0a6a..de433d5 100644 --- a/roles/gitea/molecule/default/molecule.yml +++ b/roles/gitea/molecule/default/molecule.yml @@ -1,13 +1,13 @@ --- -# Runs on the repository's own runner (label kamino-molecule), in the molecule-ubuntu2404 image -# (MOLECULE_IMAGE, the pin in .gitea/workflows/molecule.yml). Tests the guard and no-op paths of -# the role's `mint` entry point, the signature check of the download against local files and -# throwaway keys, and the remove path with its ufw rules. Gitea is never installed, so the -# normal-flow assert on gitea_api_token (after the service starts) is not -# covered. The mint tasks only assert, but the remove-path play at the end of verify.yml needs -# systemd (it stops and disables a stub unit) and ufw (it deletes the Gitea rules), so the -# container runs systemd as PID 1 with a writable cgroup and NET_ADMIN. No privileged mode. The -# image has ufw and gnupg preinstalled, so the scenario downloads nothing. +# Runs on the repository's own runner (label kamino-molecule), in the molecule-ubuntu2404 +# (MOLECULE_IMAGE) and molecule-ubuntu2604 (MOLECULE_IMAGE_2604) images, pinned in +# .gitea/workflows/molecule.yml. Tests the guard and no-op paths of the role's `mint` entry point, +# the signature check of the download against local files and throwaway keys, and the remove path +# with its ufw rules. Gitea is never installed, so the normal-flow assert on gitea_api_token (after +# the service starts) is not covered. The mint tasks only assert, but the remove-path play at the +# end of verify.yml needs systemd (it stops and disables a stub unit) and ufw (it deletes the Gitea +# rules), so the container runs systemd as PID 1 with a writable cgroup and NET_ADMIN. No +# privileged mode. Both images have ufw and gnupg preinstalled, so the scenario downloads nothing. driver: name: docker platforms: @@ -28,6 +28,23 @@ platforms: - NET_ADMIN security_opts: - apparmor=unconfined + - name: ${KAMINO_RUN_ID:-local}-gitea-2604-instance + labels: + net.rkdr.mortis.molecule-run: "${KAMINO_RUN_ID:-local}" + image: ${MOLECULE_IMAGE_2604} + 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 provisioner: name: ansible inventory: