From 6e9709f0da411b144a8e3e4068275129594fa9bd Mon Sep 17 00:00:00 2001 From: Defame1297 Date: Sun, 29 Nov 2026 17:32:45 +0000 Subject: [PATCH] test(molecule): refresh the APT cache where a scenario installs ufw or fail2ban The molecule images keep no APT lists, and the ufw and fail2ban scenarios, and the gitea scenario's remove path, relied on those packages being baked in. Their prepare now refreshes the cache, so they keep working once the images stop shipping the packages. Refs: #435 Assisted-by: Claude Code --- roles/fail2ban/molecule/default/prepare.yml | 8 +++++++- roles/gitea/molecule/default/molecule.yml | 2 +- roles/gitea/molecule/default/prepare.yml | 12 ++++++++++++ roles/ufw/molecule/default/prepare.yml | 4 +++- 4 files changed, 23 insertions(+), 3 deletions(-) create mode 100644 roles/gitea/molecule/default/prepare.yml diff --git a/roles/fail2ban/molecule/default/prepare.yml b/roles/fail2ban/molecule/default/prepare.yml index 4a145df..22f174f 100644 --- a/roles/fail2ban/molecule/default/prepare.yml +++ b/roles/fail2ban/molecule/default/prepare.yml @@ -1,9 +1,15 @@ --- -# The log file a service jail watches must exist, or `fail2ban-client -t` fails. +# The image keeps no APT lists, and --check does not refresh them, so the fresh-host check needs +# them to preview the fail2ban install. The log file a service jail watches must exist, or +# `fail2ban-client -t` fails. - name: Prepare hosts: all gather_facts: false tasks: + - name: Refresh the APT cache + ansible.builtin.apt: + update_cache: true + - name: Create the log file the logpath jail watches ansible.builtin.file: path: /var/log/svc-a.log diff --git a/roles/gitea/molecule/default/molecule.yml b/roles/gitea/molecule/default/molecule.yml index 658e893..5b56634 100644 --- a/roles/gitea/molecule/default/molecule.yml +++ b/roles/gitea/molecule/default/molecule.yml @@ -7,7 +7,7 @@ # 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. +# privileged mode. Both images have gnupg preinstalled; prepare.yml installs ufw from the archive. driver: name: docker platforms: diff --git a/roles/gitea/molecule/default/prepare.yml b/roles/gitea/molecule/default/prepare.yml new file mode 100644 index 0000000..046b365 --- /dev/null +++ b/roles/gitea/molecule/default/prepare.yml @@ -0,0 +1,12 @@ +--- +# The remove-path play in verify.yml needs ufw, which the image does not ship. It keeps no APT +# lists, so the install refreshes them. +- name: Prepare + hosts: all + gather_facts: false + tasks: + - name: Install ufw + ansible.builtin.apt: + name: ufw + state: present + update_cache: true diff --git a/roles/ufw/molecule/default/prepare.yml b/roles/ufw/molecule/default/prepare.yml index c16fff8..3dd444e 100644 --- a/roles/ufw/molecule/default/prepare.yml +++ b/roles/ufw/molecule/default/prepare.yml @@ -7,10 +7,12 @@ hosts: all gather_facts: false tasks: + # The image keeps no APT lists, so the install refreshes them. - name: Install ufw - ansible.builtin.package: + ansible.builtin.apt: name: ufw state: present + update_cache: true # An application profile whose name holds openssh, for the orphan seeds below. - name: Define an application profile named like SSH