ci(images): stop baking ufw and fail2ban into the molecule images

ADR 0002 keeps a package a role installs out of the molecule images, so its scenario exercises
the install. The ufw and fail2ban roles install their packages, so both images drop them; iptables,
openssh-server, python3-systemd and gnupg stay as fixtures. The labels, header comments, image
docs and image-smoke package lists no longer claim the packages are baked or that a converge
makes no network calls.

Refs: #435
Assisted-by: Claude Code
This commit is contained in:
Defame1297 committed 2026-11-29 18:53:24 +00:00
1 parent 6e9709f0da
commit c64b4b932b
9 files changed
+35 -41

No files matched your search

+4 -3
View File
@@ -11,9 +11,10 @@ It is the release the hosts run today.
- 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).
- Test fixtures no role installs: `iptables`, `openssh-server` (the `ssh` unit is enabled), and
`gnupg` (the docker scenario signs its stand-in APT repository with it).
- No package a role installs, such as `ufw` or `fail2ban`: the role's scenario exercises that
install. The APT lists are removed, so such a scenario refreshes the APT cache in its prepare.
- 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.
+4 -3
View File
@@ -11,9 +11,10 @@ It is the release the hosts are moving to; every role scenario whose role declar
- 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).
- Test fixtures no role installs: `iptables`, `openssh-server` (the `ssh` unit is enabled), and
`gnupg` (the docker scenario signs its stand-in APT repository with it).
- No package a role installs, such as `ufw` or `fail2ban`: the role's scenario exercises that
install. The APT lists are removed, so such a scenario refreshes the APT cache in its prepare.
- root's `sudo` skips the PAM account check (`pam_rootok`), so `become` works in the container.
- 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.
@@ -15,7 +15,7 @@
ansible.builtin.package_facts:
manager: auto
- name: The packages the roles manage are preinstalled
- name: The fixtures the scenarios need are preinstalled
ansible.builtin.assert:
that: item in ansible_facts['packages']
quiet: true
@@ -30,8 +30,6 @@
- python3-apt
- python3-systemd
- iptables
- ufw
- fail2ban
- openssh-server
- gnupg
+1 -3
View File
@@ -15,7 +15,7 @@
ansible.builtin.package_facts:
manager: auto
- name: The packages the roles manage are preinstalled
- name: The fixtures the scenarios need are preinstalled
ansible.builtin.assert:
that: item in ansible_facts['packages']
quiet: true
@@ -30,8 +30,6 @@
- python3-apt
- python3-systemd
- iptables
- ufw
- fail2ban
- openssh-server
- gnupg
+10 -12
View File
@@ -1,7 +1,7 @@
# Molecule test target for the roles of this Collection: Ubuntu 24.04 with systemd
# as PID 1 and the packages the roles manage preinstalled, so a converge makes no
# network calls. It replaces the molecule test image that used to be built locally
# on the CI runner.
# as PID 1 and the fixtures the scenarios need preinstalled. A package a role installs
# is not baked in, so its scenario exercises the install (ADR 0002). It replaces the
# molecule test image that used to be built locally on the CI runner.
#
# Built by .gitea/workflows/image.yml with kaniko and pushed (never on pull
# requests) to git.rkdr.net/mortis/molecule-ubuntu2404. Consumers reference it
@@ -14,7 +14,7 @@
# scenario starts it with command /sbin/init, cgroupns_mode host, /sys/fs/cgroup
# mounted rw, tmpfs on /run and /run/lock, capability NET_ADMIN. No privileged mode.
#
# One RUN layer: about 30 MB compressed on top of the 29.8 MB base (estimated from
# One RUN layer: at most about 30 MB compressed on top of the 29.8 MB base (estimated from
# the real .debs, with the .pyc files the postinst scripts compile), far below
# Cloudflare's 100 MB request-body limit on git.rkdr.net (kaniko pushes a layer as
# one request; gnupg adds a few MB, not measured). apt packages are not version-pinned, as in the original image; the
@@ -28,7 +28,7 @@
FROM ubuntu:24.04@sha256:562111b88caa79c71391c0c4d3c2114a7d5c35915c20561fd893cb1e07929e6b
LABEL org.opencontainers.image.title="molecule-ubuntu2404" \
org.opencontainers.image.description="Disposable Ubuntu 24.04 test target for the molecule scenarios of the mortis.kamino Ansible Collection. systemd runs as PID 1 with D-Bus, sudo, python3 and the packages the roles manage (iptables, ufw, fail2ban, openssh-server) preinstalled, so a converge makes no network calls. Start it as a molecule platform (usage label); it carries throwaway SSH host keys and is a test target only, never to be exposed." \
org.opencontainers.image.description="Disposable Ubuntu 24.04 test target for the molecule scenarios of the mortis.kamino Ansible Collection. systemd runs as PID 1 with D-Bus, sudo, python3 and the test fixtures (iptables, openssh-server, gnupg) preinstalled. A package a role installs is not baked in and no APT lists are kept, so a scenario refreshes the APT cache before a role installs one. Start it as a molecule platform (usage label); it carries throwaway SSH host keys and is a test target only, never to be exposed." \
org.opencontainers.image.source="https://git.rkdr.net/mortis/kamino" \
org.opencontainers.image.url="https://git.rkdr.net/mortis/kamino" \
org.opencontainers.image.documentation="https://git.rkdr.net/mortis/kamino/src/branch/main/docs/images/molecule-ubuntu2404.md" \
@@ -36,22 +36,20 @@ LABEL org.opencontainers.image.title="molecule-ubuntu2404" \
org.opencontainers.image.authors="Defame1297 and contributors" \
org.opencontainers.image.base.name="ubuntu:24.04" \
net.rkdr.mortis.purpose="Disposable Ubuntu 24.04 test target for the molecule scenarios of the mortis.kamino Ansible Collection." \
net.rkdr.mortis.contents="Ubuntu 24.04, systemd, systemd-sysv, dbus, sudo, iproute2, ca-certificates, python3, python3-apt, python3-systemd, iptables, ufw, fail2ban, openssh-server (ssh enabled), gnupg" \
net.rkdr.mortis.contents="Ubuntu 24.04, systemd, systemd-sysv, dbus, sudo, iproute2, ca-certificates, python3, python3-apt, python3-systemd, iptables, openssh-server (ssh enabled), gnupg" \
net.rkdr.mortis.usage="Molecule docker-driver platform with pre_build_image true, command /sbin/init, cgroupns_mode host, /sys/fs/cgroup mounted rw, tmpfs on /run and /run/lock, capability NET_ADMIN, security_opts apparmor=unconfined (not privileged). Pin git.rkdr.net/mortis/name:version@sha256:digest. See the documentation label."
ENV DEBIAN_FRONTEND=noninteractive
# systemd as PID 1 with D-Bus, sudo and networking tools; the Python Ansible needs on
# the target (python3-apt for the apt module); the firewall and intrusion-prevention
# packages the roles manage (python3-systemd is a dependency of fail2ban's systemd
# backend); sshd, enabled so a converge can test it under systemd; gnupg, which the docker
# scenario signs its stand-in APT repository with and which would otherwise cost it an
# apt update and install in every run.
# the target (python3-apt for the apt module, python3-systemd for the journal); iptables;
# sshd, enabled so a converge can test it under systemd; gnupg, which the docker scenario
# signs its stand-in APT repository with. ufw and fail2ban are left out: their roles install them.
RUN apt-get update \
&& apt-get install -y --no-install-recommends \
systemd systemd-sysv dbus sudo iproute2 ca-certificates \
python3 python3-apt python3-systemd \
iptables ufw fail2ban \
iptables \
openssh-server \
gnupg \
&& rm -rf /var/lib/apt/lists/* \
+10 -12
View File
@@ -1,7 +1,7 @@
# Molecule test target for the roles of this Collection: Ubuntu 26.04 with systemd
# as PID 1 and the packages the roles manage preinstalled, so a converge makes no
# network calls. It replaces the molecule test image that used to be built locally
# on the CI runner.
# as PID 1 and the fixtures the scenarios need preinstalled. A package a role installs
# is not baked in, so its scenario exercises the install (ADR 0002). It replaces the
# molecule test image that used to be built locally on the CI runner.
#
# Built by .gitea/workflows/image.yml with kaniko and pushed (never on pull
# requests) to git.rkdr.net/mortis/molecule-ubuntu2604. Consumers reference it
@@ -14,7 +14,7 @@
# scenario starts it with command /sbin/init, cgroupns_mode host, /sys/fs/cgroup
# mounted rw, tmpfs on /run and /run/lock, capability NET_ADMIN. No privileged mode.
#
# One RUN layer: about 30 MB compressed on top of the 29.8 MB base (estimated from
# One RUN layer: at most about 30 MB compressed on top of the 29.8 MB base (estimated from
# the real .debs, with the .pyc files the postinst scripts compile), far below
# Cloudflare's 100 MB request-body limit on git.rkdr.net (kaniko pushes a layer as
# one request; gnupg adds a few MB, not measured). apt packages are not version-pinned, as in the original image; the
@@ -28,7 +28,7 @@
FROM ubuntu:26.04@sha256:d66b366dac61b575bee2aef07e9c26e8070096fbe84a3d4d3eb0da069b5d76db
LABEL org.opencontainers.image.title="molecule-ubuntu2604" \
org.opencontainers.image.description="Disposable Ubuntu 26.04 test target for the molecule scenarios of the mortis.kamino Ansible Collection. systemd runs as PID 1 with D-Bus, sudo, python3 and the packages the roles manage (iptables, ufw, fail2ban, openssh-server) preinstalled, so a converge makes no network calls. Start it as a molecule platform (usage label); it carries throwaway SSH host keys and is a test target only, never to be exposed." \
org.opencontainers.image.description="Disposable Ubuntu 26.04 test target for the molecule scenarios of the mortis.kamino Ansible Collection. systemd runs as PID 1 with D-Bus, sudo, python3 and the test fixtures (iptables, openssh-server, gnupg) preinstalled. A package a role installs is not baked in and no APT lists are kept, so a scenario refreshes the APT cache before a role installs one. Start it as a molecule platform (usage label); it carries throwaway SSH host keys and is a test target only, never to be exposed." \
org.opencontainers.image.source="https://git.rkdr.net/mortis/kamino" \
org.opencontainers.image.url="https://git.rkdr.net/mortis/kamino" \
org.opencontainers.image.documentation="https://git.rkdr.net/mortis/kamino/src/branch/main/docs/images/molecule-ubuntu2604.md" \
@@ -36,24 +36,22 @@ LABEL org.opencontainers.image.title="molecule-ubuntu2604" \
org.opencontainers.image.authors="Defame1297 and contributors" \
org.opencontainers.image.base.name="ubuntu:26.04" \
net.rkdr.mortis.purpose="Disposable Ubuntu 26.04 test target for the molecule scenarios of the mortis.kamino Ansible Collection." \
net.rkdr.mortis.contents="Ubuntu 26.04, systemd, systemd-sysv, dbus, sudo, iproute2, ca-certificates, python3, python3-apt, python3-systemd, iptables, ufw, fail2ban, openssh-server (ssh enabled), gnupg" \
net.rkdr.mortis.contents="Ubuntu 26.04, systemd, systemd-sysv, dbus, sudo, iproute2, ca-certificates, python3, python3-apt, python3-systemd, iptables, openssh-server (ssh enabled), gnupg" \
net.rkdr.mortis.usage="Molecule docker-driver platform with pre_build_image true, command /sbin/init, cgroupns_mode host, /sys/fs/cgroup mounted rw, tmpfs on /run and /run/lock, capability NET_ADMIN, security_opts apparmor=unconfined (not privileged). Pin git.rkdr.net/mortis/name:version@sha256:digest. See the documentation label."
ENV DEBIAN_FRONTEND=noninteractive
# systemd as PID 1 with D-Bus, sudo and networking tools; the Python Ansible needs on
# the target (python3-apt for the apt module); the firewall and intrusion-prevention
# packages the roles manage (python3-systemd is a dependency of fail2ban's systemd
# backend); sshd, enabled so a converge can test it under systemd; gnupg, which the docker
# scenario signs its stand-in APT repository with and which would otherwise cost it an
# apt update and install in every run.
# the target (python3-apt for the apt module, python3-systemd for the journal); iptables;
# sshd, enabled so a converge can test it under systemd; gnupg, which the docker scenario
# signs its stand-in APT repository with. ufw and fail2ban are left out: their roles install them.
# root's sudo (Ansible's become here) skips pam_unix's account check, whose unix_chkpwd
# helper fails inside the container; non-root callers still go through pam_unix.
RUN apt-get update \
&& apt-get install -y --no-install-recommends \
systemd systemd-sysv dbus sudo iproute2 ca-certificates \
python3 python3-apt python3-systemd \
iptables ufw fail2ban \
iptables \
openssh-server \
gnupg \
&& rm -rf /var/lib/apt/lists/* \
+1 -1
View File
@@ -82,7 +82,7 @@ Main entry point: `fail2ban` (everything), `fail2ban_install`, `fail2ban_validat
## Tests
The scenario `molecule/default/` runs in CI only, on two platforms: `${MOLECULE_IMAGE}` (Ubuntu 24.04) and `${MOLECULE_IMAGE_2604}` (Ubuntu 26.04). It runs `check` before the converge (a fresh host, where the image already has fail2ban installed) and after it (a configured host).
The scenario `molecule/default/` runs in CI only, on two platforms: `${MOLECULE_IMAGE}` (Ubuntu 24.04) and `${MOLECULE_IMAGE_2604}` (Ubuntu 26.04). It runs `check` before the converge (a fresh host, where the role installs fail2ban) and after it (a configured host).
- Converge applies the main entry point with an extra `fail2ban_ignoreip` network and calls `service_jail` twice, one jail with a `logpath` and one with a `journalmatch`.
- Converge also runs inputs that must be refused: a service filter without `failregex`, and a `fail2ban_ignoreip` entry with whitespace, a plain string instead of a list, and an entry starting with `;`. The `fail2ban_ignoreip` refusals are matched on their message.
@@ -1,6 +1,6 @@
---
# The image ships fail2ban and no APT lists; the check step needs fail2ban gone and the lists back,
# or the install task cannot even preview the package.
# The purge keeps the scenario independent of what the image ships. The image keeps no APT lists,
# and the check step needs them, or the install task cannot even preview the package.
- name: Prepare a host without fail2ban
hosts: all
gather_facts: false
+2 -2
View File
@@ -1,6 +1,6 @@
---
# The image ships ufw and no APT lists; the check step needs ufw gone and the lists back, or the
# install task cannot even preview the package.
# The purge keeps the scenario independent of what the image ships. The image keeps no APT lists,
# and the check step needs them, or the install task cannot even preview the package.
- name: Prepare a host without ufw
hosts: all
gather_facts: false