Files
Kamino/roles/traefik/molecule/default/prepare.yml
T
Defame1297 9ce0fbd433
Build / build (pull_request) Successful in 22s
Lint / lint (pull_request) Successful in 2m1s
Molecule / molecule (pull_request) Successful in 44m6s
fix(roles): refresh apt in the docker and traefik scenarios and apply review round 2
The molecule images ship without apt lists, and --check does not
refresh them, so the fresh-host check of docker and traefik could not
find curl and wget. Their prepare now refreshes the cache, as pihole's
and system_baseline's already do by installing fixtures.

The sequence test gets its own class after the platform tests, the
check-mode rule is split into guards and README, and the
user_management comment sits on the task it explains.

Assisted-by: Claude Code
2026-11-26 12:18:48 +00:00

43 lines
1.6 KiB
YAML

---
# systemd's sandboxing directives (ProtectSystem, PrivateTmp, PrivateDevices and
# the Protect* family) need a mount namespace, which needs CAP_SYS_ADMIN. The
# test container is unprivileged on purpose, so without this drop-in the unit
# fails with status 226/NAMESPACE. The drop-in resets only those directives;
# the user, capabilities, environment file and ExecStart under test are the
# role's own. The sandbox itself is therefore not covered by this scenario.
#
# User is reset too. The switch to User=traefik fails in the unprivileged container
# (exit 217/USER, "Failed to keep CAP_SYS_ADMIN"), so the unit runs as root here.
# The traefik user, the file ownership checks and the other unit settings are
# still asserted.
- name: Prepare
hosts: all
gather_facts: false
tasks:
# The image ships without apt lists, and --check does not refresh them, so the fresh-host
# check finds the packages the role installs.
- name: Refresh the apt cache
ansible.builtin.apt:
update_cache: true
- name: Create the unit drop-in directory
ansible.builtin.file:
path: /etc/systemd/system/traefik.service.d
state: directory
mode: "0755"
- name: Disable the namespace-based sandboxing for the unprivileged container
ansible.builtin.copy:
dest: /etc/systemd/system/traefik.service.d/molecule.conf
mode: "0644"
content: |
[Service]
ProtectSystem=no
ProtectHome=no
PrivateTmp=no
PrivateDevices=no
ProtectKernelModules=no
ProtectKernelTunables=no
ReadWritePaths=
User=