Author SHA1 Message Date
Dragonish fcd2290e14 test(nfs_client): refresh the apt cache in the scenario's prepare
Molecule / molecule (pull_request) Successful in 2m5s
Lint / lint (pull_request) Successful in 2m47s
Build / build (pull_request) Successful in 31s
The molecule image ships without apt lists, and --check does not refresh
them, so the fresh-host check found no nfs-common to install and failed
with "No package matching 'nfs-common' is available". The docker, pihole,
system_baseline and traefik scenarios refresh the cache in prepare for the
same reason.

Refs #402

Assisted-by: Claude Code
2026-11-27 21:55:02 +00:00
Dragonish 5ce5e3c932 feat(nfs_client): add a role that manages NFS client entries in fstab
Build / build (pull_request) Successful in 31s
Molecule / molecule (pull_request) Failing after 43s
Lint / lint (pull_request) Successful in 1m53s
Installs nfs-common and manages NFS mount entries from nfs_client_mounts
(src, path, optional opts, state present or absent). Each mount point is
created without owner, group or mode, because once a share is mounted a
chown or chmod there changes the permissions on the NFS server. The role
writes only the fstab line and reloads systemd; it never mounts or
unmounts. An absent entry maps to ansible.posix.mount's absent_from_fstab,
which removes the line and leaves the share and the directory alone.

The default options are _netdev,nofail. x-systemd.automount is left out.

Verified locally: yamllint, ansible-lint (production profile), syntax check
of the scenario playbooks, the controller-side refusals of verify.yml (14
cases, each matched on its own message), and the module's fstab behaviour
against a scratch fstab (replacement, absent_from_fstab, idempotence).
Not verified: Molecule, which runs only in CI; the apt install and the
daemon-reload handler; that systemd generates the mount units in the
scenario's containers.

Refs #402

Assisted-by: Claude Code
2026-11-27 21:47:09 +00:00
Defame1297 b3b62121a3 Merge pull request 'chore(release): 3.2.0' (#450) from chore/release-3.2.0 into main
Build / build (push) Successful in 17s
Reviewed-on: #450
2026-11-27 21:45:36 +00:00
Defame1297 b7bac07757 chore(release): 3.2.0
Molecule / molecule (pull_request) Successful in 6s
Lint / lint (pull_request) Successful in 1m35s
Build / build (pull_request) Successful in 29s
Minor release: new inputs for system_baseline (extra packages, skipping
the upgrade during a vzdump backup, leaving journald alone), cloudflared
and traefik, a staleness window for distribution-only APT refreshes, and
facts read through ansible_facts in docker, gitea_runner and
system_baseline.

Assisted-by: Claude Code
2026-11-27 21:36:05 +00:00
Defame1297 30a8e71f97 Merge pull request 'fix(system_baseline): accept every size journald reads for the journal cap' (#449) from fix/journal-max-use-syntax into main
Reviewed-on: #449
2026-11-27 21:33:50 +00:00
Defame1297 985995656a fix(system_baseline): accept every size journald reads for the journal cap
Build / build (pull_request) Successful in 48s
Lint / lint (pull_request) Successful in 2m47s
Molecule / molecule (pull_request) Successful in 6m7s
The new check on system_baseline_journal_max_use refused sizes journald
accepts (a bare byte count, 1.5G, 10 M, P and E units), which 3.1.0
wrote as given, and accepted infinity, which SystemMaxUse does not take.
The check now follows journald's parse_size(): a number with an
optional upper-case B, K, M, G, T, P or E, still with no line break.

Assisted-by: Claude Code
2026-11-27 21:24:32 +00:00
Defame1297 5ac8eadac1 Merge pull request 'chore(deps): update git.rkdr.net/mortis/molecule-ubuntu2404 docker tag to v0.1.11' (#447) from renovate/own-ci-images into main
Reviewed-on: #447
Reviewed-by: Defame1297 <[email protected]>
2026-11-27 20:01:04 +00:00
renovate-bot 1ab99405ea chore(deps): update git.rkdr.net/mortis/molecule-ubuntu2404 docker tag to v0.1.11
renovate/stability-days Updates have met minimum release age requirement
Lint / lint (pull_request) Successful in 3m27s
Build / build (pull_request) Successful in 1m14s
Molecule / molecule (pull_request) Successful in 34m35s
2026-11-27 19:25:48 +00:00
Defame1297 5fa17e036c Merge pull request 'feat(system_baseline): optionally skip the upgrade while a vzdump backup is running' (#410) from feat/400-skip-upgrade-during-vzdump into main
Reviewed-on: #410
Reviewed-by: Defame1297 <[email protected]>
2026-11-27 19:24:38 +00:00
Defame1297 dab3bd2d44 Merge branch 'main' into feat/400-skip-upgrade-during-vzdump
Lint / lint (pull_request) Successful in 2m30s
Molecule / molecule (pull_request) Successful in 6m20s
Build / build (pull_request) Successful in 31s
2026-11-27 19:17:40 +00:00
Defame1297 1be02c574b Merge pull request 'feat(cloudflared): add cloudflared_tunnel_lookup_delay input' (#441) from feat/cloudflared-lookup-delay into main
Reviewed-on: #441
2026-11-27 19:14:48 +00:00
Defame1297 084d2d592f Merge branch 'main' into feat/cloudflared-lookup-delay
Build / build (pull_request) Successful in 34s
Lint / lint (pull_request) Successful in 2m55s
Molecule / molecule (pull_request) Successful in 3m34s
2026-11-27 19:06:43 +00:00
Defame1297 90f27812eb Merge pull request 'test(tailscale): let apt reuse downloaded packages in the default scenario' (#440) from test/tailscale-reuse-debs into main
Reviewed-on: #440
2026-11-27 19:00:28 +00:00
Defame1297 a5c1426b25 Merge branch 'main' into test/tailscale-reuse-debs
Lint / lint (pull_request) Successful in 2m24s
Molecule / molecule (pull_request) Successful in 2m47s
Build / build (pull_request) Successful in 37s
2026-11-27 18:56:36 +00:00
Defame1297 4c1cba6e35 Merge pull request 'feat(traefik): add traefik_release_url for a release mirror' (#445) from feat/traefik-release-url into main
Reviewed-on: #445
2026-11-27 18:54:23 +00:00
Defame1297 008039c60c Merge remote-tracking branch 'origin/main' into feat/400-skip-upgrade-during-vzdump
Lint / lint (pull_request) Successful in 2m46s
Build / build (pull_request) Successful in 38s
Molecule / molecule (pull_request) Successful in 9m12s
Assisted-by: Claude Code
2026-11-27 18:52:49 +00:00
Defame1297 6364445e3c Merge branch 'main' into feat/traefik-release-url
Build / build (pull_request) Successful in 38s
Lint / lint (pull_request) Successful in 2m36s
Molecule / molecule (pull_request) Successful in 5m10s
2026-11-27 18:48:13 +00:00
Defame1297 30352502dd Merge pull request 'feat: refresh the APT cache on distribution-only installs when stale' (#443) from feat/apt-cache-valid-time into main
Reviewed-on: #443
2026-11-27 18:43:54 +00:00
Defame1297 9ae5eca2a3 Merge branch 'main' into feat/apt-cache-valid-time
Lint / lint (pull_request) Successful in 4m10s
Molecule / molecule (pull_request) Successful in 11m57s
Build / build (pull_request) Successful in 31s
2026-11-27 18:31:05 +00:00
Defame1297 b3037273b7 Merge pull request 'ci: turn on Ansible pipelining for Molecule scenarios' (#446) from ci/molecule-pipelining into main
Reviewed-on: #446
2026-11-27 18:07:33 +00:00
Defame1297 34990718f0 Merge branch 'main' into ci/molecule-pipelining
Build / build (pull_request) Successful in 34s
Lint / lint (pull_request) Successful in 2m58s
Molecule / molecule (pull_request) Successful in 37m27s
2026-11-27 17:29:13 +00:00
Defame1297 47540320b6 Merge pull request 'ci: share a Molecule base config with prerun off and smart gathering' (#444) from ci/molecule-shared-config into main
Reviewed-on: #444
Reviewed-by: Defame1297 <[email protected]>
2026-11-27 17:28:18 +00:00
Defame1297 afd62a8cbb Merge branch 'main' into ci/molecule-shared-config
Lint / lint (pull_request) Successful in 3m4s
Molecule / molecule (pull_request) Successful in 47m44s
Build / build (pull_request) Successful in 30s
2026-11-27 16:35:18 +00:00
Defame1297 810a74d8e5 Merge pull request 'test: check refusals once on the controller in verify' (#442) from test/refusals-in-verify into main
Reviewed-on: #442
Reviewed-by: Defame1297 <[email protected]>
2026-11-27 16:32:23 +00:00
Defame1297 87738f65fd Merge branch 'main' into test/refusals-in-verify
Build / build (pull_request) Successful in 29s
Lint / lint (pull_request) Successful in 3m20s
Molecule / molecule (pull_request) Successful in 22m24s
2026-11-27 16:09:20 +00:00
Defame1297 48e6dcb543 Merge pull request 'ci(molecule): select by image pin for a molecule.yml change of only pins or comments' (#439) from ci/selector-narrow-pins into main
Reviewed-on: #439
Reviewed-by: Defame1297 <[email protected]>
2026-11-27 16:08:45 +00:00
Defame1297 7df98ea8c7 Merge branch 'main' into ci/selector-narrow-pins
Build / build (pull_request) Successful in 28s
Molecule / molecule (pull_request) Successful in 5s
Lint / lint (pull_request) Successful in 1m33s
2026-11-27 16:07:04 +00:00
Defame1297 4a6db3382c Merge pull request 'docs(adr): run Molecule in its own controller image' (#437) from docs/adr-molecule-controller-image into main
Reviewed-on: #437
2026-11-27 16:06:47 +00:00
Defame1297 5e230201e6 Merge branch 'main' into docs/adr-molecule-controller-image
Build / build (pull_request) Successful in 29s
Molecule / molecule (pull_request) Successful in 5s
Lint / lint (pull_request) Successful in 1m33s
2026-11-27 16:05:04 +00:00
Defame1297 114a21fc0f Merge pull request 'docs: update a branch from main only when it is next to merge' (#436) from docs/branch-update-rule into main
Reviewed-on: #436
Reviewed-by: Defame1297 <[email protected]>
2026-11-27 16:04:44 +00:00
Defame1297 c33da78633 Merge branch 'main' into docs/branch-update-rule
Molecule / molecule (pull_request) Successful in 7s
Lint / lint (pull_request) Successful in 1m33s
Build / build (pull_request) Successful in 29s
2026-11-27 16:03:01 +00:00
Defame1297 7dbf9a1bd0 Merge pull request 'ci(renovate): group updates and open them on Mondays' (#438) from ci/renovate-group-schedule into main
Reviewed-on: #438
2026-11-27 16:02:48 +00:00
Defame1297 6c031acc26 Merge branch 'main' into ci/renovate-group-schedule
Build / build (pull_request) Successful in 31s
Molecule / molecule (pull_request) Successful in 4s
Lint / lint (pull_request) Successful in 1m36s
2026-11-27 15:59:47 +00:00
Defame1297 380d52cd13 ci: turn on Ansible pipelining for Molecule scenarios
Molecule / molecule (pull_request) Canceled after 0s
Build / build (pull_request) Canceled after 7s
Lint / lint (pull_request) Canceled after 7s
Set connection.pipelining in the shared Molecule base config. Without
it, every remote task over the community.docker.docker connection pays
extra docker exec and docker cp calls to create a temp dir, copy the
module in and clean up; with it, the module goes over stdin.

The docker connection declares has_pipelining and has no pipelining
option of its own, so core's global setting applies. No role or image
sets requiretty.

Closes #423

Assisted-by: Claude Code:claude-opus-5-5
2026-11-27 15:44:34 +00:00
Defame1297 ab0ce421cc feat(traefik): add traefik_release_url for a release mirror
Lint / lint (pull_request) Canceled after 0s
Molecule / molecule (pull_request) Canceled after 0s
Build / build (pull_request) Canceled after 0s
The archive and checksums URLs were hardcoded to the GitHub releases.
traefik_release_url (default: the GitHub release directory of
traefik_version, as before) lets a host download from a mirror.

The Molecule scenario uses it: verify's update path now downloads
stand-in releases that prepare.yml builds under /opt/molecule-download
(a stub binary answering `version`, its archive and a sha256sum
checksums file), so it no longer fetches two more real releases per
host. The converge still downloads the real release from GitHub, which
keeps the default URL proven. traefik_verify_other_version moves to the
scenario's group vars so prepare and verify share it. The update path
leaves the stub installed, which the README and verify now state.

Verify replaces the fixed 15 s pause with a poll (30 x 2 s) for an
"Unable to obtain ACME certificate" log line stamped at or after the
running process's ExecMainStartTimestamp, so a line left by the
process converge restarted does not count. It fails closed on a
missing start time, a missing line or an unparseable stamp. It then
asserts NRestarts
is 0, since Restart=always would hide a crash.

Assisted-by: Claude Code:claude-opus-5-5
2026-11-27 15:36:34 +00:00
Defame1297 7d11d23294 ci: share a Molecule base config with prerun off and smart gathering
Build / build (pull_request) Successful in 50s
Lint / lint (pull_request) Successful in 5m11s
Molecule / molecule (pull_request) Canceled after 16m59s
Add .config/molecule/config.yml, which molecule merges under every
scenario's molecule.yml. prerun is off: the CI wrapper already puts the
checkout first on ANSIBLE_COLLECTIONS_PATH, so molecule's per-scenario
reinstall of mortis.kamino into ANSIBLE_HOME is redundant. gathering is
smart, so each host's facts are gathered once per playbook run instead
of in every play.

Add .config to build_ignore so scripts/check_tarball.py does not fail
the build, and reword the Molecule rule and the two script comments that
said molecule installs the collection into each scenario's ANSIBLE_HOME.

Assisted-by: Claude Code:claude-opus-5-5
2026-11-27 15:20:18 +00:00
Defame1297 0973f39831 feat: refresh the APT cache on distribution-only installs when stale
Build / build (pull_request) Successful in 29s
Lint / lint (pull_request) Successful in 2m18s
Molecule / molecule (pull_request) Canceled after 26m49s
The docker prerequisites and the system_baseline packages install only
from the distribution's sources, yet refreshed the APT cache on every
run. They now pass cache_valid_time: 3600, as the system_baseline update
task and user_management already do.

The docker and tailscale installs from the role's own APT source keep
refreshing on every run, so a run that wrote the source line but failed
to fetch its lists heals on the next run. The update entry points are
unchanged.

The system_baseline README tells a consumer who adds a source just
before the role to refresh the cache themselves.

Assisted-by: Claude Code:claude-opus-5-5
2026-11-27 15:10:32 +00:00
Defame1297 2e70980b44 test: check refusals once on the controller in verify
Build / build (pull_request) Successful in 1m10s
Lint / lint (pull_request) Successful in 2m54s
Molecule / molecule (pull_request) Successful in 18m44s
converge.yml is replayed by check, converge, check and idempotence on
both platforms, so the validation-only plays in it ran eight times per
scenario. They need no container: move them to the top of verify.yml,
on localhost in check mode, so they run once and a regressed refusal
cannot change the controller.

Applies to the default scenarios of system_baseline, docker, sshd and
systemd_hardening. The systemd_hardening refusal of a drop-in entry
that is not a mapping comes after the disable and mask tasks, so it
moves to verify.yml but stays on the container. The README Tests
sections say where each check now runs.

Assisted-by: Claude Code:claude-opus-5-5
2026-11-27 15:05:34 +00:00
Defame1297 6eca2f4031 ci(molecule): select by image pin for a molecule.yml change of only pins or comments
Build / build (pull_request) Successful in 29s
Lint / lint (pull_request) Successful in 1m59s
Molecule / molecule (pull_request) Successful in 1m37s
A change to .gitea/workflows/molecule.yml selected every scenario, so a
molecule image pin bump or a comment edit ran the full set. The selector
now compares the merge-base and HEAD copies of the workflow:

- `#` and blank lines outside a block scalar are dropped; inside one
  (a `run: |` script, where they may be heredoc content) they count;
- the line after each CI_IMAGE, MOLECULE_IMAGE and MOLECULE_IMAGE_2604
  `>-` key must be its value, deeper than the key and in the shape
  Renovate writes, in both copies;
- comments only select nothing; a MOLECULE_IMAGE* pin selects every
  scenario with a file naming it, or every scenario when a shared
  molecule file names it or a file is unreadable or a symlink;
- CI_IMAGE, any other difference or a git error selects everything.

reason_for() is split out of select() to stay under ruff's complexity
limit. The Molecule rule in .gitea/workflows/AGENTS.md describes the
new case.

Assisted-by: Claude Code:claude-opus-5-5
2026-11-27 14:36:24 +00:00
Defame1297 16b1aa4136 ci(renovate): group updates and open them on Mondays
Build / build (pull_request) Successful in 23s
Molecule / molecule (pull_request) Successful in 1m13s
Lint / lint (pull_request) Successful in 2m11s
Updates, lock file maintenance included, open on Mondays (UTC) so any
Monday run can act, with no hourly pull request limit; the weekly window
and the groups bound the volume. Groups: own CI images (ci and both
molecule pins, exempt from the schedule), ubuntu base images (Dockerfile
FROM and image.yml job_image digests in one branch, so manual), lint
tooling and pre-commit hooks. osvVulnerabilityAlerts brings fixes from
osv.dev; they skip the schedule and the release-age wait, so
vulnerabilityAlerts.automerge false keeps a person on each one.

Assisted-by: Claude Code:claude-opus-5-5
2026-11-27 14:25:23 +00:00
Defame1297 1048628cc4 feat(cloudflared): add cloudflared_tunnel_lookup_delay input
Build / build (pull_request) Successful in 41s
Lint / lint (pull_request) Successful in 3m27s
Molecule / molecule (pull_request) Successful in 4m11s
The tunnel lookup retries a 404 three times, 5 seconds apart, before it
trusts it. The new input sets that delay (default 5, as before), and
validate.yml refuses a negative value. The Molecule failure cases pass 0:
the stub API answers at once, and the three retries still run.

Assisted-by: Claude Code:claude-opus-5-5
2026-11-27 14:14:56 +00:00
Defame1297 0eade70b56 test(tailscale): let apt reuse downloaded packages in the default scenario
Build / build (pull_request) Successful in 23s
Lint / lint (pull_request) Successful in 2m17s
Molecule / molecule (pull_request) Successful in 6m14s
The Ubuntu base image's /etc/apt/apt.conf.d/docker-clean deletes every
downloaded .deb after an install, so verify's downgrade, update and
reinstalls fetched tailscale from pkgs.tailscale.com again each time. A
prepare playbook removes it; the install from the real repository stays,
and apt still checks a cached .deb against the repository's hashes.

Assisted-by: Claude Code:claude-opus-5-5
2026-11-27 14:10:53 +00:00
Defame1297 e4eb3bc656 Merge branch 'main' into docs/branch-update-rule
Molecule / molecule (pull_request) Successful in 7s
Lint / lint (pull_request) Successful in 1m29s
Build / build (pull_request) Successful in 34s
2026-11-27 14:09:00 +00:00
Defame1297 15c3731e7f Merge pull request 'chore(deps): update git.rkdr.net/mortis/ci docker tag to v0.2.47' (#416) from renovate/git.rkdr.net-mortis-ci-0.x into main
Reviewed-on: #416
Reviewed-by: Defame1297 <[email protected]>
2026-11-27 14:02:47 +00:00
Defame1297 04259751ad docs(adr): point ADR 0002 to ADR 0003 and sharpen 0003
Build / build (pull_request) Successful in 51s
Lint / lint (pull_request) Canceled after 50s
Molecule / molecule (pull_request) Canceled after 8s
ADR 0002's image bullet now names ADR 0003 as the decision that adds
Molecule's controller image; its decision is unchanged. ADR 0003 states
the Lint-only share of ci pin pull requests as a count and lists the
push paths of image.yml among the files the implementation updates.

Assisted-by: Claude Code:claude-opus-5-5
2026-11-27 13:50:55 +00:00
Defame1297 699179674f docs: bring a renovate/ branch up to date through its rebase checkbox
Build / build (pull_request) Successful in 1m19s
Lint / lint (pull_request) Successful in 3m38s
Molecule / molecule (pull_request) Successful in 2m37s
A Renovate pull request is not always rebased just for falling
behind main, so forbidding every update would leave it stuck. Never
use the update button on it; tick the rebase/retry checkbox instead,
and say why a hand-made update commit is excluded.

Assisted-by: Claude Code:claude-opus-5-5
2026-11-27 13:45:55 +00:00
Defame1297 bf604a1af2 docs(adr): run Molecule in its own controller image
Record ADR 0003: Molecule runs in a molecule-controller image that bakes
only Molecule's tools, from a requirements file and hash-pinned lock of
its own, so a ci pin pull request no longer moves molecule.yml and runs
no scenario. The ADR lists the files the implementation updates and the
alternatives not taken.

Assisted-by: Claude Code:claude-opus-5-5
2026-11-27 13:38:09 +00:00
Defame1297 3d2fab5388 docs: update a branch from main only when it is next to merge
main blocks an outdated branch, so every update re-runs Lint, Build
and Molecule and cancels the run in progress. Limit updates to the
pull request that is next to merge, schedule its merge afterwards,
and leave renovate/ branches to Renovate's own rebase.

Assisted-by: Claude Code:claude-opus-5-5
2026-11-27 13:37:49 +00:00
renovate-bot 042051b3e5 chore(deps): update git.rkdr.net/mortis/ci docker tag to v0.2.48
renovate/stability-days Updates have met minimum release age requirement
Gitea release key / check (pull_request) Successful in 24s
Build / build (pull_request) Successful in 1m28s
Lint / lint (pull_request) Successful in 2m13s
Molecule / molecule (pull_request) Successful in 57m8s
2026-11-27 13:02:52 +00:00
Defame1297 6e3ea4521b Merge pull request 'chore(deps): update dependency community.docker to v5.4.1' (#414) from renovate/community.docker-5.x into main
Images / image (0.1, Dockerfile, ubuntu:24.04@sha256:562111b88caa79c71391c0c4d3c2114a7d5c35915c20561fd893cb1e07929e6b, molecule-ubuntu2404, images/molecule-ubuntu2404) (push) Successful in 19s
Images / image (0.1, Dockerfile, ubuntu:26.04@sha256:d66b366dac61b575bee2aef07e9c26e8070096fbe84a3d4d3eb0da069b5d76db, molecule-ubuntu2604, images/molecule-ubuntu2604) (push) Successful in 44s
Images / image (0.2, images/ci/Dockerfile, ubuntu:26.04@sha256:d66b366dac61b575bee2aef07e9c26e8070096fbe84a3d4d3eb0da069b5d76db, ci, ) (push) Successful in 5m52s
Reviewed-on: #414
2026-11-27 12:54:31 +00:00
renovate-bot 7433a37697 chore(deps): update dependency community.docker to v5.4.1
renovate/stability-days Updates have met minimum release age requirement
Build / build (pull_request) Successful in 25s
Lint / lint (pull_request) Successful in 2m26s
Molecule / molecule (pull_request) Successful in 1h15m2s
2026-11-27 11:39:00 +00:00
Defame1297 0b8c45a19c Merge pull request 'chore(deps): update ubuntu:24.04 docker digest to 562111b' (#412) from renovate/job-container-ubuntu-24.04 into main
Images / image (0.1, Dockerfile, ubuntu:24.04@sha256:562111b88caa79c71391c0c4d3c2114a7d5c35915c20561fd893cb1e07929e6b, molecule-ubuntu2404, images/molecule-ubuntu2404) (push) Successful in 15s
Images / image (0.1, Dockerfile, ubuntu:26.04@sha256:d66b366dac61b575bee2aef07e9c26e8070096fbe84a3d4d3eb0da069b5d76db, molecule-ubuntu2604, images/molecule-ubuntu2604) (push) Successful in 1m7s
Images / image (0.2, images/ci/Dockerfile, ubuntu:26.04@sha256:d66b366dac61b575bee2aef07e9c26e8070096fbe84a3d4d3eb0da069b5d76db, ci, ) (push) Successful in 12s
Reviewed-on: #412
Reviewed-by: Defame1297 <[email protected]>
2026-11-27 11:29:50 +00:00
renovate-bot 2d4d44b871 chore(deps): update ubuntu:24.04 docker digest to 562111b
renovate/stability-days Updates have met minimum release age requirement
Build / build (pull_request) Successful in 22s
Molecule / molecule (pull_request) Successful in 56s
Lint / lint (pull_request) Successful in 2m3s
2026-11-27 11:27:28 +00:00
Dragonish d862097b9c Merge pull request 'fix: read facts through ansible_facts and run Molecule with fact injection off' (#405) from fix/364-ansible-facts into main
Reviewed-on: #405
2026-11-27 11:23:39 +00:00
Defame1297 6670ab664f Merge branch 'main' into fix/364-ansible-facts
Build / build (pull_request) Successful in 26s
Lint / lint (pull_request) Successful in 2m5s
Molecule / molecule (pull_request) Successful in 1h25m40s
2026-11-27 09:56:11 +00:00
Defame1297 1372c257c2 Merge pull request 'Fix/mole timeout' (#417) from fix/mole-timeout into main
Images / image (0.1, Dockerfile, ubuntu:24.04@sha256:9c7f200c07e3d4a03e7249d2c16bf66a51120fb876aa2242cf31451412543289, molecule-ubuntu2404, images/molecule-ubuntu2404) (push) Successful in 1m21s
Images / image (0.1, Dockerfile, ubuntu:26.04@sha256:d66b366dac61b575bee2aef07e9c26e8070096fbe84a3d4d3eb0da069b5d76db, molecule-ubuntu2604, images/molecule-ubuntu2604) (push) Successful in 17s
Images / image (0.2, images/ci/Dockerfile, ubuntu:26.04@sha256:d66b366dac61b575bee2aef07e9c26e8070096fbe84a3d4d3eb0da069b5d76db, ci, ) (push) Successful in 18s
Reviewed-on: #417
2026-11-27 09:54:22 +00:00
Dragonish 18475ea0a5 fix(ci): give the molecule job a 90 minute timeout
Lint / lint (pull_request) Failing after 5m36s
Build / build (pull_request) Successful in 26s
Molecule / molecule (pull_request) Successful in 49m28s
Removing timeout-minutes left the sweep step's 45 minute bound without
the job timeout it must equal, and the script test that holds the two
equal failed with a KeyError. Restore the key at 90 minutes, which also
leaves a full run under load (PR #405 took 44m53s) real margin, and move
the sweep bound to match so a live run's containers are never removed.

Assisted-by: Claude Code
2026-11-27 08:47:25 +00:00
Defame1297 e2df672be7 remove molecule.yml timeout
Lint / lint (pull_request) Failing after 6m27s
Molecule / molecule (pull_request) Canceled after 26m38s
Build / build (pull_request) Successful in 1m13s
2026-11-27 08:15:45 +00:00
Defame1297 2e92b11cbc remove image.yml timeout 2026-11-27 08:15:18 +00:00
Defame1297 7311a27e43 Merge pull request 'chore(deps): update ubuntu:24.04 docker digest to 562111b' (#411) from renovate/ubuntu-24.04 into main
Images / image (0.1, Dockerfile, ubuntu:24.04@sha256:9c7f200c07e3d4a03e7249d2c16bf66a51120fb876aa2242cf31451412543289, molecule-ubuntu2404, images/molecule-ubuntu2404) (push) Successful in 40s
Images / image (0.1, Dockerfile, ubuntu:26.04@sha256:d66b366dac61b575bee2aef07e9c26e8070096fbe84a3d4d3eb0da069b5d76db, molecule-ubuntu2604, images/molecule-ubuntu2604) (push) Successful in 14s
Images / image (0.2, images/ci/Dockerfile, ubuntu:26.04@sha256:d66b366dac61b575bee2aef07e9c26e8070096fbe84a3d4d3eb0da069b5d76db, ci, ) (push) Successful in 15s
Reviewed-on: #411
2026-11-27 08:08:29 +00:00
renovate-bot 19449f7e93 chore(deps): update ubuntu:24.04 docker digest to 562111b
renovate/stability-days Updates have met minimum release age requirement
Build / build (pull_request) Successful in 23s
Molecule / molecule (pull_request) Successful in 55s
Lint / lint (pull_request) Successful in 2m5s
2026-11-27 07:50:27 +00:00
Defame1297 84ad29b18b Merge pull request 'chore(deps): update dependency apm-cli to v0.38.1' (#413) from renovate/apm-cli-0.x into main
Images / image (0.1, Dockerfile, ubuntu:24.04@sha256:9c7f200c07e3d4a03e7249d2c16bf66a51120fb876aa2242cf31451412543289, molecule-ubuntu2404, images/molecule-ubuntu2404) (push) Successful in 1m19s
Images / image (0.1, Dockerfile, ubuntu:26.04@sha256:d66b366dac61b575bee2aef07e9c26e8070096fbe84a3d4d3eb0da069b5d76db, molecule-ubuntu2604, images/molecule-ubuntu2604) (push) Successful in 16s
Images / image (0.2, images/ci/Dockerfile, ubuntu:26.04@sha256:d66b366dac61b575bee2aef07e9c26e8070096fbe84a3d4d3eb0da069b5d76db, ci, ) (push) Successful in 4m28s
Reviewed-on: #413
2026-11-27 07:43:54 +00:00
Defame1297 6d505c0db7 Merge branch 'main' into renovate/apm-cli-0.x
Build / build (pull_request) Successful in 24s
Molecule / molecule (pull_request) Successful in 48s
Lint / lint (pull_request) Successful in 2m37s
2026-11-27 07:41:01 +00:00
Defame1297 3bf9ae0efe Merge pull request 'ci: cut the Lint and Build fast-path network by environment' (#408) from ci/168-offline-fast-path into main
Images / image (0.1, Dockerfile, ubuntu:24.04@sha256:9c7f200c07e3d4a03e7249d2c16bf66a51120fb876aa2242cf31451412543289, molecule-ubuntu2404, images/molecule-ubuntu2404) (push) Successful in 15s
Images / image (0.1, Dockerfile, ubuntu:26.04@sha256:d66b366dac61b575bee2aef07e9c26e8070096fbe84a3d4d3eb0da069b5d76db, molecule-ubuntu2604, images/molecule-ubuntu2604) (push) Successful in 38s
Images / image (0.2, images/ci/Dockerfile, ubuntu:26.04@sha256:d66b366dac61b575bee2aef07e9c26e8070096fbe84a3d4d3eb0da069b5d76db, ci, ) (push) Successful in 13s
Reviewed-on: #408
2026-11-27 07:38:18 +00:00
Defame1297 fbc8b1b6d7 Merge branch 'main' into ci/168-offline-fast-path
Molecule / molecule (pull_request) Successful in 4s
Lint / lint (pull_request) Successful in 1m31s
Build / build (pull_request) Successful in 28s
2026-11-27 07:36:40 +00:00
Defame1297 7c068c2b47 Merge pull request 'feat(system_baseline): let system_baseline_journal_max_use be empty to leave journald alone' (#415) from feat/401-journal-max-use-empty into main
Reviewed-on: #415
2026-11-27 07:36:10 +00:00
Dragonish c51fa998b9 feat(system_baseline): let system_baseline_journal_max_use be empty to leave journald alone
Lint / lint (pull_request) Successful in 2m33s
Molecule / molecule (pull_request) Successful in 7m29s
Build / build (pull_request) Successful in 28s
The role capped the persistent journal on every host with no way to opt
out, and wrote the value into the drop-in unchecked: an empty value
produced an empty SystemMaxUse=, and a bare number, a typo or a line
break went into the file as it was.

An empty system_baseline_journal_max_use now skips the journald task, as
an empty system_baseline_apt_daily_timeout skips its task: no drop-in
directory, no drop-in file and no restart of systemd-journald. A file an
earlier run wrote stays.

Any other value is checked before any change: infinity, or a number
followed by K, M, G or T. A bare number, a space and a line break stop
the run with a message that names the input. The default stays 200M.

Closes #401

Assisted-by: Claude Code:claude-sonnet-5-5
2026-11-27 06:00:04 +00:00
renovate-bot 2eb7da3563 chore(deps): update dependency apm-cli to v0.38.1
renovate/stability-days Updates have met minimum release age requirement
Build / build (pull_request) Successful in 24s
Molecule / molecule (pull_request) Successful in 1m2s
Lint / lint (pull_request) Successful in 2m5s
2026-11-27 03:18:31 +00:00
Dragonish 3a5040aae8 fix: read getent results through ansible_facts in two verify plays
Build / build (pull_request) Successful in 30s
Lint / lint (pull_request) Successful in 2m52s
Molecule / molecule (pull_request) Successful in 44m53s
The pihole and user_management scenarios read getent_passwd and
getent_shadow as top-level variables. The getent module returns them as
facts, which are injected as variables only while inject_facts_as_vars
is on, so with the setting this pull request turns on in the molecule
job the two verify plays failed (exit 2 in both runs of this pull
request, whose per-scenario logs were not printed).

They now read ansible_facts['getent_passwd'] and
ansible_facts['getent_shadow']. The remaining module-returned facts in
roles/ and extensions/ (package_facts, service_facts, the getent read in
user_management's ssh_keys.yml) are already read through ansible_facts.

Assisted-by: Claude Code:claude-sonnet-5-5
2026-11-26 23:58:23 +00:00
Defame1297 6a2060bd31 Merge pull request 'feat(system_baseline): add inputs that append packages to the profile's lists' (#409) from feat/399-extra-packages into main
Reviewed-on: #409
2026-11-26 23:08:05 +00:00
Dragonish 11fec7c8fc ci: rerun the molecule job to capture the scenario logs
Build / build (pull_request) Successful in 40s
Lint / lint (pull_request) Successful in 2m45s
Molecule / molecule (pull_request) Failing after 45m4s
The molecule job of the previous head ended at its timeout before it
printed the per-scenario logs, so the exit 2 of pihole and
user_management has no output. No file changes.

Assisted-by: Claude Code:claude-sonnet-5-5
2026-11-26 23:03:51 +00:00
Defame1297 40e3b39990 Merge branch 'main' into feat/399-extra-packages
Build / build (pull_request) Successful in 36s
Lint / lint (pull_request) Successful in 2m35s
Molecule / molecule (pull_request) Successful in 8m28s
2026-11-26 22:58:40 +00:00
Defame1297 e1a46fcdb1 Merge pull request 'chore(release): 3.1.0' (#407) from chore/release-3.1.0 into main
Build / build (push) Successful in 15s
Reviewed-on: #407
2026-11-26 22:57:41 +00:00
Dragonish 5519733312 feat(system_baseline): optionally skip the upgrade while a vzdump backup is running
Build / build (pull_request) Successful in 42s
Lint / lint (pull_request) Successful in 2m48s
Molecule / molecule (pull_request) Successful in 15m25s
An apt upgrade of a Proxmox node can restart Proxmox services while a
backup holds a snapshot of a guest, and the role had no way to say
"not now".

system_baseline_skip_upgrade_during_vzdump (bool, default false) makes
the main flow and the update entry point ask the node for its running
tasks (pvesh get /nodes/localhost/tasks --source active) before the
upgrade, on the pve system type only. A vzdump task without an end time
skips the upgrade with a message; autoremove, autoclean and the reboot
check still run. The role does not wait for the backup. A pvesh answer
that is not a JSON list stops the run. With the default no pvesh
command runs.

Closes #400

Assisted-by: Claude Code:claude-sonnet-5-5
2026-11-26 22:49:33 +00:00
Defame1297 4d5042a31f ci: cut the fast-path network by environment, not unshare
Build / build (pull_request) Successful in 34s
Molecule / molecule (pull_request) Successful in 16s
Lint / lint (pull_request) Successful in 1m38s
The runner's job container refuses unshare, even with a user namespace, so the
fast path sets PIP_NO_INDEX and a dead proxy instead; a raw socket is not caught.

Assisted-by: Claude Code
2026-11-26 22:48:51 +00:00
Dragonish d5a91520df feat(system_baseline): add inputs that append packages to the profile's lists
Lint / lint (pull_request) Successful in 5m37s
Molecule / molecule (pull_request) Successful in 7m20s
Build / build (pull_request) Successful in 1m15s
system_baseline_essential_packages and system_baseline_remove_packages
replace the whole list, and so does a list inside
system_baseline_profile_overrides, so adding one package meant repeating
the profile's list and keeping it in step with every release.

system_baseline_extra_packages and system_baseline_extra_remove_packages
(lists, default empty) append to the resolved lists. The tmux and
unattended-upgrades checks read the combined list, so an extra tmux or
unattended-upgrades enables the matching task like a profile package.
Items must be Debian package names: a null item would have become the
package "None", and apt reads a trailing minus (jq-) as a removal. A
package that one input installs and another purges stops the run before
any change; only overlaps that involve an extra are checked, so a
consumer's own overlap between the resolved lists behaves as before. A
flat input that is a plain string still counts as a one-item list.

With both inputs left at their default the role behaves as before.

Closes #399

Assisted-by: Claude Code:claude-sonnet-5-5
2026-11-26 22:25:36 +00:00
Defame1297 7c148e858d docs: say what the network-off fast path does not hold
Build / build (pull_request) Failing after 8s
Lint / lint (pull_request) Failing after 12s
Molecule / molecule (pull_request) Successful in 13s
A step without the $OFFLINE prefix runs online unchecked, and the script
tests keep network; both stay held by review.

Assisted-by: Claude Code
2026-11-26 22:20:17 +00:00
Defame1297 f7fde63f7d ci: run the Lint and Build fast path without network
When the pins match the ci image every tool is baked in, so a runtime
download is a bake-in defect; failing the job makes it visible.

Assisted-by: Claude Code
2026-11-26 22:17:42 +00:00
Defame1297 a659e83e6b chore(release): 3.1.0
Lint / lint (pull_request) Successful in 5m4s
Molecule / molecule (pull_request) Successful in 19s
Build / build (pull_request) Successful in 1m3s
Minor release: adds the tailscale role, and fixes six roles that failed
under --check on a host where they were not installed yet.

Assisted-by: Claude Code:claude-opus-5-5
2026-11-26 21:56:10 +00:00
Defame1297 464cc5848b Merge branch 'main' into fix/364-ansible-facts
Build / build (pull_request) Successful in 29s
Lint / lint (pull_request) Successful in 2m56s
Molecule / molecule (pull_request) Failing after 45m4s
2026-11-26 21:50:58 +00:00
Defame1297 1afce962a0 Merge pull request 'docs(adr): record self-built CI and molecule images, versioned by CI, pinned by version and digest' (#404) from docs/167-image-adr into main
Reviewed-on: #404
Reviewed-by: Defame1297 <[email protected]>
2026-11-26 21:45:53 +00:00
Defame1297 d1b4501c2b Merge branch 'main' into fix/364-ansible-facts
Lint / lint (pull_request) Successful in 2m10s
Molecule / molecule (pull_request) Canceled after 5m20s
Build / build (pull_request) Successful in 29s
2026-11-26 21:44:16 +00:00
Defame1297 e3d5c35fcd Merge branch 'main' into docs/167-image-adr
Molecule / molecule (pull_request) Successful in 6s
Lint / lint (pull_request) Successful in 3m26s
Build / build (pull_request) Successful in 1m3s
2026-11-26 21:41:16 +00:00
Defame1297 aa4e8c68a7 Merge pull request 'feat(tailscale): add the tailscale role' (#398) from feat/tailscale-role into main
Reviewed-on: #398
2026-11-26 21:41:00 +00:00
Dragonish 26b6e37a09 fix: read facts through ansible_facts and run Molecule with fact injection off
Build / build (pull_request) Successful in 34s
Lint / lint (pull_request) Successful in 2m32s
Molecule / molecule (pull_request) Canceled after 6m34s
ansible-core deprecates injecting facts as top-level variables (removal is
scheduled for 2.24, see #364). Three roles still read a bare fact: system_baseline (reboot check,
ansible_os_family), docker (APT source line, ansible_distribution_release)
and gitea_runner (re-registration backup name, ansible_date_time). With
inject_facts_as_vars set to false the system_baseline reboot check failed
with "'ansible_os_family' is undefined".

They now read ansible_facts[...]; the argument specs and READMEs that name
the facts follow. run_molecule_in_ci_image.sh exports
ANSIBLE_INJECT_FACT_VARS=False, so a role that reads an injected fact fails
its scenario, and a script test keeps the export in place.

Refs #364

Assisted-by: Claude Code:claude-sonnet-5-5
2026-11-26 21:33:03 +00:00
Defame1297 4f9b96b2f4 Merge branch 'main' into feat/tailscale-role
Build / build (pull_request) Successful in 30s
Lint / lint (pull_request) Successful in 2m25s
Molecule / molecule (pull_request) Successful in 4m58s
2026-11-26 21:32:08 +00:00
Defame1297 87280a2f60 docs(security): date the no-failure evidence of the post-merge entry
Build / build (pull_request) Successful in 28s
Molecule / molecule (pull_request) Successful in 9s
Lint / lint (pull_request) Successful in 1m56s
Assisted-by: Claude Code
2026-11-26 21:27:39 +00:00
Defame1297 2b1301d838 docs(adr): date each measurement and give the recorded Dockerfile reason
Assisted-by: Claude Code
2026-11-26 21:26:34 +00:00
Defame1297 288cea47a9 docs(adr): record self-built CI and molecule images, versioned by CI, pinned by version and digest
ADR 0002 records the decision with its measured saving and build cost.
The two risks it leaves (no Molecule run after a merge, and pin bumps
first behaviour-tested after they merge) go to the Accepted risks
register in SECURITY.md, as docs/adr/AGENTS.md requires.

Closes #167

Assisted-by: Claude Code
2026-11-26 21:24:28 +00:00
Defame1297 731bc022cd fix(tailscale): tolerate an unloaded tailscaled unit in reset-failed
Build / build (pull_request) Successful in 26s
Lint / lint (pull_request) Canceled after 2m8s
Molecule / molecule (pull_request) Canceled after 1m37s
After a removal without purge the role has disabled tailscaled, so the
reinstall's postinst does not start it. systemd then unloads the inactive,
unreferenced unit, and `systemctl reset-failed tailscaled` exits 1 with
"Unit tailscaled.service not loaded.", failing the configure step on both
noble and resolute. An unloaded unit has no failure state to clear, and the
restart that follows loads it, so that one error is not a failure.

Assisted-by: Claude Code:claude-opus-5-5
2026-11-26 21:24:10 +00:00
Defame1297 29165a610f fix(tailscale): harden removal, restarts and the auth key check
Build / build (pull_request) Successful in 29s
Lint / lint (pull_request) Successful in 2m25s
Molecule / molecule (pull_request) Failing after 3m23s
- Removal passes on a host without a tailscaled unit, and the
  best-effort logout reports a change only when it succeeded.
- Under --check the service tasks run only when the unit exists, also
  with --tags configure on a host without the package.
- The auth key is required before any change only when the run includes
  the configure tasks; --tags remove, install and update need none. The
  assert in the up block stays as the hard guard.
- When the flags change or tailscaled is not active, the role clears its
  failure state and restarts it at once, so a daemon the package started
  without a TUN device does not stay in the start limit.
- The health tag is back on the configure include.
- The scenario tests removal without purge (state and defaults kept, a
  second removal passes) and a purge with a state directory the package
  does not delete itself, and waits for tailscaled to be active.

Assisted-by: Claude Code:claude-opus-5-5
2026-11-26 20:47:49 +00:00
Defame1297 9c415ee347 Merge pull request 'ci(lint): enable and gate ansible-lint's complexity rule' (#397) from ci/138-complexity-gate into main
Reviewed-on: #397
2026-11-26 19:30:30 +00:00
Defame1297 3b20a1b6c6 ci(lint): enable and gate ansible-lint's complexity rule
Build / build (pull_request) Successful in 29s
Molecule / molecule (pull_request) Successful in 5s
Lint / lint (pull_request) Successful in 1m31s
Enable complexity at the default max_tasks and empty warn_list so
experimental findings fail Lint. Replace the repository-wide role-name
skip with an ignore line for the internal role _binary_update, so a
misnamed public role fails.

Closes #138

Assisted-by: Claude Code:claude-opus-5-5
2026-11-26 19:19:15 +00:00
Defame1297 80c76b16ee feat(tailscale): add the tailscale role
Installs Tailscale from the upstream APT repository with the keyring
pinned by sha256, enables tailscaled and, with tailscale_up (default
true), runs tailscale up with tailscale_auth_key while the node is not
Running. It can also update to the APT candidate version and remove or
purge.

The role asserts Ubuntu and follows the host's release, and requires a
non-empty auth key before any change whenever tailscale up will run.
tailscale_userspace_networking now sets --tun=userspace-networking in
the FLAGS of /etc/default/tailscaled, where tailscaled reads it, instead
of passing it to tailscale up.

The molecule scenario installs the real package on noble and resolute
without joining a tailnet, and covers the update and purge paths and
the refusal cases.

Closes #396

Assisted-by: Claude Code:claude-opus-5-5
2026-11-26 19:08:25 +00:00
Defame1297 31634c4eef Merge pull request 'test(roles): run molecule's check step before and after converge' (#395) from test/134-check-before-after-converge into main
Reviewed-on: #395
Reviewed-by: Defame1297 <[email protected]>
2026-11-26 15:22:51 +00:00
Defame1297 6b99ac9ca0 Merge branch 'main' into test/134-check-before-after-converge
Build / build (pull_request) Successful in 32s
Lint / lint (pull_request) Successful in 2m59s
Molecule / molecule (pull_request) Successful in 42m34s
2026-11-26 14:39:35 +00:00
Defame1297 9ce0fbd433 fix(roles): refresh apt in the docker and traefik scenarios and apply review round 2
Lint / lint (pull_request) Successful in 2m1s
Molecule / molecule (pull_request) Successful in 44m6s
Build / build (pull_request) Successful in 22s
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
Defame1297 3afff00b9b fix(roles): apply review findings to the check-mode change
Build / build (pull_request) Successful in 25s
Lint / lint (pull_request) Successful in 2m13s
Molecule / molecule (pull_request) Failing after 34m3s
Guard gitea_runner's docker group membership like its Docker start, run
user_management's getent probe unconditionally, and state the
play-level check_mode limit in every touched README. The check-mode
rule now allows the pihole guard form and names roles whose --check
needs their package installed.

Assisted-by: Claude Code
2026-11-26 11:11:19 +00:00
Defame1297 824456ea65 Merge pull request 'chore(deps): update git.rkdr.net/mortis/ci docker tag to v0.2.46' (#393) from renovate/git.rkdr.net-mortis-ci-0.x into main
Reviewed-on: #393
2026-11-26 10:46:04 +00:00
Defame1297 cf2286b7a7 test(roles): run molecule's check step before and after converge
Every role scenario with a converge now runs check right before it (a
fresh host) and right after it (a configured host), and a script test
fails a scenario without both. pihole and pve_lxc move their second
check from after idempotence to after converge to match.

The roles that failed under --check on a fresh host get the two allowed
guards: cloudflared, docker, gitea, gitea_runner, traefik and
user_management. ufw and fail2ban preview only a host where their
package is installed, as their READMEs now say.

Closes #134

Assisted-by: Claude Code
2026-11-26 10:11:54 +00:00
Defame1297 b8ad7fc0a6 Merge branch 'main' into renovate/git.rkdr.net-mortis-ci-0.x
Gitea release key / check (pull_request) Successful in 24s
Lint / lint (pull_request) Successful in 3m18s
Molecule / molecule (pull_request) Successful in 43m39s
Build / build (pull_request) Successful in 27s
2026-11-26 10:01:44 +00:00
renovate-bot ff13f2d3a4 chore(deps): update git.rkdr.net/mortis/ci docker tag to v0.2.46
renovate/stability-days Updates have met minimum release age requirement
Gitea release key / check (pull_request) Successful in 52s
Lint / lint (pull_request) Successful in 3m9s
Molecule / molecule (pull_request) Successful in 35m49s
Build / build (pull_request) Successful in 1m15s
2026-11-26 08:10:58 +00:00
151 changed files with 4069 additions and 656 deletions

No files matched your search

+5 -4
View File
@@ -24,7 +24,8 @@ exclude_paths:
supported_ansible_also:
- "2.22."
skip_list:
# role-name requires ^[a-z][a-z0-9_]*$, which rejects the leading underscore that marks an
# internal role (_binary_update), as in prometheus.prometheus (roles/_common).
- role-name
# complexity runs at the default max_tasks (100) until the schema accepts the key (#139). An empty
# warn_list makes experimental rules (complexity), jinja[spacing] and fqcn[deep] fail Lint.
enable_list:
- complexity
warn_list: []
+3
View File
@@ -9,3 +9,6 @@ roles/_binary_update/molecule/check_mode/verify.yml var-naming[no-role-prefix]
roles/_binary_update/molecule/default/verify.yml var-naming[no-role-prefix]
roles/_binary_update/molecule/default/tasks/assert_state.yml var-naming[no-role-prefix]
roles/_binary_update/molecule/resources/roles/binary_update_caller/tasks/main.yml var-naming[no-role-prefix]
# role-name requires ^[a-z][a-z0-9_]*$, which rejects the leading underscore that marks an
# internal role (_binary_update), as in prometheus.prometheus (roles/_common).
roles/_binary_update role-name
+13
View File
@@ -0,0 +1,13 @@
---
# Merged under every scenario's molecule.yml. prerun off: the CI wrapper puts this checkout
# first on ANSIBLE_COLLECTIONS_PATH, so molecule's per-scenario install is unused.
prerun: false
provisioner:
config_options:
connection:
# Pipe each module over stdin: without it every task pays extra docker exec and docker cp
# calls to make a temp dir, copy the module in and clean up.
pipelining: true
defaults:
# Gather each host's facts once per playbook run, not in every play.
gathering: smart
+21 -7
View File
@@ -57,6 +57,14 @@ issue.
`.pre-commit-config.yaml` takes the slow path, which installs the pinned tools and collections.
*Why:* a pull request is tested on its own pins, and an unchanged one starts in seconds.
*Held:* control: the "Check the baked tooling against the pins" step.
- **On the fast path the network is cut by environment**: `PIP_NO_INDEX=1`, the proxy variables
set to a dead local port and `no_proxy` empty, for every later step except "Test the repository
scripts", which unsets them for its fake registry on loopback; the slow path keeps network.
*Why:* a runtime download is a bake-in defect and must fail the job, not silently slow it.
*Held:* control, set by the "Check the baked tooling against the pins" step, for pip, curl, git
over HTTPS and Python's urllib or requests (anything honouring `PIP_NO_INDEX` or the proxy
variables); review for a raw socket or a tool that ignores the proxy variables, and for the
script tests.
- **Triggers:** both run on pull requests to `main` and on manual dispatch; Build also runs on
`v*` tags, where it checks the tag against `galaxy.yml`. *Why:* the tag is what consumers
install. *Held:* review.
@@ -72,14 +80,18 @@ issue.
- **What a pull request runs is chosen by `scripts/select_molecule_scenarios.py`:** the scenarios
of the roles it changes and of the roles that use them (any file naming
`mortis.kamino.<role>`, transitively), none for a diff of only IGNORED paths, a failure for a
changed role with no scenario, and every scenario for any other file. *Why:* a full run takes
changed role with no scenario, for a `.gitea/workflows/molecule.yml` diff of only comments
(outside `run:` scripts) or image pins the scenarios that name a changed `MOLECULE_IMAGE*` pin
(every scenario for `CI_IMAGE`, or when a shared molecule file names the pin), and every
scenario for any other file. *Why:* a full run takes
the single runner slot for a long time. *Held:* control: the selector and its tests.
- **A role named in an include, import, play `roles:` entry or meta dependency is written out in
full**, never bare or templated. *Why:* the selector finds dependent roles by their FQCN.
*Held:* control: a selector test fails a bare or templated name.
- **Scenarios load `mortis.kamino` from the checkout, never from molecule's installed copy, so
`galaxy.yml` is on IGNORED.** *Why:* molecule installs the collection from `galaxy.yml` into
each scenario's `ANSIBLE_HOME`, which is not on `ANSIBLE_COLLECTIONS_PATH`, so its changes
- **Scenarios load `mortis.kamino` from the checkout, never from an installed copy, so
`galaxy.yml` is on IGNORED.** *Why:* the checkout is first on `ANSIBLE_COLLECTIONS_PATH` and the
shared base config `.config/molecule/config.yml` turns off molecule's install of the collection
(`prerun: false`), so changes to `galaxy.yml`
(release versions, `build_ignore`) do not change what a scenario runs, and the Build check
proves the collection builds; they had caused about a third of full pull request runs and their
minutes (#338). *Held:* control: `scripts/check_scenarios_load_checkout.py`, which
@@ -110,14 +122,16 @@ issue.
*Why:* a pull request that raises the ansible-core floor must run its scenarios on the new core
before it automerges. *Held:* control: the pin comparison in `molecule.yml`.
- **Every scenario sets `scenario.test_sequence` to molecule's default minus both `destroy`
steps, names each platform `${KAMINO_RUN_ID:-local}-<name>` and labels it
steps, with a role scenario's `check` right before and right after `converge`, names each
platform `${KAMINO_RUN_ID:-local}-<name>` and labels it
`net.rkdr.mortis.molecule-run: "${KAMINO_RUN_ID:-local}"` in its `molecule.yml`;** copy it into
a new scenario. *Why:* the run script removes each scenario's containers by those names as soon
as it ends, which skips the driver's destroy wait, the workflow finds a run's containers by the
label, and the molecule state lives in each scenario's own `ANSIBLE_HOME` in the job tree, so a
killed run leaves none behind. *Held:* control: `tests/scripts/test_run_molecule_scenarios.py`
fails a `destroy` in a sequence, a platform name that is not unique or not per run, a missing
label, and a workflow that does not filter by it.
fails a `destroy` in a sequence, a role scenario's `converge` without a `check` on each side, a
platform name that is not unique or not per run, a missing label, and a workflow that does not
filter by it.
- **Scenarios live in `roles/*/molecule/*/` and `extensions/molecule/*/`.** A role scenario that
must pass on Ubuntu 24.04 and 26.04 takes `image: ${MOLECULE_IMAGE}` or
`${MOLECULE_IMAGE_2604}` per platform; the image-smoke scenarios are described in
+6 -1
View File
@@ -28,7 +28,7 @@ jobs:
timeout-minutes: 30
# The ci image (images/ci, built by image.yml): tag for the release, digest enforced.
container:
image: git.rkdr.net/mortis/ci:0.2.45@sha256:922febf5bdccbc773a4f7f52cf118498d029f27a7c56b33c9b6f43ac2b6c2d32
image: git.rkdr.net/mortis/ci:0.2.48@sha256:d1c6653255abf366462c0265d9372626d5b59095084fe74ae95b9ebe7414007d
env:
PIP_DISABLE_PIP_VERSION_CHECK: "1"
steps:
@@ -60,6 +60,11 @@ jobs:
run: |
if sha256sum --quiet -c /opt/ci-pins.sha256; then
echo "The pin files match the ci image; using the baked tools."
# A job container may not unshare, so the network is cut by environment: pip, curl,
# git over HTTPS and Python's urllib fail; a raw socket is not caught.
printf '%s\n' PIP_NO_INDEX=1 http_proxy=http://127.0.0.1:9 https_proxy=http://127.0.0.1:9 \
HTTP_PROXY=http://127.0.0.1:9 HTTPS_PROXY=http://127.0.0.1:9 no_proxy= NO_PROXY= >> "$GITHUB_ENV"
echo "::notice::Later steps run with a dead proxy; a download fails the job (bake it into images/ci)."
else
echo "::warning::requirements-dev.txt, requirements-dev.lock, requirements.yml," \
"extensions/molecule/requirements.yml or .pre-commit-config.yaml differ from the ci image;" \
+1 -1
View File
@@ -44,7 +44,7 @@ jobs:
# The ci image (images/ci, built by image.yml), at the pin of lint.yml: tag for the
# release, digest enforced. Only its /opt/venv Python (with PyYAML) is used here.
container:
image: git.rkdr.net/mortis/ci:0.2.45@sha256:922febf5bdccbc773a4f7f52cf118498d029f27a7c56b33c9b6f43ac2b6c2d32
image: git.rkdr.net/mortis/ci:0.2.48@sha256:d1c6653255abf366462c0265d9372626d5b59095084fe74ae95b9ebe7414007d
steps:
# The container has no Node, so JavaScript actions such as actions/checkout
# cannot run; clone with git and the job token.
+1 -2
View File
@@ -62,7 +62,6 @@ jobs:
github.event_name != 'pull_request' &&
github.ref == 'refs/heads/main'
runs-on: kamino-docker
timeout-minutes: 45
# max-parallel: 1 keeps the builds to one at a time. The runner takes two jobs, so a build
# may share it with one other job (Lint, Build or Molecule). An empty subpath means the
# repository root is the build context.
@@ -80,7 +79,7 @@ jobs:
base: "0.1"
subpath: images/molecule-ubuntu2404
dockerfile: Dockerfile
job_image: ubuntu:24.04@sha256:9c7f200c07e3d4a03e7249d2c16bf66a51120fb876aa2242cf31451412543289
job_image: ubuntu:24.04@sha256:562111b88caa79c71391c0c4d3c2114a7d5c35915c20561fd893cb1e07929e6b
- name: molecule-ubuntu2604
base: "0.1"
subpath: images/molecule-ubuntu2604
+8 -1
View File
@@ -31,7 +31,7 @@ jobs:
# The tag says which release, the digest is what is enforced (bump both together
# when image.yml publishes a new version).
container:
image: git.rkdr.net/mortis/ci:0.2.45@sha256:922febf5bdccbc773a4f7f52cf118498d029f27a7c56b33c9b6f43ac2b6c2d32
image: git.rkdr.net/mortis/ci:0.2.48@sha256:d1c6653255abf366462c0265d9372626d5b59095084fe74ae95b9ebe7414007d
env:
PIP_DISABLE_PIP_VERSION_CHECK: "1"
PRE_COMMIT_HOME: /opt/pre-commit
@@ -59,6 +59,11 @@ jobs:
run: |
if sha256sum --quiet -c /opt/ci-pins.sha256; then
echo "The pin files match the ci image; using the baked tools."
# A job container may not unshare, so the network is cut by environment: pip, curl,
# git over HTTPS and Python's urllib fail; a raw socket is not caught.
printf '%s\n' PIP_NO_INDEX=1 http_proxy=http://127.0.0.1:9 https_proxy=http://127.0.0.1:9 \
HTTP_PROXY=http://127.0.0.1:9 HTTPS_PROXY=http://127.0.0.1:9 no_proxy= NO_PROXY= >> "$GITHUB_ENV"
echo "::notice::Later steps run with a dead proxy; a download fails the job (bake it into images/ci)."
else
echo "::warning::requirements-dev.txt, requirements-dev.lock, requirements.yml," \
"extensions/molecule/requirements.yml or .pre-commit-config.yaml differ from the ci image;" \
@@ -108,8 +113,10 @@ jobs:
fi
python3 -E -s "$guard" "$HEAD_REF" "$BASE_REF"
# Without the guard: an empty no_proxy would send the fake registry on 127.0.0.1 to the dead proxy.
- name: Test the repository scripts
run: |
unset PIP_NO_INDEX http_proxy https_proxy HTTP_PROXY HTTPS_PROXY
export PATH="/opt/venv/bin:$PATH"
python3 -m unittest discover -s tests/scripts
+6 -7
View File
@@ -47,18 +47,17 @@ jobs:
(github.event_name != 'pull_request' ||
github.event.pull_request.head.repo.full_name == github.repository)
runs-on: [kamino-molecule]
# Two full runs sharing the runner (a nightly run and a dispatch) take more than 30 minutes.
# Also the age past which the sweep step removes a run's containers; a script test holds the
# two equal.
timeout-minutes: 45
# A full run under load takes about 45 minutes (PR #405: 44m53s), so 45 left no margin. Also the
# age past which the sweep step removes a run's containers; a script test holds the two equal.
timeout-minutes: 90
env:
# The tools and collections molecule runs with: the image Lint and Build use.
CI_IMAGE: >-
git.rkdr.net/mortis/ci:0.2.45@sha256:922febf5bdccbc773a4f7f52cf118498d029f27a7c56b33c9b6f43ac2b6c2d32
git.rkdr.net/mortis/ci:0.2.48@sha256:d1c6653255abf366462c0265d9372626d5b59095084fe74ae95b9ebe7414007d
# Used by the scenarios as `image: ${MOLECULE_IMAGE}`; set it the same way to run
# one locally.
MOLECULE_IMAGE: >-
git.rkdr.net/mortis/molecule-ubuntu2404:0.1.10@sha256:7cdb45688667ade43a8026bdc725489a557fde7ce893123c4ee6b8d125c3fec6
git.rkdr.net/mortis/molecule-ubuntu2404:0.1.11@sha256:e7389be9c397ec50fcf7d433c99cb9da7b16b149384aaa543e3c21a3ada1a4e1
# The same for Ubuntu 26.04, the release the hosts are moving to; used by
# `image: ${MOLECULE_IMAGE_2604}` in extensions/molecule/image-smoke-2604.
MOLECULE_IMAGE_2604: >-
@@ -98,7 +97,7 @@ jobs:
ids="$(docker ps -aq --filter 'label=net.rkdr.mortis.molecule-run')"
# The job's timeout-minutes (a script test holds them equal): a shorter bound would remove a
# live run's containers.
cutoff="$(date -d '45 minutes ago' +%s)"
cutoff="$(date -d '90 minutes ago' +%s)"
old=""
for id in $ids; do
# a container removed since the listing, by its run or another run's sweep, is skipped
+39
View File
@@ -4,6 +4,45 @@ mortis.kamino Release Notes
.. contents:: Topics
v3.2.0
======
Minor Changes
-------------
- cloudflared - New input ``cloudflared_tunnel_lookup_delay``, the seconds between the three retries of a 404 from the tunnel lookup while a new tunnel may not be visible yet. The default is 5, as before.
- docker, system_baseline - The install tasks that only use the distribution's sources (docker's prerequisites, system_baseline's packages) refresh the APT cache only when it is older than an hour; before, every run refreshed it. Installs from a role's own APT source still refresh it on every run.
- system_baseline - Add ``system_baseline_extra_packages`` and ``system_baseline_extra_remove_packages`` (lists, default empty), which append to the resolved package lists, where setting ``system_baseline_essential_packages`` or ``system_baseline_remove_packages`` replaces the profile's whole list. An extra ``tmux`` or ``unattended-upgrades`` enables the matching task like a profile package. A package that one input installs and another purges stops the run before any change. With both inputs left at their default the role behaves as before.
- system_baseline - Add the input ``system_baseline_skip_upgrade_during_vzdump`` (default ``false``). With ``true`` on the ``pve`` system type, the main flow and the ``update`` entry point skip the apt upgrade while ``pvesh get /nodes/localhost/tasks --source active`` lists a ``vzdump`` task, and say so. With the default no ``pvesh`` command runs and the upgrade is unchanged.
- system_baseline - ``system_baseline_journal_max_use`` can be empty to leave journald alone: the role then writes no drop-in and does not restart ``systemd-journald``. The default stays ``200M``.
- system_baseline - ``system_baseline_journal_max_use`` is checked before any change: it must be empty or a size journald reads, a number with an optional upper-case ``B``, ``K``, ``M``, ``G``, ``T``, ``P`` or ``E``. A value journald rejects, which the role used to write into the drop-in as it was and journald then ignored (``infinity``, a lower-case unit, a line break), now stops the run; an empty value used to write an empty ``SystemMaxUse=``.
- traefik - New input ``traefik_release_url`` sets where the release archive and checksums are downloaded from, for a mirror (default: the GitHub releases, as before).
Bugfixes
--------
- docker - Read the distribution release through ``ansible_facts['distribution_release']`` for the APT source line, so the role works with ``inject_facts_as_vars`` set to false and in the ansible-core release that stops injecting facts as variables. The source line is unchanged.
- gitea_runner - Read the timestamp of the forced re-registration backup through ``ansible_facts['date_time']``, so the role works with ``inject_facts_as_vars`` set to false and in the ansible-core release that stops injecting facts as variables. The backup name is unchanged.
- system_baseline - Read the OS family through ``ansible_facts['os_family']`` in the reboot check, so the role (and its ``reboot`` entry point) works with ``inject_facts_as_vars`` set to false and in the ansible-core release that stops injecting facts as variables. Before, the task failed with ``'ansible_os_family' is undefined`` there.
v3.1.0
======
Minor Changes
-------------
- tailscale - New role. Installs Tailscale from the upstream APT repository with the keyring pinned by sha256, sets ``--tun=userspace-networking`` in the ``tailscaled`` flags when ``tailscale_userspace_networking`` is true, enables ``tailscaled`` and, with ``tailscale_up`` (default ``true``), runs ``tailscale up`` with ``tailscale_auth_key`` while the node is not Running; it can also update to the APT candidate version and remove or purge. Declares Ubuntu noble and resolute; the molecule scenario installs the real package but does not join a tailnet.
Bugfixes
--------
- cloudflared - Do not fail under ``--check`` on a host where the cloudflared account or systemd unit does not exist yet.
- docker - Do not fail under ``--check`` on a host where the Docker repository and packages are not installed yet.
- gitea - Do not fail under ``--check`` on a host where Gitea is not installed yet.
- gitea_runner - Do not fail under ``--check`` on a host where the runner account, Docker or the systemd unit does not exist yet.
- traefik - Do not fail under ``--check`` on a host where Traefik is not installed yet.
- user_management - Do not fail under ``--check`` when a managed user does not exist yet.
v3.0.0
======
+4 -4
View File
@@ -2,10 +2,10 @@
An Ansible Collection of reusable, hardened roles for a self-hosted home lab:
`cloudflared`, `docker`, `fail2ban`, `gitea`, `gitea_runner`, `network_interfaces`,
`pihole`, `pve_lxc`, `sshd`, `system_baseline`, `systemd_hardening`, `traefik`, `ufw` and
`nfs_client`, `pihole`, `pve_lxc`, `sshd`, `system_baseline`, `systemd_hardening`, `tailscale`, `traefik`, `ufw` and
`user_management`, plus the internal `_binary_update`. Roles still to come are listed under [Roadmap](#roadmap).
Status: roles arrive in waves. Release 3.0.0 holds the `cloudflared`, `docker`, `fail2ban`, `gitea`, `gitea_runner`, `network_interfaces`, `pihole`, `pve_lxc`, `sshd`, `system_baseline`, `systemd_hardening`, `traefik`, `ufw` and `user_management` roles (and the internal `_binary_update`, which `cloudflared`, `gitea`, `gitea_runner` and `traefik` call).
Status: roles arrive in waves. Release 3.2.0 holds the `cloudflared`, `docker`, `fail2ban`, `gitea`, `gitea_runner`, `network_interfaces`, `pihole`, `pve_lxc`, `sshd`, `system_baseline`, `systemd_hardening`, `tailscale`, `traefik`, `ufw` and `user_management` roles (and the internal `_binary_update`, which `cloudflared`, `gitea`, `gitea_runner` and `traefik` call).
## Consuming
@@ -17,7 +17,7 @@ name (FQCN) only, `mortis.kamino.<role>`:
collections:
- name: https://git.rkdr.net/mortis/kamino.git
type: git
version: v3.0.0
version: v3.2.0
```
Its dependencies (`community.general`, `ansible.posix`, `community.proxmox`) are declared in `galaxy.yml`, so
@@ -41,7 +41,7 @@ when its own prerequisites (tests, a safe cutover wherever the role already runs
Still to come:
- Wave 2: `pve_vm`, `tailscale`.
- Wave 2: `pve_vm`.
- Wave 3: `rke2`, `proxmox_host`.
- Later, wave not yet assigned: `opnsense`, `proxmox_firewall`.
+25
View File
@@ -98,3 +98,28 @@ reduction. A later decision that accepts a risk adds an entry here.
already reaches every secret. There is no `renovate/*` push allowlist.
- **Trigger:** a token that can push here but cannot reach the secrets.
- **Planned reduction:** none for now.
### No Molecule run after a merge
- **Risk:** Molecule does not run on push to `main`
([ADR 0002](docs/adr/0002-self-built-ci-and-molecule-images.md)). Only the nightly full run
catches drift outside the tree (mirrors, images) or a scenario-selection mistake, and it is
the only run of the scenarios a pull request's diff did not select.
- **Why accepted:** "block on outdated branch" is on, so `main` only ever receives the tree its
pull request tested; no Molecule run on `main` failed after its pull request passed (3 to 17
November 2026).
- **Trigger:** a nightly run fails on a tree whose pull request passed.
- **Planned reduction:** none for now.
### Pin bumps first behaviour-tested after they merge
- **Risk:** Lint, Build and Molecule install a pull request's pins when they differ from the
image, so a pull request that changes an image input is tested on its own pins. But most pin
bumps select no Molecule scenario: every Python pin except an ansible-core minor bump, which
edits `meta/runtime.yml`. Such a bump is first behaviour-tested after it has merged, by the
pull request that moves the workflows to the new `ci` image.
- **Why accepted:** that pull request runs every scenario before the new image is used,
and running every scenario on every Python pin bump would cost about 10 minutes each.
- **Trigger:** the pull request that moves the workflows to a new `ci` image fails Molecule
because of a bumped pin.
- **Planned reduction:** none for now.
+5 -1
View File
@@ -51,6 +51,10 @@ objects:
description: Harden systemd for a system type
name: systemd_hardening
version_added: null
tailscale:
description: Install Tailscale and bring the node up
name: tailscale
version_added: null
traefik:
description: Install, configure, update or remove Traefik as a systemd binary
name: traefik
@@ -81,4 +85,4 @@ plugins:
strategy: {}
test: {}
vars: {}
version: 3.0.0
version: 3.2.0
+86
View File
@@ -446,3 +446,89 @@ releases:
- 133-drop-jammy-and-ubuntu-all.yml
- 133-ubuntu-2604.yml
release_date: '2026-11-26'
3.1.0:
changes:
bugfixes:
- cloudflared - Do not fail under ``--check`` on a host where the cloudflared
account or systemd unit does not exist yet.
- docker - Do not fail under ``--check`` on a host where the Docker repository
and packages are not installed yet.
- gitea - Do not fail under ``--check`` on a host where Gitea is not installed
yet.
- gitea_runner - Do not fail under ``--check`` on a host where the runner account,
Docker or the systemd unit does not exist yet.
- traefik - Do not fail under ``--check`` on a host where Traefik is not installed
yet.
- user_management - Do not fail under ``--check`` when a managed user does not
exist yet.
minor_changes:
- tailscale - New role. Installs Tailscale from the upstream APT repository
with the keyring pinned by sha256, sets ``--tun=userspace-networking`` in
the ``tailscaled`` flags when ``tailscale_userspace_networking`` is true,
enables ``tailscaled`` and, with ``tailscale_up`` (default ``true``), runs
``tailscale up`` with ``tailscale_auth_key`` while the node is not Running;
it can also update to the APT candidate version and remove or purge. Declares
Ubuntu noble and resolute; the molecule scenario installs the real package
but does not join a tailnet.
fragments:
- 134-check-mode.yml
- tailscale-role.yml
release_date: '2026-11-26'
3.2.0:
changes:
bugfixes:
- docker - Read the distribution release through ``ansible_facts['distribution_release']``
for the APT source line, so the role works with ``inject_facts_as_vars`` set
to false and in the ansible-core release that stops injecting facts as variables.
The source line is unchanged.
- gitea_runner - Read the timestamp of the forced re-registration backup through
``ansible_facts['date_time']``, so the role works with ``inject_facts_as_vars``
set to false and in the ansible-core release that stops injecting facts as
variables. The backup name is unchanged.
- system_baseline - Read the OS family through ``ansible_facts['os_family']``
in the reboot check, so the role (and its ``reboot`` entry point) works with
``inject_facts_as_vars`` set to false and in the ansible-core release that
stops injecting facts as variables. Before, the task failed with ``'ansible_os_family'
is undefined`` there.
minor_changes:
- cloudflared - New input ``cloudflared_tunnel_lookup_delay``, the seconds between
the three retries of a 404 from the tunnel lookup while a new tunnel may not
be visible yet. The default is 5, as before.
- docker, system_baseline - The install tasks that only use the distribution's
sources (docker's prerequisites, system_baseline's packages) refresh the APT
cache only when it is older than an hour; before, every run refreshed it.
Installs from a role's own APT source still refresh it on every run.
- system_baseline - Add ``system_baseline_extra_packages`` and ``system_baseline_extra_remove_packages``
(lists, default empty), which append to the resolved package lists, where
setting ``system_baseline_essential_packages`` or ``system_baseline_remove_packages``
replaces the profile's whole list. An extra ``tmux`` or ``unattended-upgrades``
enables the matching task like a profile package. A package that one input
installs and another purges stops the run before any change. With both inputs
left at their default the role behaves as before.
- system_baseline - Add the input ``system_baseline_skip_upgrade_during_vzdump``
(default ``false``). With ``true`` on the ``pve`` system type, the main flow
and the ``update`` entry point skip the apt upgrade while ``pvesh get /nodes/localhost/tasks
--source active`` lists a ``vzdump`` task, and say so. With the default no
``pvesh`` command runs and the upgrade is unchanged.
- 'system_baseline - ``system_baseline_journal_max_use`` can be empty to leave
journald alone: the role then writes no drop-in and does not restart ``systemd-journald``.
The default stays ``200M``.'
- 'system_baseline - ``system_baseline_journal_max_use`` is checked before any
change: it must be empty or a size journald reads, a number with an optional
upper-case ``B``, ``K``, ``M``, ``G``, ``T``, ``P`` or ``E``. A value journald
rejects, which the role used to write into the drop-in as it was and journald
then ignored (``infinity``, a lower-case unit, a line break), now stops the
run; an empty value used to write an empty ``SystemMaxUse=``.'
- 'traefik - New input ``traefik_release_url`` sets where the release archive
and checksums are downloaded from, for a mirror (default: the GitHub releases,
as before).'
fragments:
- 364-ansible-facts.yml
- 399-extra-packages.yml
- 400-skip-upgrade-during-vzdump.yml
- 401-journal-max-use-empty.yml
- apt-cache-valid-time.yml
- cloudflared-tunnel-lookup-delay.yml
- refusals-in-verify.yml
- traefik-release-url.yml
release_date: '2026-11-27'
+8
View File
@@ -0,0 +1,8 @@
---
minor_changes:
- >-
nfs_client - New role. Installs ``nfs-common`` and manages NFS mount entries in ``/etc/fstab`` from ``nfs_client_mounts``
(``src``, ``path``, optional ``opts`` and ``state`` ``present`` or ``absent``), with ``nfs_client_default_opts``
(default ``_netdev,nofail``) for an entry that sets none. It creates each mount point without owner, group or mode,
writes only the fstab line, never mounts or unmounts, and reloads systemd after a change. An ``absent`` entry loses its
line and nothing else. Declares Ubuntu noble and resolute; the molecule scenario never mounts a share.
@@ -0,0 +1,50 @@
# 0002. Self-built CI and molecule images, versioned by CI, pinned by version and digest
Status: accepted
## Context
Every CI job runs on one shared runner. Installing the toolchain in each job is simple but slow.
Building our own images is faster but adds machinery: Dockerfiles, an image build, version tags
and pin updates. The choice is hard to undo once every workflow pins an image.
## Decision
- **We build our own images:** a `ci` image, and one Dockerfile per molecule image (one per Ubuntu
release, and later the Debian 13 one).
Molecule's controller image is added by [ADR 0003](0003-molecule-controller-image.md).
- **The molecule images bake in everything except what a role installs itself.** The test
fixtures a scenario's `prepare.yml` needs are baked in. Packages a role installs are still
downloaded, because that install path is what the test exercises. A converge is not kept off
the network.
- **Consumers pin `<version>@sha256:<digest>`.**
- **CI assigns the patch version from the image's inputs.** A published tag is never moved.
- **The pin follows each build through Renovate.**
- **Molecule runs are isolated per run:** per-run container names and labels, and no shared
concurrency group. Molecule does not run on push to `main`. Raising the runner's capacity is a
separate change.
## Reason
We chose speed over simplicity, and the measured saving shows the trade:
- With everything installed per run, Lint took about 82s and Build about 50s (24–25 October
2026). With the image, Lint takes about 33s and Build about 13s (3 to 17 November 2026).
- The cost: a `ci` image build takes about 4 minutes on the shared runner, and each new version
also costs a pin pull request's CI. `ci` went from 0.1.0 to 0.2.23 in three weeks, with 9
versions on 14–15 November.
Versions are assigned by CI, because a version a person has to remember to raise is one
somebody forgets. Pinning by digest means a consumer runs exactly the image a reviewer saw.
Molecule runs are isolated per run rather than queued in one concurrency group, because a
shared group cancels a waiting run and stalls the required check of that run's pull request.
The risks this leaves are in the [Accepted risks](../../SECURITY.md#accepted-risks) register:
no Molecule run after a merge, and pin bumps that are first behaviour-tested after they merge.
## Not done
- **One molecule Dockerfile with a release build argument:** it would need a matrix argument, a
Renovate regex manager for two digests and a pins check that reads build arguments, and the
Debian 13 image differs by more than a release tag anyway. Review keeps the files in step.
@@ -0,0 +1,60 @@
# 0003. Molecule runs in its own controller image, not the `ci` image
Status: accepted
## Context
[ADR 0002](0002-self-built-ci-and-molecule-images.md) built one `ci` image that bakes every CI
tool, and Lint, Build and Molecule all pin it. A change to a tool only Lint uses (apm-cli,
antsibull-changelog, a pre-commit hook environment) publishes a new `ci` version, and its pin
pull request moves `CI_IMAGE` in `molecule.yml`. The scenario selector cannot tell what changed
inside an image, so it runs every scenario. 9 of 18 `ci` pin pull requests over two weeks
were Lint-only. Images are built only on push to `main`, so a bump and its pin never share a pull
request.
## Decision
- **Molecule runs in a `molecule-controller` image**, separate from `ci`. It bakes only what
Molecule needs: ansible-core, molecule, molecule-plugins, the Python packages of the Docker
connection, and the collections of `requirements.yml` and
`extensions/molecule/requirements.yml`.
- **Its Python packages come from a requirements file and hash-pinned lock of its own.**
- **`molecule.yml` pins it instead of `ci`**; Lint and Build keep `ci`.
- **It follows ADR 0002 otherwise:** built by `image.yml`, versioned by CI, pinned by
`<version>@sha256:<digest>`, moved by Renovate. This adds to ADR 0002's set of images; the
rest of ADR 0002 stands.
## Reason
A `ci` pin pull request then touches only paths the selector ignores and runs no scenario. A
`molecule-controller` pin pull request still runs every scenario, which is right: it changes
Molecule's tools.
The cost: one more image and lock to maintain, its layers to estimate against the 100 MB limit,
a hand-made first pin, and ansible-core pinned in two locks that must stay equal. A collection
bump is an input of both images, so it publishes two versions and two pin pull requests.
The controller's requirements file and lock must not be on the selector's IGNORED list, so a
bump of ansible-core or molecule there runs every scenario before it merges. Today
`requirements-dev.txt` and `requirements-dev.lock` are on IGNORED, so such a bump selects no
scenario unless it edits `meta/runtime.yml`; this decision does not change that list.
The implementation updates: `image.yml` (matrix, and its push `paths` unless the new files live
under `images/`), `molecule.yml`,
`scripts/run_molecule_in_ci_image.sh` (its pin comparison reads the `ci` image's checksums),
`scripts/check_image_versions.py`, `scripts/check_bot_pr_diff.py` and
`scripts/lock-requirements.sh` (they know only `requirements-dev.lock`), their tests, the
`pip-compile` patterns in `renovate.json`, `images/AGENTS.md` (the consumer list, and "each
molecule image is one Ubuntu release"), the Molecule rules in `.gitea/workflows/AGENTS.md`,
`docs/images/` (a new page, and `ci.md`, which names Molecule as a consumer), the `ci`
Dockerfile's description label, `docs/contributing/setup.md` if the clone's tools change, and the
[Accepted risks](../../SECURITY.md#accepted-risks) entry "Pin bumps first behaviour-tested after
they merge", which counts on the `ci` pin pull request running every scenario.
## Not done
- **The selector classifies the packages a lock change moves, to decide whether a `CI_IMAGE`
bump matters:** a heuristic package list inside a script that judges pull requests.
- **Status quo:** every Lint-only tool change keeps costing a full Molecule run.
- **Grouping pin pull requests only:** adopted separately; it lowers the number of full runs
but not the cause.
+14 -1
View File
@@ -15,10 +15,23 @@ trailers, are in [ai-assistance.md](ai-assistance.md).
*Reason:* every change reaches `main` through the Lint and Build checks and a reviewer.
*Held by:* control: branch protection on `main`.
- **Do not push to someone else's branch or to a bot's branch; put your change in a pull request of
your own.** Updating a branch from `main` with Gitea's update button is allowed.
your own.** Updating a branch from `main` with Gitea's update button is allowed under the next
two rules.
*Reason:* a push changes a head its author already reviewed or scheduled to merge, and a hand-made
commit on a `renovate/` branch makes Renovate stop rebasing it.
*Held by:* aspirational.
- **Update a pull request's branch from `main` only when it is next to merge: reviewed, green on its
previous head, and the only branch being updated. After updating your own pull request, give it a
scheduled merge; merge anyone else's as [reviewing.md](reviewing.md) says.**
*Reason:* `main` blocks an outdated branch, so every update re-runs Lint, Build and Molecule, and
a new head cancels the run in progress; an update made while another pull request merges first is
wasted.
*Held by:* aspirational.
- **Never press the update button on a `renovate/` branch. When a Renovate pull request is next to
merge and behind `main`, tick the rebase/retry checkbox in its description; Renovate rebases it at
its next run.**
*Reason:* the update button adds a hand-made commit, and Renovate stops rebasing that branch.
*Held by:* aspirational.
- **File an issue or open a pull request with the headings of the matching template in `.gitea/`,
also when you file through the API, `tea` or an MCP server.**
*Reason:* those routes skip the templates, and an agent's built-in body leaves out what review needs.
+2 -1
View File
@@ -66,7 +66,8 @@ Read `.gitea/workflows/molecule.yml` for the full command.
`/opt/ci-pins.sha256` lists the five pin files by their checkout-relative path, so `sha256sum -c` runs in the checkout root. When
the checkout's `requirements-dev.txt`, `requirements-dev.lock`, `requirements.yml`, `extensions/molecule/requirements.yml` and `.pre-commit-config.yaml` match, the baked tools and
collections are used as they are. When a pull request changes a pin the check fails and the job installs the pinned
collections are used as they are, and Lint and Build cut the network by environment (proxy variables and
`PIP_NO_INDEX`) for all but the script tests, so a tool that downloads at run time fails the job. When a pull request changes a pin the check fails and the job installs the pinned
tools and collections itself for that run
(slower, same result), until the image is rebuilt from `main`. `lint.yml`, `build.yml`, `molecule.yml` and `gitea-release-key.yml`
are the real consumers.
+1 -1
View File
@@ -7,4 +7,4 @@
# Renovate (renovate.json, ansible-galaxy manager) bumps this pin.
collections:
- name: community.docker
version: 5.4.0
version: 5.4.1
+5 -4
View File
@@ -1,14 +1,14 @@
---
namespace: mortis
name: kamino
version: 3.0.0
version: 3.2.0
readme: README.md
authors:
- Defame1297
description: >-
Reusable, hardened Ansible roles for a self-hosted home lab (cloudflared, docker, fail2ban,
gitea, gitea_runner, network_interfaces, pihole, pve_lxc, sshd, system_baseline,
systemd_hardening, traefik, ufw, user_management; _binary_update is internal).
gitea, gitea_runner, network_interfaces, nfs_client, pihole, pve_lxc, sshd, system_baseline,
systemd_hardening, tailscale, traefik, ufw, user_management; _binary_update is internal).
license:
- GPL-3.0-or-later
tags:
@@ -22,7 +22,7 @@ homepage: https://git.rkdr.net/mortis/kamino
issues: https://git.rkdr.net/mortis/kamino/issues
# CI tests the versions pinned in requirements.yml; the lower bounds here are not tested.
# No upper bound, so a consumer's newer pin does not conflict. community.general is used by system_baseline and ufw,
# ansible.posix by system_baseline and user_management, community.proxmox by pve_lxc (Proxmox VE guest lifecycle).
# ansible.posix by nfs_client, system_baseline and user_management, community.proxmox by pve_lxc (Proxmox VE guest lifecycle).
# community.proxmox's modules import the Python library proxmoxer (2.3 or later) on the controller; galaxy.yml
# cannot declare a Python dependency, so the README says it and requirements-dev.txt pins it for CI.
dependencies:
@@ -39,6 +39,7 @@ build_ignore:
- apm_modules
- .apm-local
- .claude
- .config
- .gitea
- .gitignore
- .pre-commit-config.yaml
+4 -2
View File
@@ -61,8 +61,10 @@ it to this repository's organisation in the Gitea registry as `<version>` and `l
- **Bake in:** every tool, collection, hook environment and package a CI job uses is in its
image; a job downloads at run time only on the slow path (a pull request that changes a pin
file). *Why:* a run that downloads is slower and depends on the network. *Held:* review until
the network-off check (#168) lands.
file). *Why:* a run that downloads is slower and depends on the network. *Held:* control: on
the fast path Lint and Build cut the network by environment, so a download through pip or a
proxy-honouring client fails the job; review for a raw socket, for the script tests, which keep
network, and for Molecule.
- **Recorded speed:** a speed optimisation that adds machinery states its measured saving where
it lives (a comment next to it). *Why:* machinery is kept only for a saving someone can check.
*Held:* review.
+1 -1
View File
@@ -25,7 +25,7 @@
# fails without host keys, so they cannot be removed; image scanners will flag them.
# They are throwaway keys of a test target that is never exposed.
# ubuntu:24.04 index digest as of 2026-10-24 (24.04.5).
FROM ubuntu:24.04@sha256:9c7f200c07e3d4a03e7249d2c16bf66a51120fb876aa2242cf31451412543289
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." \
+48 -9
View File
@@ -1,6 +1,6 @@
{
"$schema": "https://docs.renovatebot.com/renovate-schema.json",
"description": "Run by .gitea/workflows/renovate.yml on this repository's own runner. Policy: automerge minor and patch, majors by hand. Every bot pull request must pass scripts/check_bot_pr_diff.py (lint workflow), which allows only version, tag, digest and pin lines. Image versions are assigned by the Images workflow when an image's inputs change, so a bot pull request needs no version edit.",
"description": "Run by .gitea/workflows/renovate.yml on this repository's own runner. Policy: automerge minor and patch, majors by hand. Every bot pull request must pass scripts/check_bot_pr_diff.py (lint workflow), which allows only version, tag, digest and pin lines. Image versions are assigned by the Images workflow when an image's inputs change, so a bot pull request needs no version edit. Updates open on Mondays (UTC), so any Monday run can act; the own image pins and vulnerability fixes found on osv.dev open at any time. The weekly window and the groups bound the volume, so there is no hourly pull request limit. Vulnerability fixes skip the release-age wait, so they are never automerged: a person checks a fix that had no time to be pulled as a compromised release. Base-image bumps are manual: every Dockerfile is FROM ubuntu, grouped with the job containers.",
"extends": [
"config:recommended",
":enablePreCommit"
@@ -19,7 +19,7 @@
],
"automerge": true,
"automergeType": "pr",
"prHourlyLimit": 5,
"prHourlyLimit": 0,
"minimumReleaseAge": "3 days",
"minimumReleaseAgeBehaviour": "timestamp-optional",
"timezone": "UTC",
@@ -90,7 +90,7 @@
],
"packageRules": [
{
"description": "Dockerfile base-image tag and digest bumps (images/*/Dockerfile) MAY automerge. Kamino is the untrusted side and the bump pull request's own CI exercises the new image before the merge. Placed first so the major-version rule below still turns automerge off. The merge publishes a new image version.",
"description": "Dockerfile base-image tag and digest bumps (images/*/Dockerfile) MAY automerge. Kamino is the untrusted side and the bump pull request's own CI exercises the new image before the merge. Placed first so the major-version rule below still turns automerge off. The merge publishes a new image version. Today every Dockerfile is FROM ubuntu, whose bumps join the manual ubuntu base images group below; this rule is the safety net for a future base image of another kind.",
"matchManagers": [
"dockerfile"
],
@@ -145,12 +145,18 @@
"allowedVersions": "<=26.10.1"
},
{
"description": "The job containers of image.yml (matrix job_image, ubuntu by digest) hold the org registry push credential while the image job runs: never automerged, and kept in their own branch so the Dockerfile base-image bumps are not held back with them.",
"description": "The job containers of image.yml (matrix job_image, ubuntu by digest) hold the org registry push credential while the image job runs: never automerged. Their ubuntu bumps share one branch with the Dockerfile FROM bumps (ubuntu base images rule below), so that pull request is manual too: a group automerges only if every update in it does.",
"matchFileNames": [
".gitea/workflows/image.yml"
],
"automerge": false,
"additionalBranchPrefix": "job-container-"
"automerge": false
},
{
"description": "The Dockerfile FROM digests and the image.yml job_image digests of one Ubuntu update move in one pull request, so the release pair stays in step and one Images run covers both.",
"matchPackageNames": [
"ubuntu"
],
"groupName": "ubuntu base images"
},
{
"description": "Safety net only: kaniko is pinned by layer digests in image.yml and no Renovate manager reads them, so it is updated by hand. If a manager ever starts to read it, its bumps are not automerged.",
@@ -160,11 +166,15 @@
"automerge": false
},
{
"description": "Pin follow-up for our own images (git.rkdr.net/mortis/*): moves the image:<version>@sha256:<digest> pins of lint.yml, build.yml, molecule.yml and gitea-release-key.yml to the newest published version and its digest, and automerges. The Images workflow's completion starts a Renovate run, so this pull request opens minutes after a new version is pushed. The pull request's own Lint and Build run in the new image before the merge, and scripts/check_bot_pr_diff.py allows only these pin lines. The registry lists tags and digests anonymously, so no hostRules are needed. A major version stays manual (rule above).",
"description": "Pin follow-up for our own images (git.rkdr.net/mortis/*): moves the image:<version>@sha256:<digest> pins of lint.yml, build.yml, molecule.yml and gitea-release-key.yml to the newest published version and its digest, and automerges. The Images workflow's completion starts a Renovate run, so this pull request opens minutes after a new version is pushed. The pull request's own Lint and Build run in the new image before the merge, and scripts/check_bot_pr_diff.py allows only these pin lines. The registry lists tags and digests anonymously, so no hostRules are needed. A major version stays manual (rule above). One pull request moves every image an Images run published (ci and both molecule images), so one Molecule run tests them together. Exempt from the weekly schedule, so the pins on main catch up with a new image within minutes.",
"matchPackageNames": [
"git.rkdr.net/mortis/**"
],
"automerge": true
"automerge": true,
"groupName": "own CI images",
"schedule": [
"at any time"
]
},
{
"description": "Look the pre-commit hook repositories up with git ls-remote (git-tags) instead of the GitHub API. This run has no GitHub token, and the github-tags datasource then either skips every hook (skipReason github-token-required, dry run 3880) or is refused at once with 403 rate limit (githubTokenWarn off, local run). git-tags needs no API and no credential, and it uses the dereferenced hash of an annotated tag, so the new rev is the commit, as pre-commit needs. The `# frozen:` form is kept by the manager's own replace template. It works only together with RENOVATE_GITHUB_TOKEN_WARN=false in renovate.yml: the token check runs after extraction and skips every github-tags dependency before a package rule can change its datasource (local run, Renovate 44.161.0). git-tags has no release timestamps, so minimumReleaseAge cannot delay a hook bump: hook bumps are never automerged, a person reviews each one.",
@@ -177,16 +187,45 @@
"overrideDatasource": "git-tags",
"overridePackageName": "https://github.com/{{{depName}}}",
"automerge": false
},
{
"description": "Lint and build tooling in one weekly pull request across requirements-dev.lock and the ci image's uv pin, so one ci image build instead of one per tool.",
"matchDatasources": [
"pypi"
],
"matchPackageNames": [
"apm-cli",
"antsibull-changelog",
"galaxy-importer",
"reuse",
"pre-commit",
"uv"
],
"groupName": "lint tooling"
},
{
"description": "The pre-commit hooks in one weekly pull request; never automerged (rule above).",
"matchManagers": [
"pre-commit"
],
"groupName": "pre-commit hooks"
}
],
"lockFileMaintenance": {
"enabled": true,
"schedule": [
"before 6am on monday"
"on monday"
],
"automerge": false,
"labels": [
"lock-file-maintenance"
]
},
"schedule": [
"on monday"
],
"osvVulnerabilityAlerts": true,
"vulnerabilityAlerts": {
"automerge": false
}
}
+3 -3
View File
@@ -240,9 +240,9 @@ anyio==4.16.0 \
# via
# httpx2
# openai
apm-cli==0.38.0 \
--hash=sha256:6dfac2fdc8ab68586afb2b1a5a6db3c1b7ab569ff0edc525448aa85d0f92bd38 \
--hash=sha256:aa51a98867ae6aef11e92143dd9ca2a994d3dd6cbd7224eae58fb7b8078fc3b1
apm-cli==0.38.1 \
--hash=sha256:c2a0394643e54d3516efefcd78bb043509ac48b65cca1f40166023789b8eb89a \
--hash=sha256:c2ddd1ea95f7223de2ced83c1bbb61b756a10de2651edc76b93346c925dc162b
# via -r requirements-dev.txt
attrs==23.2.0 \
--hash=sha256:935dc3b529c262f6cf76e50877d35a4bd3c1de194fd41f47a2b7ae8f19971f30 \
+1 -1
View File
@@ -19,4 +19,4 @@ molecule-plugins[docker]==26.11.0
proxmoxer==2.3.0
# apm-cli: for changing apm.yml (run apm install, commit the lock). Keep it at 0.36.1 or later (#252):
# before 0.29.0, `apm audit --ci` compares the whole .claude/settings.json and fails on any hand-written key.
apm-cli==0.38.0
apm-cli==0.38.1
+13 -8
View File
@@ -18,7 +18,7 @@ names a check that does not exist yet and its backlog issue.
*Why:* a consumer finds the same thing in the same place. *Held:* review.
- **Complexity.** A task file stays within ansible-lint's `complexity` limit, `max_tasks` 100
(40 once ansible-lint accepts the key). *Why:* a long task file is hard to review. *Held:*
review until the Lint job enables `complexity` and fails on it (#138).
control, ansible-lint `complexity` in the Lint job.
- **Roadmap.** The pull request that adds a role removes it from the README "Roadmap" list, and
the section goes when the list is empty. *Why:* the list is useful only if true. *Held:* review.
@@ -95,12 +95,16 @@ names a check that does not exist yet and its backlog issue.
- **Negative tests.** Every validation has one in `verify.yml` (or a file it includes):
block/rescue/assert matching the expected error message, run last or failing before any
change. *Why:* a bare "it failed" passes for the wrong error. *Held:* review.
- **Check mode.** Every scenario runs `check` before and after converge. The only guards are
`check_mode: false` on read-only probes and `when: not ansible_check_mode`; `--check` is the
supported preview, and the README says a play-level `check_mode: true` is not supported. A role
that cannot support check mode says why in README Notes and drops the step. *Why:* check-mode
breakage is a frequent fix, and one guard pattern is reviewable. *Held:* review until every
scenario's `test_sequence` runs `check` (#134).
- **Check mode.** Every scenario runs `check` before and after converge. Guards:
`check_mode: false` on read-only probes, and `when: not ansible_check_mode`, alone or as
`not ansible_check_mode or <condition>` where the condition shows the task can run (such as a
registered result that is not changed). README: `--check` is the supported preview and a
play-level `check_mode: true` is not supported; a role whose `--check` needs its package
installed says so in Notes and keeps the step; a role that cannot support check mode at all
says why in Notes and drops the step, which also needs an exception in the test named below.
*Why:* check-mode breakage is a frequent fix, and one guard pattern is reviewable. *Held:*
Molecule for the run passing, `tests/scripts/test_run_molecule_scenarios.py` for the steps
being there; review for the guards.
## Roles calling roles
@@ -121,4 +125,5 @@ names a check that does not exist yet and its backlog issue.
review that each new internal role has it.
- **`role-name` for internal roles.** An internal role is exempted from ansible-lint `role-name`
by its own line in `.ansible-lint-ignore`. *Why:* a misnamed public role must still fail.
*Held:* review; until #138 replaces it, `.ansible-lint` skips `role-name` repository-wide.
*Held:* control, ansible-lint `role-name` in the Lint job; review that each new internal role
has its line.
+2 -1
View File
@@ -71,7 +71,8 @@ Two molecule scenarios run in CI only, on two platforms: `${MOLECULE_IMAGE}` (Ub
stub unit, with no network: `default` covers a successful bump, its idempotence, a binary that
cannot start, a binary that reports another version (both rolled back), a run with nothing
staged (the service is not stopped), a direct call from a play (refused) and a first install
with nothing to back up. `check_mode` runs the bump under `--check` against a stopped service
with nothing to back up, and runs `check` before the converge (on a fresh host) and after it
(on the configured host). `check_mode` runs the bump under `--check` against a stopped service
and checks that nothing changed. The calling roles' own scenarios cover a real upstream binary.
Idempotent: yes.
@@ -46,13 +46,16 @@ verifier:
scenario:
# molecule's default sequence minus both destroys: scripts/run_molecule_scenarios.sh removes the
# container as soon as this scenario ends. After a local run, run `molecule destroy` yourself.
# A check runs before the converge (fresh host) and after it (configured host).
test_sequence:
- dependency
- cleanup
- syntax
- create
- prepare
- check
- converge
- check
- idempotence
- side_effect
- verify
+3 -1
View File
@@ -32,6 +32,7 @@ The role targets Ubuntu hosts that run the tunnel daemon, not Proxmox nodes, so
| `cloudflared_zone_name` | `""` (asserted while `cloudflared_manage_dns`) | Zone of the ingress hostnames. |
| `cloudflared_allow_dns_overwrite` | `[]` | Hostnames whose existing non-tunnel DNS record may be overwritten. |
| `cloudflared_api_base_url` | `https://api.cloudflare.com/client/v4` | Cloudflare API base URL for the role's `uri` calls, no trailing slash. |
| `cloudflared_tunnel_lookup_delay` | `5` | Seconds between the three retries of a 404 from the tunnel lookup, at least 0. |
| `cloudflared_tunnel_name` | `{{ inventory_hostname }}-tunnel` | Tunnel name used by the `mint` entry point. |
| `cloudflared_version` | pinned in `defaults/main.yml` | Release tag, `YYYY.M.P`. |
| `cloudflared_sha256_amd64` | pinned | SHA-256 of the amd64 binary. Update with the version. |
@@ -106,7 +107,7 @@ Remove with `-e "cloudflared_remove=true cloudflared_remove_data=true"`; only `c
## Tests
The `default` molecule scenario runs in CI only, on two platforms: `${MOLECULE_IMAGE}` (Ubuntu 24.04) and `${MOLECULE_IMAGE_2604}` (Ubuntu 26.04). It runs without Cloudflare: a stub cloudflared binary stands in for the daemon, the downloads come from local `file://` URLs, and a stub of the Cloudflare API on the controller's loopback (`molecule/default/files/cloudflare_api_stub.py`, reached through `cloudflared_api_base_url`) answers the tunnel, zone and DNS record calls. It covers the converge with `cloudflared_manage_dns` false and an update through `_binary_update` (and its idempotence), the rendered `config.yml`, credentials file and unit, a stale credentials file, a failed checksum that leaves the daemon running, the input asserts, the deleted-tunnel and DNS guards, the `mint` entry point (confirm guard, CI refusal, no-op, check mode and a mint against the stub, run as child processes) and the remove path. The `community.general.cloudflare_dns` calls, which cannot be pointed at the stub, are not covered: creating, pruning and deleting records.
The `default` molecule scenario runs in CI only, on two platforms: `${MOLECULE_IMAGE}` (Ubuntu 24.04) and `${MOLECULE_IMAGE_2604}` (Ubuntu 26.04). It runs without Cloudflare: a stub cloudflared binary stands in for the daemon, the downloads come from local `file://` URLs, and a stub of the Cloudflare API on the controller's loopback (`molecule/default/files/cloudflare_api_stub.py`, reached through `cloudflared_api_base_url`) answers the tunnel, zone and DNS record calls. It covers the converge with `cloudflared_manage_dns` false and an update through `_binary_update` (and its idempotence), the rendered `config.yml`, credentials file and unit, a stale credentials file, a failed checksum that leaves the daemon running, the input asserts, the deleted-tunnel and DNS guards, the `mint` entry point (confirm guard, CI refusal, no-op, check mode and a mint against the stub, run as child processes) and the remove path. The `community.general.cloudflare_dns` calls, which cannot be pointed at the stub, are not covered: creating, pruning and deleting records. It runs `check` before the converge (a fresh host) and after it (a configured host).
## Notes
@@ -120,3 +121,4 @@ The `default` molecule scenario runs in CI only, on two platforms: `${MOLECULE_I
- The `Restart cloudflared` handler runs when `config.yml` or the credentials file changes. cloudflared's own ingress check (`ingress validate`) runs after `config.yml` is written.
- Update: the version is compared as `YYYY.M.P` against `cloudflared --version`. The new binary is downloaded and checksum-verified into `cloudflared.new` before the service is stopped, so a failed download leaves it running; a configured hash that equals the installed binary's is refused with a message, since it means the hash was not bumped with the version. A binary that reports no version is replaced too.
- The play fails when `cloudflared` is not `active` after start.
- Check mode: `--check` is the supported preview; a play-level `check_mode: true` is not supported. Under `--check`, the config directory task is skipped when the `cloudflared` group or user is new. When the systemd unit is new or would change, the start, the running check, the `Restart cloudflared` handler and the update swap are skipped.
+2
View File
@@ -17,6 +17,8 @@ cloudflared_config_dir: "/etc/cloudflared"
cloudflared_service_unit: "/etc/systemd/system/cloudflared.service"
cloudflared_api_base_url: "https://api.cloudflare.com/client/v4"
# Seconds between the three retries of a 404 from the tunnel lookup.
cloudflared_tunnel_lookup_delay: 5
cloudflared_tunnel_name: "{{ inventory_hostname }}-tunnel"
+2
View File
@@ -4,3 +4,5 @@
ansible.builtin.systemd:
name: cloudflared
state: restarted
# Under --check a new unit is only simulated, so systemd would not find it.
when: not ansible_check_mode or __cloudflared_unit_file | default({}) is not changed
@@ -102,6 +102,13 @@ argument_specs:
Base URL of the Cloudflare API, without a trailing slash. Prefixed to every request the role makes with
C(ansible.builtin.uri) (tunnel lookup and delete, zone lookup and DNS record listing). The
C(community.general.cloudflare_dns) tasks always use the public endpoint.
cloudflared_tunnel_lookup_delay:
type: int
default: 5
description:
- >-
Seconds between the three retries of the tunnel lookup when Cloudflare answers 404, which right
after a mint can be read-after-write lag rather than a deleted tunnel. At least 0.
cloudflared_tunnel_name:
type: raw
description:
@@ -90,13 +90,16 @@ verifier:
scenario:
# molecule's default sequence minus both destroys: scripts/run_molecule_scenarios.sh removes the
# container as soon as this scenario ends. After a local run, run `molecule destroy` yourself.
# A check runs before the converge (fresh host) and after it (configured host).
test_sequence:
- dependency
- cleanup
- syntax
- create
- prepare
- check
- converge
- check
- idempotence
- side_effect
- verify
@@ -23,6 +23,8 @@
cloudflared_user: "{{ cloudflared_test_case.vars.cloudflared_user | default('cloudflared') }}"
cloudflared_install_dir: "{{ cloudflared_test_case.vars.cloudflared_install_dir | default('/usr/local/bin') }}"
cloudflared_config_dir: "{{ cloudflared_test_case.vars.cloudflared_config_dir | default('/etc/cloudflared') }}"
# The stub answers at once, so the retries need no wait; they still run.
cloudflared_tunnel_lookup_delay: "{{ cloudflared_test_case.vars.cloudflared_tunnel_lookup_delay | default(0) }}"
# Only reached when the include returned. The message must not contain the expected
# text, so the rescue below cannot mistake it for the failure under test.
@@ -157,6 +157,9 @@
- name: tunnel-id-not-uuid
vars: {cloudflared_tunnel_id: not-a-uuid}
expect: must be a lowercase UUID
- name: lookup-delay-negative
vars: {cloudflared_tunnel_lookup_delay: -1}
expect: cloudflared_tunnel_lookup_delay must be a whole number of seconds, at least 0
- name: tunnel-not-minted
vars: {cloudflared_tunnel_id: ""}
expect: run the mint entry point first
@@ -172,7 +175,7 @@
- name: tunnel-deleted
vars: {cloudflared_tunnel_id: 6f1a6e2c-0000-4000-8000-000000000002}
expect: no longer exists on Cloudflare
# Retried three times, 5 s apart, before the 404 is trusted.
# Retried three times (with no delay here) before the 404 is trusted.
- name: tunnel-unknown
vars: {cloudflared_tunnel_id: 6f1a6e2c-0000-4000-8000-00000000000f}
expect: (HTTP 404)
+8 -2
View File
@@ -20,7 +20,7 @@
# briefly before trusting it.
until: __cloudflared_tunnel_lookup.status | default(0) == 200
retries: 3
delay: 5
delay: "{{ cloudflared_tunnel_lookup_delay }}"
# Running out of retries fails the task whatever its status, and no_log would hide why: the
# two tasks below fail instead, with the re-mint instructions for a 404.
ignore_errors: true # noqa: ignore-errors
@@ -281,6 +281,7 @@
owner: root
group: root
mode: "0644"
register: __cloudflared_unit_file
- name: Reload systemd daemon
ansible.builtin.systemd:
@@ -291,6 +292,8 @@
name: cloudflared
enabled: true
state: started
# Under --check a new unit is only simulated, so systemd would not find it.
when: not ansible_check_mode or __cloudflared_unit_file is not changed
- name: Check cloudflared service status
ansible.builtin.systemd:
@@ -301,5 +304,8 @@
- name: Fail if cloudflared service is not running
ansible.builtin.fail:
msg: "cloudflared service is not running"
when: __cloudflared_service_status.status.ActiveState != "active"
when:
- __cloudflared_service_status.status.ActiveState != "active"
# The start above is skipped under --check for a new unit.
- not ansible_check_mode or __cloudflared_unit_file | default({}) is not changed
tags: [cloudflared, configure, health]
+4
View File
@@ -4,6 +4,7 @@
ansible.builtin.group:
name: "{{ cloudflared_group }}"
system: true
register: __cloudflared_group_account
tags: [cloudflared, prereqs, always]
- name: Create cloudflared user
@@ -15,6 +16,7 @@
comment: "Cloudflare Tunnel daemon"
system: true
create_home: false
register: __cloudflared_user_account
tags: [cloudflared, prereqs, always]
- name: Create cloudflared config directory
@@ -25,6 +27,8 @@
owner: "{{ cloudflared_user }}"
group: "{{ cloudflared_group }}"
mode: "0750"
# Under --check a new account is only simulated, so an existing directory cannot be chowned to it.
when: not ansible_check_mode or (__cloudflared_group_account is not changed and __cloudflared_user_account is not changed)
tags: [cloudflared, prereqs, always]
- name: Check if cloudflared binary exists
+3 -1
View File
@@ -80,7 +80,8 @@
cloudflared was not stopped and still runs {{ __cloudflared_installed_version }}.
tags: [cloudflared, update]
# An include does not pass its tags on to the included tasks, hence apply.
# An include does not pass its tags on to the included tasks, hence apply. Under --check a
# new unit is only simulated, so the stop and start of the swap would not find it.
- name: Swap in the staged cloudflared binary
ansible.builtin.include_role:
name: mortis.kamino._binary_update
@@ -93,6 +94,7 @@
_binary_update_version_command: ["{{ cloudflared_install_dir }}/cloudflared", --version]
_binary_update_expected_version: "{{ cloudflared_version }}"
_binary_update_version_regex: '([0-9]{4}\.[0-9]+\.[0-9]+)'
when: not ansible_check_mode or __cloudflared_unit_file | default({}) is not changed
tags: [cloudflared, update]
always:
+6
View File
@@ -63,6 +63,12 @@
newline or %, and the two directories must be absolute paths.
quiet: true
- name: Require a non-negative tunnel lookup delay
ansible.builtin.assert:
that: cloudflared_tunnel_lookup_delay | int(-1) >= 0
fail_msg: cloudflared_tunnel_lookup_delay must be a whole number of seconds, at least 0.
quiet: true
# The role never creates the tunnel on its main entry point. Defined and empty (or null) counts
# as missing, as in the mint entry point, so the two cannot disagree.
- name: Require the minted tunnel secrets
+4 -3
View File
@@ -4,7 +4,7 @@ Installs Docker Engine from the upstream Docker APT repository, optionally updat
## Supported platforms
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.
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_facts['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).
@@ -86,12 +86,12 @@ 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 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.
`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. It runs `check` before the converge (on a fresh host) and after it (on the configured host).
What it shows, with the role's tasks running unchanged:
- The key is fetched, stored at `docker_keyring_path` with mode `0644`, and apt really verifies the repository against it (an unsigned or wrongly signed repository would leave no install candidate).
- The source line has the architecture, the `signed-by` keyring and `ansible_distribution_release`.
- The source line has the architecture, the `signed-by` keyring and `ansible_facts['distribution_release']`.
- The packages are installed from that repository, the unit is enabled and active, and `docker_users` join `docker_group`.
- `docker_remove` with `docker_remove_data` removes the source line, the keyring, the packages, the unit and `/var/lib/docker`.
- Both units are installed, enabled, ordered against `docker.service` as stated, the shutdown unit is active, a unit is removed when its input is `false`, and `docker_remove` removes both.
@@ -104,6 +104,7 @@ What it does not show: what the units do at a real boot or shutdown (the contain
## Notes
- Idempotent: yes.
- Check mode: `--check` is the supported preview; a play-level `check_mode: true` is not supported. On a host where the Docker source line is not written yet, the package install, the service start, adding `docker_users` to `docker_group` and the `docker_update` tasks are skipped under `--check`, because the repository they need is only simulated.
- `docker_remove` is checked first: when true, only `remove.yml` runs.
- Removal with `docker_remove_data` is destructive. It deletes `/var/lib/docker`.
- The update task resolves each package's candidate with `apt-cache policy` and fails if a package has none. It installs `package=version`, never `latest`.
+2 -2
View File
@@ -6,7 +6,7 @@ argument_specs:
- >-
Installs Docker Engine from the upstream APT repository, or removes it when C(docker_remove) is true. Optionally updates the packages to
the current candidate versions, then adds C(docker_users) to C(docker_group).
- Needs gathered facts, because the APT source uses C(ansible_distribution_release).
- Needs gathered facts, because the APT source uses C(ansible_facts['distribution_release']).
options:
docker_remove:
type: bool
@@ -53,7 +53,7 @@ argument_specs:
type: str
default: https://download.docker.com/linux/ubuntu
description:
- Base URL of the repository. The source line uses C(ansible_distribution_release) and the C(stable) component.
- Base URL of the repository. The source line uses C(ansible_facts['distribution_release']) and the C(stable) component.
docker_apt_arch:
type: str
default: ""
-113
View File
@@ -20,116 +20,3 @@
max-concurrent-downloads: 3
roles:
- role: mortis.kamino.docker
# The plays below are refusals: argument_specs rejects the wrong types before any task runs,
# so the idempotence run stays clean. A sentinel in the failure message tells "the role
# refused" from "the fail task after the role ran", which a bare rescue cannot.
- name: A docker_users value that is not a list is refused
hosts: all
gather_facts: false
vars:
docker_users:
not: a-list
tasks:
- name: Apply the role with a mapping for docker_users
block:
- name: Include the role
ansible.builtin.include_role:
name: mortis.kamino.docker
- name: Fail when the wrong type was accepted
ansible.builtin.fail:
msg: MOLECULE-ACCEPTED
rescue:
- name: The argument check stopped the play
ansible.builtin.assert:
that:
- "'MOLECULE-ACCEPTED' not in ansible_failed_result.msg | default('')"
- "'docker_users' in ansible_failed_result.msg | default('')"
quiet: true
- name: A docker_remove value that is not a boolean is refused
hosts: all
gather_facts: false
vars:
docker_remove: maybe
tasks:
- name: Apply the role with a non-boolean docker_remove
block:
- name: Include the role
ansible.builtin.include_role:
name: mortis.kamino.docker
- name: Fail when the wrong type was accepted
ansible.builtin.fail:
msg: MOLECULE-ACCEPTED
rescue:
- name: The argument check stopped the play
ansible.builtin.assert:
that:
- "'MOLECULE-ACCEPTED' not in ansible_failed_result.msg | default('')"
- "'docker_remove' in ansible_failed_result.msg | default('')"
quiet: true
# The architecture is written into the one-line apt source, so a value with a space or a bracket is refused before anything
# changes. The derived default is covered by the converge above and verify.yml (the container is x86_64, so the source says amd64).
- name: A docker_apt_arch value that would corrupt the apt source is refused
hosts: all
gather_facts: false
vars:
docker_apt_arch: "bad arch"
tasks:
- name: Apply the role with a bad architecture
block:
- name: Include the role
ansible.builtin.include_role:
name: mortis.kamino.docker
- name: Fail when the bad architecture was accepted
ansible.builtin.fail:
msg: MOLECULE-ACCEPTED
rescue:
- name: The validation stopped the play
ansible.builtin.assert:
that:
- "'MOLECULE-ACCEPTED' not in ansible_failed_result.msg | default('')"
- "'docker_apt_arch' in ansible_failed_result.msg | default('')"
quiet: true
# The unit timings are checked before anything changes.
- name: A docker_stop_at_shutdown_timeout of 0 is refused
hosts: all
gather_facts: false
vars:
docker_stop_at_shutdown_timeout: 0
tasks:
- name: Apply the role with a timeout of 0
block:
- name: Include the role
ansible.builtin.include_role:
name: mortis.kamino.docker
- name: Fail when the timeout was accepted
ansible.builtin.fail:
msg: MOLECULE-ACCEPTED
rescue:
- name: The validation stopped the play
ansible.builtin.assert:
that:
- "'MOLECULE-ACCEPTED' not in ansible_failed_result.msg | default('')"
- "'docker_stop_at_shutdown_timeout' in ansible_failed_result.msg | default('')"
quiet: true
# A key that docker_daemon_options and a dedicated input both set, and a log value dockerd would reject, stop the run before any change.
- name: A bad daemon setting is refused
hosts: all
gather_facts: false
tasks:
- name: Apply the role with each bad setting
ansible.builtin.include_tasks: tasks/refuse_daemon.yml
vars:
docker_refused: "{{ item }}"
loop:
- {docker_live_restore: true, docker_daemon_options: {live-restore: false}}
- {docker_log_driver: local, docker_daemon_options: {log-driver: json-file}}
- {docker_log_max_size: 10m, docker_daemon_options: {log-opts: {max-size: 1m}}}
- {docker_log_driver: Local}
- {docker_log_max_size: ten}
- {docker_log_max_file: "0"}
- {docker_log_max_file: "-1"}
@@ -49,13 +49,16 @@ verifier:
scenario:
# molecule's default sequence minus both destroys: scripts/run_molecule_scenarios.sh removes the
# container as soon as this scenario ends. After a local run, run `molecule destroy` yourself.
# A check runs before the converge (fresh host) and after it (configured host).
test_sequence:
- dependency
- cleanup
- syntax
- create
- prepare
- check
- converge
- check
- idempotence
- side_effect
- verify
@@ -12,6 +12,12 @@
docker_molecule_repo: /srv/docker-stub-repo
docker_molecule_work: /var/tmp/docker-stub-work
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: Copy the repository builder
ansible.builtin.copy:
src: build-stub-repo.sh
+129
View File
@@ -1,4 +1,133 @@
---
# The refusals need no container, so they run once, on the controller, in check mode so that a
# refusal that regressed cannot change it. The controller has no gathered facts, so a play that
# does not test the architecture sets it. A sentinel in the failure message tells "the role
# refused" from "the fail task after the role ran", which a bare rescue cannot.
- name: A docker_users value that is not a list is refused
hosts: localhost
connection: local
check_mode: true
gather_facts: false
vars:
docker_apt_arch: amd64
docker_users:
not: a-list
tasks:
- name: Apply the role with a mapping for docker_users
block:
- name: Include the role
ansible.builtin.include_role:
name: mortis.kamino.docker
- name: Fail when the wrong type was accepted
ansible.builtin.fail:
msg: MOLECULE-ACCEPTED
rescue:
- name: The argument check stopped the play
ansible.builtin.assert:
that:
- "'MOLECULE-ACCEPTED' not in ansible_failed_result.msg | default('')"
- "'docker_users' in ansible_failed_result.msg | default('')"
quiet: true
- name: A docker_remove value that is not a boolean is refused
hosts: localhost
connection: local
check_mode: true
gather_facts: false
vars:
docker_apt_arch: amd64
docker_remove: maybe
tasks:
- name: Apply the role with a non-boolean docker_remove
block:
- name: Include the role
ansible.builtin.include_role:
name: mortis.kamino.docker
- name: Fail when the wrong type was accepted
ansible.builtin.fail:
msg: MOLECULE-ACCEPTED
rescue:
- name: The argument check stopped the play
ansible.builtin.assert:
that:
- "'MOLECULE-ACCEPTED' not in ansible_failed_result.msg | default('')"
- "'docker_remove' in ansible_failed_result.msg | default('')"
quiet: true
# The architecture is written into the one-line apt source, so a value with a space or a bracket is refused before anything
# changes. The derived default is covered by converge.yml and the plays below (the container is x86_64, so the source says amd64).
- name: A docker_apt_arch value that would corrupt the apt source is refused
hosts: localhost
connection: local
check_mode: true
gather_facts: false
vars:
docker_apt_arch: "bad arch"
tasks:
- name: Apply the role with a bad architecture
block:
- name: Include the role
ansible.builtin.include_role:
name: mortis.kamino.docker
- name: Fail when the bad architecture was accepted
ansible.builtin.fail:
msg: MOLECULE-ACCEPTED
rescue:
- name: The validation stopped the play
ansible.builtin.assert:
that:
- "'MOLECULE-ACCEPTED' not in ansible_failed_result.msg | default('')"
- "'docker_apt_arch' in ansible_failed_result.msg | default('')"
quiet: true
# The unit timings are checked before anything changes.
- name: A docker_stop_at_shutdown_timeout of 0 is refused
hosts: localhost
connection: local
check_mode: true
gather_facts: false
vars:
docker_apt_arch: amd64
docker_stop_at_shutdown_timeout: 0
tasks:
- name: Apply the role with a timeout of 0
block:
- name: Include the role
ansible.builtin.include_role:
name: mortis.kamino.docker
- name: Fail when the timeout was accepted
ansible.builtin.fail:
msg: MOLECULE-ACCEPTED
rescue:
- name: The validation stopped the play
ansible.builtin.assert:
that:
- "'MOLECULE-ACCEPTED' not in ansible_failed_result.msg | default('')"
- "'docker_stop_at_shutdown_timeout' in ansible_failed_result.msg | default('')"
quiet: true
# A key that docker_daemon_options and a dedicated input both set, and a log value dockerd would reject, stop the run before any change.
- name: A bad daemon setting is refused
hosts: localhost
connection: local
check_mode: true
gather_facts: false
vars:
docker_apt_arch: amd64
tasks:
- name: Apply the role with each bad setting
ansible.builtin.include_tasks: tasks/refuse_daemon.yml
vars:
docker_refused: "{{ item }}"
loop:
- {docker_live_restore: true, docker_daemon_options: {live-restore: false}}
- {docker_log_driver: local, docker_daemon_options: {log-driver: json-file}}
- {docker_log_max_size: 10m, docker_daemon_options: {log-opts: {max-size: 1m}}}
- {docker_log_driver: Local}
- {docker_log_max_size: ten}
- {docker_log_max_file: "0"}
- {docker_log_max_file: "-1"}
# What the role is for, as far as stand-in packages can show it: the repository key and the
# source line are in place and apt really used them, the packages are installed from that
# repository, the unit is enabled and running, and the user joined the group. The second play
+9 -1
View File
@@ -7,6 +7,7 @@
- curl
state: present
update_cache: true
cache_valid_time: 3600
tags: [docker, install]
- name: Ensure APT keyrings directory exists
@@ -30,8 +31,9 @@
ansible.builtin.copy:
dest: "{{ docker_apt_list_path }}"
content: |
deb [arch={{ __docker_apt_arch }} signed-by={{ docker_keyring_path }}] {{ docker_repo_base_url }} {{ ansible_distribution_release }} stable
deb [arch={{ __docker_apt_arch }} signed-by={{ docker_keyring_path }}] {{ docker_repo_base_url }} {{ ansible_facts['distribution_release'] }} stable
mode: "0644"
register: __docker_apt_source
tags: [docker, install]
- name: Install Docker Engine packages
@@ -39,8 +41,12 @@
ansible.builtin.apt:
name: "{{ docker_packages }}"
state: present
# Always refreshed: a run that wrote the source line but failed to fetch its lists heals here.
update_cache: true
register: __docker_packages
notify: Restart docker
# Under --check a new source line is only simulated, so apt would find no Docker package.
when: not ansible_check_mode or __docker_apt_source is not changed
tags: [docker, install]
- name: Enable and start Docker service
@@ -49,4 +55,6 @@
name: "{{ docker_service }}"
enabled: true
state: started
# Under --check on a host without the packages there is no unit to start yet.
when: not ansible_check_mode or (__docker_apt_source is not changed and __docker_packages is not changed)
tags: [docker, install]
+6 -1
View File
@@ -24,6 +24,8 @@
when:
- not (docker_remove | default(false) | bool)
- docker_update | bool
# Under --check a new source line is only simulated, so no package would have a candidate.
- not ansible_check_mode or __docker_apt_source | default({}) is not changed
tags: [docker, update]
- name: Add configured users to the docker group
@@ -33,7 +35,10 @@
groups: "{{ docker_group }}"
append: true
loop: "{{ docker_users }}"
when: not (docker_remove | default(false) | bool)
when:
- not (docker_remove | default(false) | bool)
# Under --check on a host without the packages the group does not exist yet.
- not ansible_check_mode or (__docker_apt_source | default({}) is not changed and __docker_packages | default({}) is not changed)
tags: [docker, configure]
- name: Install or remove the boot and shutdown units
+2 -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). The sequence runs prepare, converge, idempotence, side effect and verify; it has no check-mode step.
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).
- 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.
@@ -94,6 +94,7 @@ Not covered: no failure is sent through a jail, so a ban triggered by `failregex
## Notes
- Idempotent: yes.
- Check mode: `--check` previews a host where fail2ban is already installed; a play-level `check_mode: true` is not supported. On a host without fail2ban it fails at the configuration and service tasks: the package is not installed under `--check`, so `/etc/fail2ban`, `fail2ban-client` and the unit are missing.
- `fail2ban_ignoreip` lives in the `[DEFAULT]` section of `jail.local`, so it also applies to the jails that `service_jail` writes to `jail.d`. The exemption only exists once the main entry point has written `jail.local` on that host: `service_jail` does not read `fail2ban_ignoreip`, so a host that uses only `service_jail` has none.
- `fail2ban_ignoreip` replaces an `ignoreip` set in `jail.conf` or `jail.d/*.conf`, which Fail2Ban reads before `jail.local`; a `jail.d/*.local` file is read after it and can still override it for one jail. Entries must not contain whitespace, `;` or `%` (a `;` after whitespace starts a comment in Fail2Ban's config files and a `%` is interpolation syntax).
- Prefer IP addresses and CIDR networks in `fail2ban_ignoreip`. Fail2Ban resolves a hostname when the jail starts, and a failed lookup leaves that entry ineffective with only a log warning. The validation of `fail2ban_ignoreip` runs under the `fail2ban_validate` tag, so `--tags fail2ban_configure` skips it.
@@ -47,13 +47,16 @@ verifier:
scenario:
# molecule's default sequence minus both destroys: scripts/run_molecule_scenarios.sh removes the
# container as soon as this scenario ends. After a local run, run `molecule destroy` yourself.
# A check runs before the converge (fresh host) and after it (configured host).
test_sequence:
- dependency
- cleanup
- syntax
- create
- prepare
- check
- converge
- check
- idempotence
- side_effect
- verify
+2 -1
View File
@@ -148,7 +148,7 @@ The `default` molecule scenario runs in CI only, on two platforms: `${MOLECULE_I
- 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.
- The remove path, against a stub unit and binary: both are deleted, the service is no longer active, only the Gitea ufw rules are removed (the SSH rule and a rule without an owner tag stay), and no config or data directory or `gitea_user` account is created.
Not covered: install, configure, the admin user, the SSH-key API calls, the update path, the normal-flow assert on `gitea_api_token` (after the service starts) and a mint that creates a token.
Not covered: install, configure, the admin user, the SSH-key API calls, the update path, the normal-flow assert on `gitea_api_token` (after the service starts) and a mint that creates a token. The scenario runs `check` before and after the converge, but its converge applies nothing, so neither check runs the role.
## Notes
@@ -162,3 +162,4 @@ Not covered: install, configure, the admin user, the SSH-key API calls, the upda
- The SSH-key API calls go to `gitea_http_addr:gitea_http_port` (wildcard becomes loopback, IPv6 is bracketed), not to `gitea_domain`.
- Handlers: `Reload Gitea` restarts the service when `app.ini` changes, and `main.yml` flushes handlers at the end so a later failure in the same play does not drop the restart. The `Reload Systemd` handler is defined but no task in the role notifies it.
- The play fails when the service is not `active` after start.
- Check mode: `--check` is the supported preview; a play-level `check_mode: true` is not supported. Under `--check` on a host without the binary, the binary assert and the bash completion tasks are skipped. When the systemd unit is new or would change, the start, the running check, the `Reload Gitea` handler and the update swap are skipped. The check-mode path is not tested.
+2
View File
@@ -9,3 +9,5 @@
ansible.builtin.systemd:
name: gitea
state: restarted
# Under --check a new unit is only simulated, so systemd would not find it.
when: not ansible_check_mode or __gitea_unit_file | default({}) is not changed
@@ -57,13 +57,16 @@ verifier:
scenario:
# molecule's default sequence minus both destroys: scripts/run_molecule_scenarios.sh removes the
# container as soon as this scenario ends. After a local run, run `molecule destroy` yourself.
# A check runs before the converge (fresh host) and after it (configured host).
test_sequence:
- dependency
- cleanup
- syntax
- create
- prepare
- check
- converge
- check
- idempotence
- side_effect
- verify
+10 -1
View File
@@ -92,6 +92,8 @@
changed_when: false
# Read-only: the script is only generated to be written by the next task, so it must also run in --check.
check_mode: false
# Under --check on a fresh host there is no binary to run.
when: not ansible_check_mode or gitea_installed
tags: [gitea, configure]
- name: Write bash completion to system directory
@@ -102,6 +104,7 @@
owner: root
group: root
mode: "0644"
when: not ansible_check_mode or gitea_installed
tags: [gitea, configure]
- name: Create systemd service file for Gitea
@@ -127,6 +130,7 @@
owner: root
group: root
mode: "0644"
register: __gitea_unit_file
tags: [gitea, configure]
- name: Reload systemd daemon
@@ -164,6 +168,8 @@
name: gitea
enabled: true
state: started
# Under --check a new unit is only simulated, so systemd would not find it.
when: not ansible_check_mode or __gitea_unit_file is not changed
tags: [gitea, configure]
- name: Check Gitea service status
@@ -176,7 +182,10 @@
- name: Fail if Gitea service is not running
ansible.builtin.fail:
msg: "Gitea service is not running"
when: gitea_service_status.status.ActiveState != "active"
when:
- gitea_service_status.status.ActiveState != "active"
# The start above is skipped under --check for a new unit.
- not ansible_check_mode or __gitea_unit_file | default({}) is not changed
tags: [gitea, configure, health]
# The token is minted by the opt-in mint entry point, never here. This sits after the
+2
View File
@@ -39,4 +39,6 @@
that:
- gitea_binary.stat.exists
fail_msg: "Gitea binary not found after download"
# Nothing is downloaded under --check.
when: not ansible_check_mode
tags: [gitea, install, health, update]
+3 -1
View File
@@ -64,7 +64,8 @@
Gitea was not stopped and still runs {{ gitea_installed_version }}.
tags: [gitea, update]
# An include does not pass its tags on to the included tasks, hence apply.
# An include does not pass its tags on to the included tasks, hence apply. Under --check a
# new unit is only simulated, so the stop and start of the swap would not find it.
- name: Swap in the staged Gitea binary
ansible.builtin.include_role:
name: mortis.kamino._binary_update
@@ -76,6 +77,7 @@
_binary_update_staged_path: "{{ gitea_staging_dir }}/gitea"
_binary_update_version_command: ["{{ gitea_install_dir }}/gitea", --version]
_binary_update_expected_version: "{{ gitea_version }}"
when: not ansible_check_mode or __gitea_unit_file | default({}) is not changed
tags: [gitea, update]
always:
+3 -2
View File
@@ -18,7 +18,7 @@ The role targets Ubuntu hosts that run CI jobs, not Proxmox nodes, so it does no
- The registration token is generated on the fly, held in a `no_log` fact and passed to `gitea-runner register` through the `GITEA_RUNNER_REGISTRATION_TOKEN` environment variable, not argv. It is never written to a file by the role.
- The role creates `gitea_runner_group` and `gitea_runner_user` when they are missing; an existing account (for example the SSH login user) is reused.
- Docker is installed by this role (`tasks/docker.yml`) on first install, not by `mortis.kamino.docker`.
- Fact gathering must be on for `gitea_runner_force_register`: the backup name uses `ansible_date_time`.
- Fact gathering must be on for `gitea_runner_force_register`: the backup name uses `ansible_facts['date_time']`.
- Updates: the update path stages the verified binary and hands the swap to `mortis.kamino._binary_update`, an internal role of this Collection.
- `gitea_runner_version` is asserted at role start to be a plain `X.Y.Z` release number, with no leading `v`. Pin it in inventory to move the runner independently of Collection releases; the role default changes only with a release.
- The executor and job image of a job come from its label's suffix (`:host` or `docker://<image>`); a label with no suffix runs its jobs on the host. `config.yaml` has no keys for them.
@@ -89,7 +89,7 @@ Change the registration scope of a registered runner: set `gitea_runner_registra
## Tests
The `default` molecule scenario runs in CI only, on two platforms: `${MOLECULE_IMAGE}` (Ubuntu 24.04) and `${MOLECULE_IMAGE_2604}` (Ubuntu 26.04). It runs without a Gitea server and without Docker: a stub `docker.service`, a stub runner binary and a seeded `.runner` stand in for them, and the downloads come from local `file://` URLs. It covers the converge with the prune timer and an update through `_binary_update` (and its idempotence), the rendered `config.yaml` and unit, the prune gate script, the count prune and the disk check against a stub `docker` CLI, turning the pressure prune off, a failed checksum that leaves the runner running, the input asserts, the CI refusal of a forced re-registration and the mint-before-drop order, and the remove path. Registration, the Docker install and the host packages of the host-executor label are not covered.
The `default` molecule scenario runs in CI only, on two platforms: `${MOLECULE_IMAGE}` (Ubuntu 24.04) and `${MOLECULE_IMAGE_2604}` (Ubuntu 26.04). It runs without a Gitea server and without Docker: a stub `docker.service`, a stub runner binary and a seeded `.runner` stand in for them, and the downloads come from local `file://` URLs. It covers the converge with the prune timer and an update through `_binary_update` (and its idempotence), the rendered `config.yaml` and unit, the prune gate script, the count prune and the disk check against a stub `docker` CLI, turning the pressure prune off, a failed checksum that leaves the runner running, the input asserts, the CI refusal of a forced re-registration and the mint-before-drop order, and the remove path. Registration, the Docker install and the host packages of the host-executor label are not covered. It runs `check` before the converge (a fresh host) and after it (a configured host).
## Notes
@@ -101,4 +101,5 @@ The `default` molecule scenario runs in CI only, on two platforms: `${MOLECULE_I
- The Docker prune units (`gitea-runner-docker-prune.{service,timer}`) are written only while `gitea_runner_docker_prune_enabled` is true. Setting it back to false leaves them in place: run `systemctl disable --now gitea-runner-docker-prune.timer` by hand. `gitea_runner_remove` deletes them, the pressure units and the prune scripts. A run skipped because a job was running is not retried until the next timer elapse: shorten `gitea_runner_docker_prune_schedule` (e.g. `*-*-* 04:30:00`) if that happens.
- The pressure prune (`gitea-runner-docker-prune-pressure.{service,timer}`) runs once per check while usage is above the threshold; it has no low watermark, so usage that stays high needs a smaller count or a larger disk. A threshold set back to `0` stops its timer and removes its units and the disk check script. The age prunes and the count prune both apply: an image either one removes is gone.
- The play fails when `gitea-runner` is not `active` after start.
- Check mode: `--check` is the supported preview; a play-level `check_mode: true` is not supported. Under `--check`, the work directory ownership task is skipped when the runner group or user is new, and starting Docker when `docker.io` is not installed yet. When the systemd unit is new or would change, the start, the running check, the `Restart Gitea Runner` handler and the update swap are skipped.
- `no_log` covers the token mint, the token fact and the registration command.
+2
View File
@@ -4,3 +4,5 @@
ansible.builtin.systemd:
name: gitea-runner
state: restarted
# Under --check a new unit is only simulated, so systemd would not find it.
when: not ansible_check_mode or __gitea_runner_unit_file | default({}) is not changed
+1 -1
View File
@@ -19,7 +19,7 @@ argument_specs:
C(gitea_runner_token_host), C(gitea_runner_instance_url) and C(gitea_runner_name) have empty role defaults and
are asserted only when registration runs, so a run that never registers is not blocked.
- >-
Reads gathered facts (C(ansible_date_time), for the forced re-registration backup name) and
Reads gathered facts (C(ansible_facts['date_time']), for the forced re-registration backup name) and
C(ansible_check_mode).
options:
gitea_runner_remove:
@@ -66,13 +66,16 @@ verifier:
scenario:
# molecule's default sequence minus both destroys: scripts/run_molecule_scenarios.sh removes the
# container as soon as this scenario ends. After a local run, run `molecule destroy` yourself.
# A check runs before the converge (fresh host) and after it (configured host).
test_sequence:
- dependency
- cleanup
- syntax
- create
- prepare
- check
- converge
- check
- idempotence
- side_effect
- verify
+11 -1
View File
@@ -17,6 +17,10 @@
owner: "{{ gitea_runner_user }}"
group: "{{ gitea_runner_group }}"
recurse: true
# Under --check a new account is only simulated, so an existing directory cannot be chowned to it.
when: >-
not ansible_check_mode or
(__gitea_runner_group_account | default({}) is not changed and __gitea_runner_user_account | default({}) is not changed)
tags: [gitea_runner, configure]
- name: Check current runner registration file state
@@ -62,6 +66,7 @@
[Install]
WantedBy=multi-user.target
register: __gitea_runner_unit_file
tags: [gitea_runner, configure]
- name: Reload systemd
@@ -76,6 +81,8 @@
name: gitea-runner
enabled: true
state: started
# Under --check a new unit is only simulated, so systemd would not find it.
when: not ansible_check_mode or __gitea_runner_unit_file is not changed
tags: [gitea_runner, configure]
- name: Check runner service status
@@ -88,5 +95,8 @@
- name: Fail if runner service is not running
ansible.builtin.fail:
msg: "Gitea runner service is not running"
when: gitea_runner_service_status.status.ActiveState != "active"
when:
- gitea_runner_service_status.status.ActiveState != "active"
# The start above is skipped under --check for a new unit.
- not ansible_check_mode or __gitea_runner_unit_file | default({}) is not changed
tags: [gitea_runner, configure, health]
+5
View File
@@ -17,6 +17,7 @@
name:
- docker.io
state: present
register: __gitea_runner_docker_package
tags: [gitea_runner, docker, install]
- name: Enable and start Docker
@@ -25,6 +26,8 @@
name: docker
enabled: true
state: started
# Under --check a new package is only simulated, so there is no docker unit yet.
when: not ansible_check_mode or __gitea_runner_docker_package is not changed
tags: [gitea_runner, docker, install]
- name: Add the runner user to the docker group
@@ -33,6 +36,8 @@
name: "{{ gitea_runner_user }}"
groups: docker
append: true
# Under --check a new docker.io creates no docker group, and user fails on a missing group.
when: not ansible_check_mode or __gitea_runner_docker_package is not changed
tags: [gitea_runner, docker, install]
# Pulls ubuntu:24.04 from Docker Hub. Also proves Docker runs inside a container host
+1 -1
View File
@@ -71,7 +71,7 @@
become: true
ansible.builtin.copy:
src: "{{ gitea_runner_work_dir }}/.runner"
dest: "{{ gitea_runner_work_dir }}/.runner.bak.{{ ansible_date_time.iso8601_basic_short }}"
dest: "{{ gitea_runner_work_dir }}/.runner.bak.{{ ansible_facts['date_time']['iso8601_basic_short'] }}"
remote_src: true
owner: "{{ gitea_runner_state.stat.pw_name }}"
group: "{{ gitea_runner_state.stat.gr_name }}"
+2
View File
@@ -6,6 +6,7 @@
ansible.builtin.group:
name: "{{ gitea_runner_group }}"
system: true
register: __gitea_runner_group_account
tags: [gitea_runner, prereqs, always]
- name: Ensure runner user exists
@@ -16,6 +17,7 @@
home: "{{ gitea_runner_home }}"
create_home: true
system: true
register: __gitea_runner_user_account
tags: [gitea_runner, prereqs, always]
- name: Check if runner is installed
+3 -1
View File
@@ -54,7 +54,8 @@
The runner was not stopped and still runs {{ gitea_runner_installed_version }}.
tags: [gitea_runner, update]
# An include does not pass its tags on to the included tasks, hence apply.
# An include does not pass its tags on to the included tasks, hence apply. Under --check a
# new unit is only simulated, so the stop and start of the swap would not find it.
- name: Swap in the staged runner binary
ansible.builtin.include_role:
name: mortis.kamino._binary_update
@@ -66,6 +67,7 @@
_binary_update_staged_path: "{{ gitea_runner_staged_binary }}"
_binary_update_version_command: ["{{ gitea_runner_install_dir }}/gitea-runner", --version]
_binary_update_expected_version: "{{ gitea_runner_version }}"
when: not ansible_check_mode or __gitea_runner_unit_file | default({}) is not changed
tags: [gitea_runner, update]
always:
+2 -1
View File
@@ -57,7 +57,7 @@ None. The role does not tag its tasks, so only a play-level tag applies.
## Tests
`molecule/default` runs in CI only, on one platform: Ubuntu 24.04 (noble), the `molecule-ubuntu2404` image (`${MOLECULE_IMAGE}`). The image has no `ifupdown2`, and a real reload could cut the container's own network, so the validate command is `/bin/true` and the apply command appends to a marker file; the rest of the role runs unchanged. Prepare seeds `/etc/network/interfaces` with a legacy body, so the converge has a change to make and a backup to take.
`molecule/default` runs in CI only, on one platform: Ubuntu 24.04 (noble), the `molecule-ubuntu2404` image (`${MOLECULE_IMAGE}`). The image has no `ifupdown2`, and a real reload could cut the container's own network, so the validate command is `/bin/true` and the apply command appends to a marker file; the rest of the role runs unchanged. Prepare seeds `/etc/network/interfaces` with a legacy body, so the converge has a change to make and a backup to take. The scenario runs `check` before the converge (fresh host) and after it (configured host).
Verify checks:
@@ -76,4 +76,5 @@ It does not test `ifreload`, so no Debian release or `ifupdown2` version is veri
- On change the order is: copy the current file to `network_interfaces_backup`, write the new file (notifies `Reload Interfaces`), run the validate command, flush handlers. Any failure in that block restores the backup and fails with "Invalid network configuration detected. Previous config restored." The restore does not reload the interfaces.
- The validate command runs after the file is written, and the reload runs right after it. A configuration that passes validation but breaks connectivity is not detected.
- With `method: static`, `address` and `netmask` are required by the template.
- Check mode: `--check` is the supported preview; a play-level `check_mode: true` is not supported. Under `--check` the new file is not written, so the validate command and the reload are skipped; the preview shows whether the file would change, not whether it is valid.
- `no_log` is not used: the role handles no secrets.
@@ -29,13 +29,16 @@ verifier:
scenario:
# molecule's default sequence minus both destroys: scripts/run_molecule_scenarios.sh removes the
# container as soon as this scenario ends. After a local run, run `molecule destroy` yourself.
# A check runs before the converge (fresh host) and after it (configured host).
test_sequence:
- dependency
- cleanup
- syntax
- create
- prepare
- check
- converge
- check
- idempotence
- side_effect
- verify
+74
View File
@@ -0,0 +1,74 @@
# nfs_client
Installs the NFS client (`nfs-common`) and manages NFS mount entries in `/etc/fstab`. It writes the fstab line, creates the mount point and reloads systemd; it never mounts or unmounts anything. Variables and their types are defined in [`meta/argument_specs.yml`](meta/argument_specs.yml), which is the source of truth.
## Supported platforms
Ubuntu 24.04 (noble) and 26.04 (resolute), the platforms the molecule scenario runs on. The role asserts a Debian-family host before any change.
Untested platforms: Debian 13 (trixie). The role has no OS-specific branch, but no scenario runs on it until the Debian image (#226) exists.
## Requirements and run order
- Use it by its fully qualified name, `mortis.kamino.nfs_client`, in a play that gathers facts: the Debian-family assert reads them.
- Role dependencies: none. The role calls `ansible.posix.mount`, so the Collection's `ansible.posix` dependency applies.
- `become` is used for every task that changes the host.
- The role does not set up an NFS server, autofs, CIFS/SMB or Kerberos, and it does not wait for a mount.
## Role variables
| Variable | Default | Description |
|---|---|---|
| `nfs_client_mounts` | `[]` | The mounts to manage: a list of entries, each mount point once. With no entries only the client package is installed. |
| `nfs_client_default_opts` | `_netdev,nofail` | Options for an entry that sets none. |
An entry takes these keys:
| Key | Default | Description |
|---|---|---|
| `src` | required | The export as `server:/export`, one word without spaces. |
| `path` | required | The mount point: absolute, without spaces, not `/`, no trailing slash. |
| `opts` | `nfs_client_default_opts` | The fstab options, one comma-separated word. Put the NFS version here, for example `vers=4.2`. |
| `state` | `present` | `present` writes the fstab line. `absent` removes it and nothing else. |
## Tags
- `nfs_client`: everything the role does.
- `install`: the client package.
- `configure`: the mount points and the fstab entries.
Validation runs under `always`, so a bad input fails before any change whatever tags the run selects.
## Example play
```yaml
- name: NFS client
hosts: nfs_clients
roles:
- role: mortis.kamino.nfs_client
vars:
nfs_client_mounts:
- src: nas.example:/export/data
path: /mnt/data
- src: nas.example:/export/media
path: /mnt/media
opts: _netdev,nofail,ro,vers=4.2
```
## Tests
`molecule/default` runs on Ubuntu noble and resolute: a check on a fresh host, the converge, a check on the configured host, an idempotence run, and `verify.yml`. The scenario seeds an fstab line for `/mnt/data` that names another server and a line and a directory for `/mnt/old`, so the run shows that a line is replaced once and that an `absent` entry loses only its line.
`verify.yml` first checks a refusal for each validation on the controller, once, in check mode (a missing or empty `src`, a `src` without an export, a relative path, the root, a trailing slash, options with a space or none, a duplicate path, `mounted` and `remounted`, a host without facts). It then asserts, on each container, the client package, the exact fstab fields, that a new mount point is root's and an existing one keeps its owner and mode, that the removed entry's directory and file are intact, that `/proc/mounts` shows nothing mounted, and that systemd has a mount unit for each new entry and none for the removed one.
What it does not show: that a real share mounts at boot (the server in the scenario does not exist), that `x-systemd.automount` or any option other than the defaults behaves, and Debian trixie.
## Notes
- **Why only the fstab.** `ansible.posix.mount` with `state: mounted` mounts from the play's own process. Where that process runs in a private mount namespace (a hardened sshd unit can), systemd and containers do not see the mount. The role writes the line and reloads systemd, and the share is mounted at the next boot or with `systemctl start <unit>.mount`. New options reach a share that is already mounted only after it is remounted or the host reboots.
- **No owner, group or mode on the mount point.** Once a share is mounted the path is the export root, and a `chown` or `chmod` there changes the permissions on the NFS server. A new directory gets the system defaults, and an existing one is left as it is.
- **A share that is mounted and unreachable.** On a re-run the role looks at each `present` mount point, and a mounted path whose server is gone can block that look. Fix or unmount the share, or leave that entry out of the run, before running the role again.
- **`absent` leaves the share alone.** The entry's line is removed; the share stays mounted until it is unmounted and the mount point is not deleted.
- **Default options.** `_netdev` orders the mount after the network and puts it in `remote-fs.target`; `nofail` keeps an unreachable server from holding up the boot. `x-systemd.automount` changes when a mount appears and can hide an unreachable server until first access, so it is left to the host that wants it. The `docker` role's `docker_stop_at_shutdown` relies on the same `remote-fs.target` ordering.
- `--check` is the supported preview; a play-level `check_mode: true` is not supported. `apt` and the fstab edit both report what would change.
- Idempotent: yes.
+8
View File
@@ -0,0 +1,8 @@
---
# Each entry: src (server:/export) and path (absolute mount point) are required; opts falls back
# to nfs_client_default_opts; state is present (default) or absent.
nfs_client_mounts: []
# _netdev orders the mount after the network and puts it in remote-fs.target; nofail keeps an
# unreachable server from holding up the boot. x-systemd.automount is left to the host that wants it.
nfs_client_default_opts: "_netdev,nofail"
+7
View File
@@ -0,0 +1,7 @@
---
# systemd builds a mount unit from each fstab line only when it reloads, so the reload is what
# makes a changed line known to systemd. It mounts nothing.
- name: Reload systemd for the nfs_client fstab entries
become: true
ansible.builtin.systemd_service:
daemon_reload: true
+57
View File
@@ -0,0 +1,57 @@
---
argument_specs:
main:
short_description: Install the NFS client and manage NFS entries in /etc/fstab
description:
- >-
Asserts a Debian-family host, installs C(nfs-common), creates each mount point of a C(present) entry without
owner, group or mode, writes or removes the entry's line in C(/etc/fstab), and reloads systemd after a change
so that the mount unit is generated now. Nothing is mounted.
- >-
It never mounts or unmounts anything. An C(absent) entry only loses its fstab line: the share stays mounted
until it is unmounted or the host reboots, and the mount point is not removed. Needs gathered facts.
options:
nfs_client_mounts:
type: list
elements: dict
default: []
description:
- >-
The NFS mounts to manage. Each mount point may appear once. With the default (no entries) only the client
package is installed.
options:
src:
type: str
required: true
description:
- The export as C(server:/export), one word without spaces.
path:
type: str
required: true
description:
- >-
The mount point: an absolute path without spaces, not C(/) and without a trailing slash. Created, when
the entry is C(present), with no owner, group or mode.
opts:
type: str
description:
- >-
The fstab options, one comma-separated word without spaces. Falls back to C(nfs_client_default_opts)
when left out or empty. Put the NFS version here, for example C(vers=4.2).
state:
type: str
default: present
choices: [present, absent]
description:
- >-
C(present) writes the fstab line. C(absent) removes it and nothing else. The role has no C(mounted),
C(unmounted) or C(remounted): mounting is left to systemd, so that a mount made from a play running in a
private mount namespace (a hardened sshd unit) cannot go unseen by systemd and by containers.
nfs_client_default_opts:
type: str
default: "_netdev,nofail"
description:
- >-
Options for an entry that sets none. C(_netdev) orders the mount after the network and puts it in
C(remote-fs.target); C(nofail) keeps an unreachable server from holding up the boot.
C(x-systemd.automount) is not in the default.
+18
View File
@@ -0,0 +1,18 @@
---
galaxy_info:
role_name: nfs_client
namespace: mortis
author: Dragonish
license: GPL-3.0-or-later
description: Install the NFS client and manage NFS mount entries in /etc/fstab, without mounting anything.
min_ansible_version: "2.22"
platforms:
- name: Ubuntu
versions:
- noble
- resolute
galaxy_tags:
- nfs
- fstab
- storage
dependencies: []
@@ -0,0 +1,7 @@
---
# The mounts come from molecule.yml.
- name: Converge
hosts: all
gather_facts: true
roles:
- role: mortis.kamino.nfs_client
@@ -0,0 +1,75 @@
---
# 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. Needs the Ubuntu mirrors: the role installs nfs-common. The
# containers run systemd as PID 1 with a writable cgroup, so a daemon-reload builds mount units
# from /etc/fstab; no privileged mode. Nothing is ever mounted: the server below does not exist.
driver:
name: docker
platforms:
- name: ${KAMINO_RUN_ID:-local}-nfs-client-noble
labels:
net.rkdr.mortis.molecule-run: "${KAMINO_RUN_ID:-local}"
image: ${MOLECULE_IMAGE}
pre_build_image: true
pull: true
command: /sbin/init
cgroupns_mode: host
volumes:
- /sys/fs/cgroup:/sys/fs/cgroup:rw
tmpfs:
- /run
- /run/lock
security_opts:
- apparmor=unconfined
- name: ${KAMINO_RUN_ID:-local}-nfs-client-resolute
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
security_opts:
- apparmor=unconfined
provisioner:
name: ansible
# One source for every play, so the converge and the plays in verify.yml start from the same
# valid input: a default-options mount, one with its own options, one to remove (prepare.yml
# seeds its line), and /mnt/data, whose seeded line has another server and must be replaced.
inventory:
group_vars:
all:
nfs_client_mounts:
- src: nas.example:/export/data
path: /mnt/data
- src: nas.example:/export/media
path: /mnt/media
opts: _netdev,nofail,ro,vers=4.2
- src: nas.example:/export/old
path: /mnt/old
state: absent
verifier:
name: ansible
scenario:
# molecule's default sequence minus both destroys (scripts/run_molecule_scenarios.sh removes the
# containers as soon as this scenario ends; after a local run, run `molecule destroy` yourself),
# plus a check before the converge (fresh host) and one after it (configured host).
test_sequence:
- dependency
- cleanup
- syntax
- create
- prepare
- check
- converge
- check
- idempotence
- side_effect
- verify
- cleanup
@@ -0,0 +1,43 @@
---
# The state a host has before the role runs: a line for /mnt/data that names another server (the
# role must replace it, once) and a line and a mount point for /mnt/old, the entry the converge
# removes. The file in /mnt/old shows that removing the line leaves the directory alone.
- name: Prepare
hosts: all
gather_facts: false
tasks:
# The image ships without apt lists, and --check does not refresh them, so without this the
# fresh-host check finds no nfs-common to install.
- name: Refresh the apt cache
ansible.builtin.apt:
update_cache: true
- name: Seed the fstab lines
ansible.builtin.lineinfile:
path: /etc/fstab
line: "{{ item }}"
create: true
mode: "0644"
loop:
- old-nas.example:/export/data /mnt/data nfs defaults 0 0
- nas.example:/export/old /mnt/old nfs _netdev,nofail 0 0
- name: Create the mount point that the converge leaves alone
ansible.builtin.file:
path: /mnt/old
state: directory
mode: "0750"
- name: Put a file in it
ansible.builtin.copy:
content: kept
dest: /mnt/old/keep
mode: "0644"
# An existing mount point of a present entry: the role must leave its owner and mode alone.
- name: Create a mount point with an owner and a mode of its own
ansible.builtin.file:
path: /mnt/media
state: directory
owner: daemon
mode: "0710"
@@ -0,0 +1,21 @@
---
# One failing run: includes the role with the inputs the caller sets on the include, and asserts
# that the expected message, not something else, stopped it. Input: nfs_client_test_case (name,
# expect).
- name: "Run the role, case {{ nfs_client_test_case.name }}"
block:
- name: "Include the role, case {{ nfs_client_test_case.name }}"
ansible.builtin.include_role:
name: mortis.kamino.nfs_client
# Only reached when the include returned. The message must not contain the expected
# text, so the rescue below cannot mistake it for the failure under test.
- name: "Fail because the include returned, case {{ nfs_client_test_case.name }}"
ansible.builtin.fail:
msg: The role accepted the input
rescue:
- name: "The expected failure stopped the run, case {{ nfs_client_test_case.name }}"
ansible.builtin.assert:
that: nfs_client_test_case.expect in (ansible_failed_result.msg | default(''))
fail_msg: "Expected '{{ nfs_client_test_case.expect }}', got: {{ ansible_failed_result.msg | default('') }}"
quiet: true
@@ -0,0 +1,247 @@
---
# The refusals below stop in validation, before any task that changes a host, so they need no
# container: they run once, on the controller, in check mode so that a regressed guard cannot
# change it.
#
# Runs first, before any play gathers facts: the role refuses a host it cannot identify as
# Debian-family, before any change.
- name: Refuse a host without facts
hosts: localhost
connection: local
check_mode: true
gather_facts: false
tasks:
- name: Run the role without gathered facts
ansible.builtin.include_tasks: tasks/failed_run.yml
vars:
nfs_client_test_case:
name: no-facts
expect: nfs_client supports Debian-family hosts only
# Negative tests: each validation stops the role before any change, with its own message. The
# inputs replace the converge's mounts for one include only.
- name: Refuse invalid input
hosts: localhost
connection: local
check_mode: true
gather_facts: true
tasks:
- name: Refuse a state the role does not have
ansible.builtin.include_tasks: tasks/failed_run.yml
vars:
nfs_client_mounts:
- {src: "nas.example:/export/data", path: /mnt/data, state: mounted}
nfs_client_test_case:
name: state-mounted
expect: "value of state must be one of: present, absent, got: mounted"
- name: Refuse remounted
ansible.builtin.include_tasks: tasks/failed_run.yml
vars:
nfs_client_mounts:
- {src: "nas.example:/export/data", path: /mnt/data, state: remounted}
nfs_client_test_case:
name: state-remounted
expect: "value of state must be one of: present, absent, got: remounted"
- name: Refuse an entry without a src
ansible.builtin.include_tasks: tasks/failed_run.yml
vars:
nfs_client_mounts:
- {path: /mnt/data}
nfs_client_test_case:
name: src-missing
expect: "missing required arguments: src"
- name: Refuse an empty src
ansible.builtin.include_tasks: tasks/failed_run.yml
vars:
nfs_client_mounts:
- {src: "", path: /mnt/data}
nfs_client_test_case:
name: src-empty
expect: nfs_client_mounts src must be one word of the form server:/export
- name: Refuse a src without an export
ansible.builtin.include_tasks: tasks/failed_run.yml
vars:
nfs_client_mounts:
- {src: nas.example, path: /mnt/data}
nfs_client_test_case:
name: src-no-export
expect: nfs_client_mounts src must be one word of the form server:/export
- name: Refuse a src with a space after the export
ansible.builtin.include_tasks: tasks/failed_run.yml
vars:
nfs_client_mounts:
- {src: "nas.example:/export/my data", path: /mnt/data}
nfs_client_test_case:
name: src-space
expect: nfs_client_mounts src must be one word of the form server:/export
- name: Refuse a mount point with a space
ansible.builtin.include_tasks: tasks/failed_run.yml
vars:
nfs_client_mounts:
- {src: "nas.example:/export/data", path: "/mnt/my data"}
nfs_client_test_case:
name: path-space
expect: nfs_client_mounts path must be an absolute path
- name: Refuse a relative mount point
ansible.builtin.include_tasks: tasks/failed_run.yml
vars:
nfs_client_mounts:
- {src: "nas.example:/export/data", path: mnt/data}
nfs_client_test_case:
name: path-relative
expect: nfs_client_mounts path must be an absolute path
- name: Refuse the root as a mount point
ansible.builtin.include_tasks: tasks/failed_run.yml
vars:
nfs_client_mounts:
- {src: "nas.example:/export/data", path: /}
nfs_client_test_case:
name: path-root
expect: nfs_client_mounts path must be an absolute path
- name: Refuse a trailing slash
ansible.builtin.include_tasks: tasks/failed_run.yml
vars:
nfs_client_mounts:
- {src: "nas.example:/export/data", path: /mnt/data/}
nfs_client_test_case:
name: path-trailing-slash
expect: nfs_client_mounts path must be an absolute path
- name: Refuse options with a space
ansible.builtin.include_tasks: tasks/failed_run.yml
vars:
nfs_client_mounts:
- {src: "nas.example:/export/data", path: /mnt/data, opts: "ro, nofail"}
nfs_client_test_case:
name: opts-space
expect: nfs_client_mounts options must be a non-empty comma-separated word
- name: Refuse an entry with no options when the default is empty
ansible.builtin.include_tasks: tasks/failed_run.yml
vars:
nfs_client_default_opts: ""
nfs_client_mounts:
- {src: "nas.example:/export/data", path: /mnt/data}
nfs_client_test_case:
name: opts-empty
expect: nfs_client_mounts options must be a non-empty comma-separated word
- name: Refuse the same mount point twice
ansible.builtin.include_tasks: tasks/failed_run.yml
vars:
nfs_client_mounts:
- {src: "nas.example:/export/data", path: /mnt/data}
- {src: "nas.example:/export/other", path: /mnt/data}
nfs_client_test_case:
name: duplicate-path
expect: nfs_client_mounts lists the same path twice
- name: Verify the host
hosts: all
gather_facts: true
tasks:
- name: Read the installed packages
ansible.builtin.package_facts:
manager: apt
- name: The client package is installed
ansible.builtin.assert:
that:
- "'nfs-common' in ansible_facts.packages"
quiet: true
- name: Read fstab
ansible.builtin.slurp:
src: /etc/fstab
register: nfs_client_test_fstab
# Each line split into its six fields, so the assertions do not depend on the spacing the
# module writes.
- name: Split the fstab lines into fields
ansible.builtin.set_fact:
nfs_client_test_rows: >-
{{ (nfs_client_test_fstab.content | b64decode).splitlines()
| reject('match', '^#')
| map('split')
| reject('equalto', [])
| list }}
# The seeded line for /mnt/data named another server and the default options: the role
# replaces it, so exactly one line is left for the path.
- name: The default-options entry replaced the seeded line
ansible.builtin.assert:
that:
- "['nas.example:/export/data', '/mnt/data', 'nfs', '_netdev,nofail', '0', '0'] in nfs_client_test_rows"
- nfs_client_test_rows | selectattr('1', 'eq', '/mnt/data') | list | length == 1
quiet: true
- name: The entry with its own options keeps them
ansible.builtin.assert:
that:
- "['nas.example:/export/media', '/mnt/media', 'nfs', '_netdev,nofail,ro,vers=4.2', '0', '0'] in nfs_client_test_rows"
quiet: true
- name: The absent entry lost its line
ansible.builtin.assert:
that:
- nfs_client_test_rows | selectattr('1', 'eq', '/mnt/old') | list | length == 0
quiet: true
- name: Stat the mount points
ansible.builtin.stat:
path: "{{ item }}"
loop: [/mnt/data, /mnt/media, /mnt/old, /mnt/old/keep]
register: nfs_client_test_stat
# prepare.yml gave /mnt/media an owner and a mode and /mnt/old a mode of its own. The role
# created /mnt/data (a new directory is root's) and changed neither of the others, and the
# removed entry's directory and the file in it are untouched.
- name: The mount points exist, keep their owner and mode, and the removed entry's directory is intact
ansible.builtin.assert:
that:
- nfs_client_test_stat.results | map(attribute='stat.exists') | min
- nfs_client_test_stat.results[0].stat.isdir
- nfs_client_test_stat.results[0].stat.pw_name == 'root'
- nfs_client_test_stat.results[1].stat.pw_name == 'daemon'
- nfs_client_test_stat.results[1].stat.mode == '0710'
- nfs_client_test_stat.results[2].stat.mode == '0750'
quiet: true
- name: Read what is mounted
ansible.builtin.slurp:
src: /proc/mounts
register: nfs_client_test_mounts
- name: Nothing was mounted
ansible.builtin.assert:
that:
- "'/mnt/data' not in (nfs_client_test_mounts.content | b64decode)"
- "'/mnt/media' not in (nfs_client_test_mounts.content | b64decode)"
quiet: true
# The daemon-reload is what turns an fstab line into a unit; the generator ran again, so the
# new lines have a unit and the removed one has none. systemctl and not the systemd module,
# which fails on a unit that is not loaded, the very state asserted for the removed entry.
- name: Ask systemd about the mount units # noqa: command-instead-of-module
ansible.builtin.command: "systemctl show --property=LoadState --value {{ item }}"
loop: [mnt-data.mount, mnt-media.mount, mnt-old.mount]
register: nfs_client_test_units
changed_when: false
check_mode: false
- name: Systemd knows the new entries and not the removed one
ansible.builtin.assert:
that:
- nfs_client_test_units.results[0].stdout == 'loaded'
- nfs_client_test_units.results[1].stdout == 'loaded'
- nfs_client_test_units.results[2].stdout == 'not-found'
quiet: true
+48
View File
@@ -0,0 +1,48 @@
---
# Validation first, under always, so a bad input fails before any change whatever tags the run
# selects.
- name: Validate the role inputs
ansible.builtin.import_tasks: validate.yml
tags: always
- name: Install the NFS client package
become: true
ansible.builtin.apt:
name: "{{ __nfs_client_package }}"
state: present
update_cache: true
cache_valid_time: 3600
tags: [nfs_client, install]
# No owner, group or mode: once a share is mounted the path is the export root, and a chown or
# chmod there changes the permissions on the NFS server.
- name: Create the mount points # noqa: risky-file-permissions
become: true
ansible.builtin.file:
path: "{{ item.path }}"
state: directory
loop: "{{ __nfs_client_entries | selectattr('state', 'eq', 'present') | list }}"
loop_control:
label: "{{ item.path }}"
tags: [nfs_client, configure]
# present writes the fstab line and mounts nothing. An absent entry only loses its line:
# ansible.posix.mount's own absent would also unmount the share and delete the mount point.
- name: Manage the fstab entries
become: true
ansible.posix.mount:
src: "{{ item.src }}"
path: "{{ item.path }}"
fstype: nfs
opts: "{{ item.opts }}"
dump: "0"
passno: "0"
state: "{{ 'present' if item.state == 'present' else 'absent_from_fstab' }}"
loop: "{{ __nfs_client_entries }}"
loop_control:
label: "{{ item.path }}"
notify: Reload systemd for the nfs_client fstab entries
tags: [nfs_client, configure]
- name: Flush handlers
ansible.builtin.meta: flush_handlers
+73
View File
@@ -0,0 +1,73 @@
---
# Input checks. Imported first in main.yml with tags: always, so a bad input fails before any
# change. The argument spec (types, choices, required keys) runs before this file; the rules
# below are the ones between values. Each assert covers the whole list, not one item per loop
# pass, so the failure message is the assert's own. fstab fields are split on whitespace, so
# "one word" is tested with split rather than a pattern.
# The package and the fstab format are Debian's, and the role reads gathered facts.
- name: Require a Debian-family host
ansible.builtin.assert:
that:
- ansible_facts['os_family'] | default('') == 'Debian'
fail_msg: >-
nfs_client supports Debian-family hosts only (found: {{ ansible_facts['os_family'] | default('no gathered facts') }}).
The role reads gathered facts, so run it in a play that gathers them.
quiet: true
# Fact-computing tasks that the checks below read. A statement block in one template would leave
# whitespace around the result and make it a string instead of a list, so the list is built by
# appending one entry per pass.
- name: Start the resolved entries
ansible.builtin.set_fact:
__nfs_client_entries: []
# Defaults of the suboptions are applied here: the spec's suboption defaults are documentation.
- name: Resolve the entries
ansible.builtin.set_fact:
__nfs_client_entries: >-
{{ __nfs_client_entries + [{
'src': item.src | trim,
'path': item.path,
'opts': (item.opts | default('', true) | trim) or (nfs_client_default_opts | trim),
'state': item.state | default('present', true)
}] }}
loop: "{{ nfs_client_mounts }}"
loop_control:
label: "{{ item.path }}"
- name: Require a server and an export in every src
ansible.builtin.assert:
that:
- __nfs_client_entries | map(attribute='src') | map('split') | map('length') | reject('eq', 1) | list | length == 0
- __nfs_client_entries | map(attribute='src') | reject('search', '^[^ ]+:/') | list | length == 0
fail_msg: >-
nfs_client_mounts src must be one word of the form server:/export, without spaces
(offending: {{ __nfs_client_entries | map(attribute='src') | reject('search', '^[^ ]+:/') | list }}).
quiet: true
- name: Require an absolute mount point that is not the root
ansible.builtin.assert:
that:
- __nfs_client_entries | map(attribute='path') | map('split') | map('length') | reject('eq', 1) | list | length == 0
- __nfs_client_entries | map(attribute='path') | reject('search', '^/[^ ]*[^/ ]$') | list | length == 0
fail_msg: >-
nfs_client_mounts path must be an absolute path without spaces, not the root and without a trailing slash
(offending: {{ __nfs_client_entries | map(attribute='path') | reject('search', '^/[^ ]*[^/ ]$') | list }}).
quiet: true
- name: Require options that fit one fstab field
ansible.builtin.assert:
that:
- __nfs_client_entries | map(attribute='opts') | map('split') | map('length') | reject('eq', 1) | list | length == 0
fail_msg: >-
nfs_client_mounts options must be a non-empty comma-separated word without spaces, from the entry's opts or, when
that is empty, from nfs_client_default_opts.
quiet: true
- name: Require one entry per mount point
ansible.builtin.assert:
that:
- __nfs_client_entries | map(attribute='path') | unique | list | length == __nfs_client_entries | length
fail_msg: nfs_client_mounts lists the same path twice; each mount point may appear once.
quiet: true
+3
View File
@@ -0,0 +1,3 @@
---
# Constant, not an input: the package that carries mount.nfs on Debian and Ubuntu.
__nfs_client_package: nfs-common
+1 -1
View File
@@ -58,7 +58,7 @@ The input asserts carry `always` (and `assert`), so they run whatever tags are s
## Tests
The `default` molecule scenario runs in CI only, on two platforms: `${MOLECULE_IMAGE}` (Ubuntu 24.04) and `${MOLECULE_IMAGE_2604}` (Ubuntu 26.04). It replaces the upstream repository with a local stub whose installer only logs its arguments and creates the database file, so it tests the merge, the asserts, the user, the configuration directory and the rendered `pihole.toml` (owner, group and mode), the clone's checked-out version, the installer sequence (install once, then reconfigure from the handler) and idempotence, not Pi-hole itself: no pihole-FTL service runs, so that the service loaded the configuration is not verified. It runs `check` before the converge (a first-run preview) and after the idempotence run. Negative tests in `verify.yml` cover a host without Ubuntu facts, a missing `pihole_web_password`, an unset interface, empty upstreams, a non-string password and the placeholder password.
The `default` molecule scenario runs in CI only, on two platforms: `${MOLECULE_IMAGE}` (Ubuntu 24.04) and `${MOLECULE_IMAGE_2604}` (Ubuntu 26.04). It replaces the upstream repository with a local stub whose installer only logs its arguments and creates the database file, so it tests the merge, the asserts, the user, the configuration directory and the rendered `pihole.toml` (owner, group and mode), the clone's checked-out version, the installer sequence (install once, then reconfigure from the handler) and idempotence, not Pi-hole itself: no pihole-FTL service runs, so that the service loaded the configuration is not verified. It runs `check` before the converge (a fresh host) and after it (a configured host). Negative tests in `verify.yml` cover a host without Ubuntu facts, a missing `pihole_web_password`, an unset interface, empty upstreams, a non-string password and the placeholder password.
## Notes
+2 -2
View File
@@ -63,7 +63,7 @@ verifier:
scenario:
# molecule's default sequence minus both destroys (scripts/run_molecule_scenarios.sh removes the
# containers as soon as this scenario ends; after a local run, run `molecule destroy` yourself),
# plus two check steps: one before the converge (first-run preview), one after the idempotence run.
# plus a check before the converge (fresh host) and one after it (configured host).
test_sequence:
- dependency
- cleanup
@@ -72,8 +72,8 @@ scenario:
- prepare
- check
- converge
- idempotence
- check
- idempotence
- side_effect
- verify
- cleanup
+2 -2
View File
@@ -98,8 +98,8 @@
- name: The user is a system account without a login shell
ansible.builtin.assert:
that:
- getent_passwd.pihole[5] == '/usr/sbin/nologin'
- getent_passwd.pihole[1] | int < 1000
- ansible_facts['getent_passwd'].pihole[5] == '/usr/sbin/nologin'
- ansible_facts['getent_passwd'].pihole[1] | int < 1000
quiet: true
# Neither check run (before and after the converge) ran the installer or the handler.
+1 -1
View File
@@ -92,7 +92,7 @@ The input validation (`tasks/validate.yml`) carries `always`, so it runs whateve
## Tests
The `default` molecule scenario runs in CI on Ubuntu 24.04 (noble), the `molecule-ubuntu2404` image, which stands in for the Proxmox node. The API lifecycle (detect, create, update, resize, start, stop, delete and the restarts) is not exercised: there is no Proxmox API in the scenario. The converge includes the internal task files `main.yml` runs on the node side, in its order (`validate`, `firewall`, `raw_config`), with `pve_lxc_state: stopped`, under which the role never restarts the container. Prepare seeds a container config with stale `lxc.*` lines, blockinfile markers and a snapshot section, and backup copies of two containers' configs. Verify checks the reconciled config byte for byte (Proxmox's lines kept in order, the desired `lxc.*` lines after them, the snapshot section untouched), the rendered firewall file, and that only this container's backups were removed. It runs `check` before the converge and after the idempotence run. Negative tests cover a state outside the spec, missing API credentials and a missing network prefix through `main`, and raw config given as a string, outside the `lxc.` namespace or with two lines in one item, a malformed firewall rule and an unknown policy through `validate`; a run with `pve_lxc_manage_lifecycle: false` checks the presence facts. No Proxmox service runs, so pmxcfs's handling of the files and `pve-firewall` loading the rules are not verified.
The `default` molecule scenario runs in CI on Ubuntu 24.04 (noble), the `molecule-ubuntu2404` image, which stands in for the Proxmox node. The API lifecycle (detect, create, update, resize, start, stop, delete and the restarts) is not exercised: there is no Proxmox API in the scenario. The converge includes the internal task files `main.yml` runs on the node side, in its order (`validate`, `firewall`, `raw_config`), with `pve_lxc_state: stopped`, under which the role never restarts the container. Prepare seeds a container config with stale `lxc.*` lines, blockinfile markers and a snapshot section, and backup copies of two containers' configs. Verify checks the reconciled config byte for byte (Proxmox's lines kept in order, the desired `lxc.*` lines after them, the snapshot section untouched), the rendered firewall file, and that only this container's backups were removed. It runs `check` before the converge (a fresh host) and after it (a configured host). Negative tests cover a state outside the spec, missing API credentials and a missing network prefix through `main`, and raw config given as a string, outside the `lxc.` namespace or with two lines in one item, a malformed firewall rule and an unknown policy through `validate`; a run with `pve_lxc_manage_lifecycle: false` checks the presence facts. No Proxmox service runs, so pmxcfs's handling of the files and `pve-firewall` loading the rules are not verified.
## Notes
+2 -2
View File
@@ -57,7 +57,7 @@ verifier:
scenario:
# molecule's default sequence minus both destroys (scripts/run_molecule_scenarios.sh removes the
# container as soon as this scenario ends; after a local run, run `molecule destroy` yourself),
# plus two check steps: one before the converge (first-run preview), one after the idempotence run.
# plus a check before the converge (fresh host) and one after it (configured host).
test_sequence:
- dependency
- cleanup
@@ -66,8 +66,8 @@ scenario:
- prepare
- check
- converge
- idempotence
- check
- idempotence
- side_effect
- verify
- cleanup
+4 -3
View File
@@ -59,10 +59,10 @@ The role defines none.
## Tests
The scenario `molecule/default/` runs in CI only, on two platforms: `${MOLECULE_IMAGE}` (Ubuntu 24.04) and `${MOLECULE_IMAGE_2604}` (Ubuntu 26.04). Both images ship openssh-server. The sequence runs converge, idempotence and verify; it has no check-mode step.
The scenario `molecule/default/` runs in CI only, on two platforms: `${MOLECULE_IMAGE}` (Ubuntu 24.04) and `${MOLECULE_IMAGE_2604}` (Ubuntu 26.04). Both images ship openssh-server. It runs `check` before the converge (a fresh host) and after it (a configured host).
- Converge applies the `ubuntu_lxc` profile. It then loads the defaults through `tasks_from: validate.yml` without changing the host: every profile (`pve`, `ubuntu_lxc`, `ubuntu_vm`) passes validation and keeps its root login policy and key algorithms, a consumer `sshd_settings` override wins over the profile, and the `pve` guard accepts each value that allows root key login.
- Verify first checks the refusals: a run without `sshd_profile`, `PubkeyAuthentication no` (lock-out), a `pve` profile with `PermitRootLogin no` or `forced-commands-only`, a `pve` profile without `rsa-sha2-512`, SHA-1 `ssh-rsa`, and an unknown profile. Each but the missing profile is matched on its message.
- Converge applies the `ubuntu_lxc` profile. Verify first loads the defaults on the controller through `tasks_from: validate.yml`: every profile (`pve`, `ubuntu_lxc`, `ubuntu_vm`) passes validation and keeps its root login policy and key algorithms, a consumer `sshd_settings` override wins over the profile, and the `pve` guard accepts each value that allows root key login.
- Verify then checks the refusals: a run without `sshd_profile`, `PubkeyAuthentication no` (lock-out), a `pve` profile with `PermitRootLogin no` or `forced-commands-only`, a `pve` profile without `rsa-sha2-512`, SHA-1 `ssh-rsa`, and an unknown profile. Each but the missing profile is matched on its message.
- Verify then checks the converged host: the drop-in exists, `sshd -t` passes, the `ssh` unit is active, and `sshd -T` shows key login on and password and root login off.
- The `pve` profile is checked by rendering its drop-in to a scratch file and parsing it with `sshd -T -f`: root logs in with keys only and passwords stay off.
@@ -71,6 +71,7 @@ Not covered: the `pve` profile is not converged and no SSH login is attempted.
## Notes
- Idempotent: yes.
- Check mode: `--check` is the supported preview; a play-level `check_mode: true` is not supported.
- `tasks/validate.yml` fails the play for an unknown profile, an empty merged result, `PasswordAuthentication no` without `PubkeyAuthentication yes`, a `pve` profile whose `PermitRootLogin` does not allow root key login (`prohibit-password`, its alias `without-password`, or `yes`; `no` and `forced-commands-only` are refused), a `pve` profile whose `HostKeyAlgorithms` or `PubkeyAcceptedAlgorithms` lacks `rsa-sha2-512` (the `+`/`-`/`^` list forms are not parsed and fail; write the full list), and any profile that lists SHA-1 `ssh-rsa` in either.
- The drop-in is installed with `validate: sshd -t -f %s`. The handler named `Restart SSH` reloads the service, and is skipped in check mode or when `sshd_reload` is false.
- `ssh-keygen -A` runs on every play and always reports ok.
-70
View File
@@ -7,73 +7,3 @@
ansible_user: root
roles:
- role: mortis.kamino.sshd
# The plays below only load the role's defaults and run validate.yml, which changes nothing
# on the container. They cover the profiles the converge above cannot run and the values
# the guards accept.
- name: Every profile passes validation and keeps its root login policy
hosts: all
gather_facts: false
tasks:
- name: Validate each profile
ansible.builtin.include_role:
name: mortis.kamino.sshd
tasks_from: validate.yml
public: true
vars:
sshd_profile: "{{ item }}"
loop: [pve, ubuntu_lxc, ubuntu_vm]
- name: Assert the profile data
ansible.builtin.assert:
that:
- sshd_profiles.pve.PermitRootLogin == "prohibit-password"
- sshd_profiles.ubuntu_lxc.PermitRootLogin == "no"
- sshd_profiles.ubuntu_vm.PermitRootLogin == "no"
quiet: true
# Proxmox cluster SSH needs RSA with SHA-2, never SHA-1 ssh-rsa; the others stay ed25519 only.
- name: Assert the key algorithms per profile
ansible.builtin.assert:
that:
- sshd_profiles.pve.HostKeyAlgorithms == "ssh-ed25519,rsa-sha2-512,rsa-sha2-256"
- sshd_profiles.pve.PubkeyAcceptedAlgorithms == "ssh-ed25519,rsa-sha2-512,rsa-sha2-256"
- sshd_settings_defaults.HostKeyAlgorithms == "ssh-ed25519"
- sshd_settings_defaults.PubkeyAcceptedAlgorithms == "ssh-ed25519"
- "'HostKeyAlgorithms' not in sshd_profiles.ubuntu_lxc"
- "'HostKeyAlgorithms' not in sshd_profiles.ubuntu_vm"
quiet: true
# Play vars outrank the role defaults, so the override reaches the merged settings.
- name: A consumer override wins and keeps the rest
hosts: all
gather_facts: false
vars:
sshd_profile: ubuntu_vm
sshd_settings:
MaxAuthTries: "5"
tasks:
- name: Load the role defaults
ansible.builtin.include_role:
name: mortis.kamino.sshd
tasks_from: validate.yml
public: true
- name: Assert the override
ansible.builtin.assert:
that:
- sshd_settings_effective.MaxAuthTries == "5"
- sshd_settings_effective.PermitRootLogin == "no"
- sshd_settings_effective.PubkeyAuthentication == "yes"
quiet: true
- name: The Proxmox guard accepts every value that allows root key login
hosts: all
gather_facts: false
tasks:
- name: Validate the pve profile with each accepted value
ansible.builtin.include_role:
name: mortis.kamino.sshd
tasks_from: validate.yml
vars:
sshd_profile: pve
sshd_settings:
PermitRootLogin: "{{ item }}"
loop: [prohibit-password, without-password, "yes", Prohibit-Password]
+3
View File
@@ -47,13 +47,16 @@ verifier:
scenario:
# molecule's default sequence minus both destroys: scripts/run_molecule_scenarios.sh removes the
# container as soon as this scenario ends. After a local run, run `molecule destroy` yourself.
# A check runs before the converge (fresh host) and after it (configured host).
test_sequence:
- dependency
- cleanup
- syntax
- create
- prepare
- check
- converge
- check
- idempotence
- side_effect
- verify
+78 -1
View File
@@ -1,6 +1,83 @@
---
# The plays below only load the role's defaults and run validate.yml, which needs no container,
# so they run once, on the controller, in check mode so that a regressed guard cannot change it.
# They cover the profiles converge.yml cannot run and the values the guards accept.
- name: Every profile passes validation and keeps its root login policy
hosts: localhost
connection: local
check_mode: true
gather_facts: false
tasks:
- name: Validate each profile
ansible.builtin.include_role:
name: mortis.kamino.sshd
tasks_from: validate.yml
public: true
vars:
sshd_profile: "{{ item }}"
loop: [pve, ubuntu_lxc, ubuntu_vm]
- name: Assert the profile data
ansible.builtin.assert:
that:
- sshd_profiles.pve.PermitRootLogin == "prohibit-password"
- sshd_profiles.ubuntu_lxc.PermitRootLogin == "no"
- sshd_profiles.ubuntu_vm.PermitRootLogin == "no"
quiet: true
# Proxmox cluster SSH needs RSA with SHA-2, never SHA-1 ssh-rsa; the others stay ed25519 only.
- name: Assert the key algorithms per profile
ansible.builtin.assert:
that:
- sshd_profiles.pve.HostKeyAlgorithms == "ssh-ed25519,rsa-sha2-512,rsa-sha2-256"
- sshd_profiles.pve.PubkeyAcceptedAlgorithms == "ssh-ed25519,rsa-sha2-512,rsa-sha2-256"
- sshd_settings_defaults.HostKeyAlgorithms == "ssh-ed25519"
- sshd_settings_defaults.PubkeyAcceptedAlgorithms == "ssh-ed25519"
- "'HostKeyAlgorithms' not in sshd_profiles.ubuntu_lxc"
- "'HostKeyAlgorithms' not in sshd_profiles.ubuntu_vm"
quiet: true
# Play vars outrank the role defaults, so the override reaches the merged settings.
- name: A consumer override wins and keeps the rest
hosts: localhost
connection: local
check_mode: true
gather_facts: false
vars:
sshd_profile: ubuntu_vm
sshd_settings:
MaxAuthTries: "5"
tasks:
- name: Load the role defaults
ansible.builtin.include_role:
name: mortis.kamino.sshd
tasks_from: validate.yml
public: true
- name: Assert the override
ansible.builtin.assert:
that:
- sshd_settings_effective.MaxAuthTries == "5"
- sshd_settings_effective.PermitRootLogin == "no"
- sshd_settings_effective.PubkeyAuthentication == "yes"
quiet: true
- name: The Proxmox guard accepts every value that allows root key login
hosts: localhost
connection: local
check_mode: true
gather_facts: false
tasks:
- name: Validate the pve profile with each accepted value
ansible.builtin.include_role:
name: mortis.kamino.sshd
tasks_from: validate.yml
vars:
sshd_profile: pve
sshd_settings:
PermitRootLogin: "{{ item }}"
loop: [prohibit-password, without-password, "yes", Prohibit-Password]
# The refusal cases: here, not in converge.yml, because idempotence reruns converge. Each
# fails in validate.yml; they run first, so the assertions below also show the host unchanged.
# fails in validate.yml; they run before the host checks, so the assertions below also show the
# host unchanged.
# A play without sshd_profile: the role must refuse it. The block proves the refusal
# (not its wording).
+43 -8
View File
@@ -12,7 +12,7 @@ The role targets Ubuntu guests (the `ubuntu_lxc` and `ubuntu_vm` profiles) and P
## Requirements and run order
- Facts must be gathered (`gather_facts: true`); `reboot.yml` reads `ansible_os_family`.
- Facts must be gathered (`gather_facts: true`); `reboot.yml` reads `ansible_facts['os_family']`.
- `system_baseline_system_type` is required and has no default (the role does not read a global such as `system_type`; map it in the inventory). Valid values: `ubuntu_lxc`, `ubuntu_vm` or `pve`.
- Use it by its fully qualified name, `mortis.kamino.system_baseline`.
- Collections: `community.general` (locale, timezone) and `ansible.posix` (sysctl, mount).
@@ -35,14 +35,17 @@ templating error instead of the role's own message.
| `system_baseline_profile` | derived | no | Active profile after overrides |
| `system_baseline_essential_packages` | from profile | no | Packages to install |
| `system_baseline_remove_packages` | from profile | no | Packages to purge when present |
| `system_baseline_extra_packages` | `[]` | no | Packages to install in addition to the resolved list; appends, see "Adding packages to a profile" |
| `system_baseline_extra_remove_packages` | `[]` | no | Packages to purge in addition to the resolved list; appends |
| `system_baseline_apt_periodic_settings` | from profile | no | Keys for `20auto-upgrades` |
| `system_baseline_apt_upgrade` | from profile | no | `safe` or `dist`: how the role upgrades packages (`pve`: `dist`, the Ubuntu profiles: `safe`); see "Apt upgrade mode" |
| `system_baseline_skip_upgrade_during_vzdump` | `false` | no | `pve` only: skip the apt upgrade while a vzdump backup is running on the node (see "Skipping the upgrade during a backup") |
| `system_baseline_unattended_upgrade_settings` | from profile | no | Keys for `50unattended-upgrades` |
| `system_baseline_unattended_upgrade_origins` | from profile | no | Pinned `Origins-Pattern` entries; `[]` keeps the distribution default (see below) |
| `system_baseline_unattended_upgrade_package_blacklist` | `[]` | no | Packages unattended-upgrades must not touch, as regular expressions (see below) |
| `system_baseline_sysctl_hardening` | from profile | no | List of `name` and `value` sysctl pairs |
| `system_baseline_secure_tmp_mounts` | from profile | no | Paths remounted as tmpfs with `noexec,nosuid,nodev` |
| `system_baseline_journal_max_use` | `200M` | no | Upper bound of the persistent journal (journald `SystemMaxUse`). |
| `system_baseline_journal_max_use` | `200M` | no | Upper bound of the persistent journal (journald `SystemMaxUse`): a number with an optional upper-case `B`, `K`, `M`, `G`, `T`, `P` or `E`, such as `1.5G`; a bare number is bytes. journald does not take `infinity`. Empty leaves the host alone and removes nothing a former run wrote (see "Leaving journald alone") |
| `system_baseline_tmux_autostart` | `false` | no | Attach interactive SSH logins to a tmux session (`ubuntu_lxc` and `ubuntu_vm` only) |
| `system_baseline_tmux_session` | `main` | no | Session name, `A-Za-z0-9_-`, up to 32 characters |
| `system_baseline_tmux_windows` | `[]` | no | `{name, command}` windows made when the session is created |
@@ -124,13 +127,16 @@ The two task files besides `main` are a supported interface, for a caller that d
## 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 installs packages from the Ubuntu mirrors, so the runner needs outbound network. The sequence runs prepare, converge, idempotence and verify; it has no check-mode step.
The scenario `molecule/default/` runs in CI only, on two platforms: `${MOLECULE_IMAGE}` (Ubuntu 24.04) and `${MOLECULE_IMAGE_2604}` (Ubuntu 26.04). It installs packages from the Ubuntu mirrors, so the runner needs outbound network. It runs `check` before the converge (a fresh host) and after it (a configured host).
- Converge first checks that the role refuses a bad input with its own message before any change: an unknown `system_baseline_system_type`, an unknown `system_baseline_apt_upgrade` (main flow and `update` entry point), a negative reboot throttle or a negative or boolean post-reboot delay (main flow and `reboot` entry point), a line break in `system_baseline_apt_daily_timeout`, and a bad package blacklist (a quote, a null item, a bare string).
- Converge then applies the `ubuntu_lxc` profile, with tmux autostart and `system_baseline_apt_daily_timeout: 1h`, and only resolves the `pve` and `ubuntu_vm` profiles and a consumer override, asserting the resolved inputs.
- Verify first checks, on the controller, that the role refuses a bad input with its own message before any change: an unknown `system_baseline_system_type`, an unknown `system_baseline_apt_upgrade` (main flow and `update` entry point), a negative reboot throttle or a negative or boolean post-reboot delay (main flow and `reboot` entry point), a line break in `system_baseline_apt_daily_timeout`, a bad `system_baseline_journal_max_use` (`infinity`, a lower-case unit, a unit with a trailing `B`, a line break, a number), and a bad package blacklist (a quote, a null item, a bare string).
- Converge applies the `ubuntu_lxc` profile, with tmux autostart and `system_baseline_apt_daily_timeout: 1h`. Verify only resolves the `pve` and `ubuntu_vm` profiles and a consumer override, on the controller, asserting the resolved inputs.
- Verify checks the installed and removed packages, the journal size cap, the apt settings in `20auto-upgrades` and `50unattended-upgrades`, the locale, and that systemd loaded the `apt-daily.service` timeout.
- Verify checks the tmux snippet: root-owned, valid shell, the session and quoted window command, no effect without a terminal, a session name or window command ending in a newline refused, and the file removed when autostart is off.
- Converge also checks that a bad `system_baseline_apt_tmpdir` (under `/tmp` or `/var/tmp`, relative, with `..`, empty) is refused in the main flow and in the `update` entry point. Verify reads `tasks/update.yml` and checks that the scratch directory is created with mode `0700`, that both apt tasks set `TMPDIR` to it, and that the connection is reset afterwards: the scenario skips the `update` tag, so the upgrade itself never runs there.
- Verify refuses bad items in `system_baseline_extra_packages` and `system_baseline_extra_remove_packages` (whitespace, a null, an empty string, a trailing minus, upper case, a bare string) and a package that one input installs and another purges; converge applies the `ubuntu_lxc` profile with `jq` as an extra package and `ed` as an extra removal; verify checks that `jq` is installed, `ed` is gone and the profile's packages are still there, and that an extra `tmux` installs the snippet where a flat list without it installs none.
- Verify also checks that a bad `system_baseline_apt_tmpdir` (under `/tmp` or `/var/tmp`, relative, with `..`, empty) is refused in the main flow and in the `update` entry point. It reads `tasks/update.yml` and checks that the scratch directory is created with mode `0700`, that both apt tasks set `TMPDIR` to it, and that the connection is reset afterwards: the scenario skips the `update` tag, so the upgrade itself never runs there.
- Verify runs the `update` entry point in check mode on the Ubuntu container with `system_baseline_system_type: pve` and a `pvesh` stub, in seven cases (a running, a finished or no vzdump task, the input off, `ubuntu_lxc`), and asserts the fact that decides the upgrade and that `pvesh` was run, with `--source active`, only when it should be. It does not assert that the apt task itself was skipped. The stub stands for the real answer, which no CI image has.
- Verify ends by running the role once with `system_baseline_journal_max_use: ""` after removing the drop-in, and asserts that no drop-in is written and that `systemd-journald` was not restarted.
- Verify runs the `reboot` entry point with `system_baseline_reboot_if_required: false`, without and with `/var/run/reboot-required`, and checks the fact and that the host did not reboot.
- The `pve` origins pin is applied to the Ubuntu container and read back with `apt-config dump`, then removed again. The package blacklist is written, read back as a list, left alone by a second run and removed by an empty list.
@@ -145,9 +151,23 @@ Not covered: Molecule skips `sysctl`, `secure_tmp`, `update` and `timezone` (no
- Policy lives in defaults, not `vars/`, so group_vars and host_vars can override it.
- `no_log` is not used: the role handles no secrets.
### Adding packages to a profile
`system_baseline_essential_packages` and `system_baseline_remove_packages` replace the profile's whole list, and so does a list inside `system_baseline_profile_overrides`. To add or drop a few packages and keep the profile's own, use the two extra lists, which append:
```yaml
system_baseline_extra_packages: [jq]
system_baseline_extra_remove_packages: [telnet]
```
- Each item is a Debian package name: lower-case letters, digits, `+`, `-` and `.`, two or more characters, starting with a letter or digit and not ending in `-` (apt reads a trailing minus as a removal). Anything else stops the run. Duplicates of the profile list are harmless.
- The role does not refresh an APT cache younger than an hour, so a package from a source you add just before the role (`ansible.builtin.deb822_repository` does not refresh) needs your own cache refresh first.
- An extra counts wherever the role looks for a package in the list: an extra `tmux` enables the tmux snippet and an extra `unattended-upgrades` the unattended-upgrades tasks, as a profile package does.
- A package that one input installs and another purges stops the run before any change: `system_baseline_extra_packages` against `system_baseline_remove_packages` or `system_baseline_extra_remove_packages`, and `system_baseline_extra_remove_packages` against `system_baseline_essential_packages`. The resolved lists are not checked against each other, so a consumer's own overlap there behaves as before.
### tmux on SSH login
With `system_baseline_tmux_autostart: true` an interactive SSH login attaches to the session `system_baseline_tmux_session` (created when missing), so a dropped connection loses nothing. The `ubuntu_lxc` and `ubuntu_vm` profiles install `tmux`; `pve` never gets the snippet.
With `system_baseline_tmux_autostart: true` an interactive SSH login attaches to the session `system_baseline_tmux_session` (created when missing), so a dropped connection loses nothing. The `ubuntu_lxc` and `ubuntu_vm` profiles install `tmux`; the `pve` profile has none, so it gets the snippet only if `system_baseline_extra_packages` adds `tmux`.
```yaml
system_baseline_tmux_autostart: true
@@ -157,7 +177,7 @@ system_baseline_tmux_windows:
```
- It is `/etc/profile.d/tmux-autostart.sh`. Every login shell reads that directory, so the snippet itself acts only for an interactive shell (`case $-`) with a terminal and an SSH connection, outside tmux, and without `~/.no-tmux`. `scp`, `sftp`, `ssh host command`, Ansible and `ssh -t host 'bash -lc cmd'` never trigger it. sshd's `ForceCommand` is not used: it applies to every session type and a broken tmux would lock all of them out. Users whose login shell is zsh or fish are not affected, because those shells do not read `/etc/profile.d`.
- The snippet is installed when autostart is on and the resolved package list contains `tmux` (the `ubuntu_lxc` and `ubuntu_vm` profiles). If you override `system_baseline_essential_packages` without it, nothing is installed.
- The snippet is installed when autostart is on and the packages to install contain `tmux`: the `ubuntu_lxc` and `ubuntu_vm` profiles have it, and `system_baseline_extra_packages` can add it. If you override `system_baseline_essential_packages` without it and add no extra `tmux`, nothing is installed.
- A failed attach (for example a client `TERM` such as `xterm-kitty` or `wezterm` without a terminfo entry on the host) prints a line and leaves a plain shell. Detaching (`Ctrl-b d`) ends the SSH connection, as `exit` would.
- Turn it off for one login with `ssh -t host bash` (a non-login shell does not read `/etc/profile.d`), for one user with `touch ~/.no-tmux`, and for the host by setting the variable to `false` and running the role (it removes the snippet).
- The windows are made when the session is created; a login that re-attaches adds none, so a change applies from the next new session. A window closes when its command exits. A window command runs with `sh -c` from the tmux server of the first login, before `~/.profile` is read, so it does not see `~/.local/bin` and other additions made there: use absolute paths.
@@ -195,6 +215,19 @@ The profile key `apt_upgrade` (`safe` or `dist`, resolved to `system_baseline_ap
- The `update` entry point follows the same input: it upgrades with `dist` when `system_baseline_system_type` is `pve`. Without a `system_baseline_system_type` (the entry point does not require one) it stays on `safe`.
- Only the apt upgrade changes. Autoremove and autoclean, the check-mode skip and unattended-upgrades are as before; the example blacklist below keeps unattended-upgrades away from the Proxmox packages.
### Skipping the upgrade during a backup
An upgrade of a Proxmox node can restart Proxmox services while a backup holds a snapshot of a guest. With `system_baseline_skip_upgrade_during_vzdump: true` and `system_baseline_system_type: pve`, the role runs `pvesh get /nodes/localhost/tasks --source active --limit 0` before the upgrade (`--source active` lists the running tasks; the default, `archive`, holds only finished ones). When one of the listed tasks has the type `vzdump` and no `endtime`, the upgrade is skipped and a message says why; autoremove, autoclean and the reboot check still run, and the role does not wait for the backup, so run it again afterwards.
- Off by default. With `false`, or on any other system type, no `pvesh` command runs.
- The `update` entry point reads the input as well. In check mode the main flow skips the upgrade itself, so it does not ask for the tasks; the entry point previews the upgrade and so asks.
- `localhost` is the node's own alias in the Proxmox API, so the role needs neither a node name nor gathered facts.
- A `pvesh` answer that is not a JSON list stops the run, instead of upgrading on a guess.
### Leaving journald alone
`system_baseline_journal_max_use: ""` skips the journald task: no drop-in directory, no `50-system-baseline.conf` and no restart of `systemd-journald`. Use it where another drop-in, role or policy owns the journal size. A file an earlier run wrote stays, as for an empty `system_baseline_apt_daily_timeout`; remove it by hand if the cap should go. A value that is not empty and not a size journald reads (`infinity`, `10m`, one with a line break) stops the run before any change, in the same way as the apt-daily value.
### Apt scratch directory
The upgrade runs over the SSH connection Ansible uses. An `openssh-server` upgrade restarts `ssh.service`, and a unit with `PrivateTmp=yes` (the `systemd_hardening` role sets it) has its own `/tmp` and `/var/tmp`, which systemd deletes when the unit stops. The files apt staged there for the running upgrade then disappear and dpkg fails, leaving packages unpacked but not configured. So the `update` flow creates `system_baseline_apt_tmpdir` (root, mode `0700`), runs the upgrade and the autoremove with `TMPDIR` set to it, and opens a new connection afterwards, so that later tasks get a fresh private `/tmp`.
@@ -207,6 +240,8 @@ The upgrade runs over the SSH connection Ansible uses. An `openssh-server` upgra
In a dry run (`--check`) the main flow does not run the apt upgrade: a package that is only waiting for the next patch run, or a package cache older than an hour, is not drift, and the package module reports both as `changed`, so a scheduled dry run would flag every host whenever a package landed in between. The autoremove and autoclean step still runs, and is checked: a leftover package it would remove is reported as `changed`, on purpose. `apt-get autoclean` runs in this step in a real run, in the main flow and in the `update` entry point. The `update` entry point is unchanged: it is an explicit request to update, so in check mode it still previews the upgrade.
`--check` is the supported preview; a play-level `check_mode: true` is not supported.
### Unattended-upgrades origins
A profile's `unattended_upgrade_origins` list pins the origins unattended-upgrades may install from. apt merges every file in `/etc/apt/apt.conf.d` and appends list entries across files, so a later file that only lists origins would widen the distribution's `50unattended-upgrades`, never narrow it. A non-empty list is therefore written to `/etc/apt/apt.conf.d/90unattended-upgrades-origins`, which sorts after `50unattended-upgrades`, clears `Unattended-Upgrade::Allowed-Origins` and `Unattended-Upgrade::Origins-Pattern` (apt's `#clear` directive) and sets only the listed patterns. The origin lists in `50unattended-upgrades` itself are not edited. An empty or missing list removes the drop-in.
+20 -2
View File
@@ -18,10 +18,15 @@ system_baseline_apt_tmpdir: /var/cache/system-baseline-apt-tmp
# Run the package update (tasks/update.yml) in the main flow. false skips it, for hosts that are patched by a separate,
# operator-run flow; the tasks_from: update entry point does not read it.
system_baseline_update: true
# Upper bound of the persistent journal (journald SystemMaxUse); older archived files are removed above it.
# Skip the apt upgrade while a vzdump backup is running on the Proxmox node (tasks/update.yml). Only for system_baseline_system_type pve;
# both the main flow and the tasks_from: update entry point read it. Off by default.
system_baseline_skip_upgrade_during_vzdump: false
# Upper bound of the persistent journal (journald SystemMaxUse); older archived files are removed above it. Empty leaves the host alone
# (tasks/journald.yml is not run; a drop-in an earlier run wrote stays).
system_baseline_journal_max_use: 200M
# Attach an interactive SSH login to a tmux session (see tasks/tmux.yml). Off by default: it changes what every login does.
# Only the ubuntu_lxc and ubuntu_vm profiles honour it; pve never installs the snippet.
# Installed only when tmux is among the packages to install: the ubuntu_lxc and ubuntu_vm profiles have it, the pve profile has none unless
# system_baseline_extra_packages adds it.
system_baseline_tmux_autostart: false
# Name of the session an SSH login attaches to.
system_baseline_tmux_session: main
@@ -246,6 +251,19 @@ system_baseline_profile: >-
# Inputs the tasks read
system_baseline_essential_packages: "{{ system_baseline_profile.essential_packages }}"
system_baseline_remove_packages: "{{ system_baseline_profile.remove_packages }}"
# Packages installed and purged in addition to the two resolved lists above. They append: a flat essential or remove input replaces its
# list, so adding one package that way means repeating the whole profile list.
system_baseline_extra_packages: []
system_baseline_extra_remove_packages: []
# What the role acts on: each resolved list plus its extras, without duplicates. Internal, read by tasks/packages.yml, tasks/tmux.yml and
# tasks/main.yml, so that an extra `tmux` or `unattended-upgrades` enables the matching task like a profile package does.
# A flat input that is a plain string (`system_baseline_essential_packages: vim`, which the package module accepts) counts as a one-item list.
__system_baseline_install_packages: >-
{{ (([system_baseline_essential_packages] if system_baseline_essential_packages is string else system_baseline_essential_packages)
+ system_baseline_extra_packages) | unique | list }}
__system_baseline_purge_packages: >-
{{ (([system_baseline_remove_packages] if system_baseline_remove_packages is string else system_baseline_remove_packages)
+ system_baseline_extra_remove_packages) | unique | list }}
system_baseline_apt_periodic_settings: "{{ system_baseline_profile.apt_periodic_settings }}"
# safe or dist (see the profiles). Guarded: the tasks_from: update entry point needs no system_baseline_system_type, and without one it
# stays on a safe upgrade instead of failing on the profile lookup. default('safe'): a system_baseline_profiles written before this key
+45 -3
View File
@@ -7,7 +7,7 @@ argument_specs:
Validates C(system_baseline_system_type) and, when C(system_baseline_tmux_autostart) is true, the tmux session name and
windows, then runs the update (unless C(system_baseline_update) is false), packages, unattended-upgrades, locale, timezone,
journald, apt-daily timeout (when set), sysctl, tmpfs, tmux and reboot task files, in that order.
- Needs gathered facts, because the reboot check reads C(ansible_os_family).
- Needs gathered facts, because the reboot check reads C(ansible_facts['os_family']).
- >-
The resolved inputs C(system_baseline_profile), C(system_baseline_essential_packages),
C(system_baseline_remove_packages), C(system_baseline_apt_periodic_settings), C(system_baseline_apt_upgrade),
@@ -55,6 +55,11 @@ argument_specs:
description:
- Upper bound of the persistent systemd journal (journald C(SystemMaxUse), for example C(200M)).
- Written to a drop-in under C(/etc/systemd/journald.conf.d).
- >-
A size journald reads, a number with an optional upper-case unit C(B), C(K), C(M), C(G), C(T), C(P) or C(E) (a bare number
is bytes); anything else (C(infinity), a lower-case unit, a line break) is refused before any change. Empty leaves the host
alone: no drop-in is written and journald is not restarted.
Clearing the value later does not remove a file already written.
system_baseline_tmux_autostart:
type: bool
default: false
@@ -63,7 +68,8 @@ argument_specs:
Attach an interactive SSH login to a tmux session, creating it when it does not exist. Installs C(/etc/profile.d/tmux-autostart.sh),
which acts only for an interactive login shell with a terminal, so scp, sftp, C(ssh host command) and automation are unaffected.
Shells that do not read C(/etc/profile.d) (zsh, fish) are unaffected too. A user opts out with C(~/.no-tmux). Installed only when
C(tmux) is in the resolved package list (the C(ubuntu_lxc) and C(ubuntu_vm) profiles); with false, or without tmux, the file is
C(tmux) is among the packages to install (the C(ubuntu_lxc) and C(ubuntu_vm) profiles have it, and C(system_baseline_extra_packages)
can add it to any profile, C(pve) included); with false, or without tmux, the file is
removed. A failed attach leaves a plain shell; detaching ends the SSH connection.
system_baseline_tmux_session:
type: str
@@ -152,6 +158,27 @@ argument_specs:
A non-empty list is written to C(/etc/apt/apt.conf.d/90unattended-upgrades-blacklist) as C(Unattended-Upgrade::Package-Blacklist).
apt appends list entries across files, so these are added to those of C(50unattended-upgrades). An empty list removes the file.
An entry may not hold a double quote, a backslash or a line break.
system_baseline_extra_packages:
type: list
elements: str
default: []
description:
- >-
Packages installed in addition to the resolved C(system_baseline_essential_packages). The list appends: setting
C(system_baseline_essential_packages) itself replaces the profile's list. A package named here also counts for the checks that read
the package list (C(tmux) for the tmux snippet, C(unattended-upgrades) for the unattended-upgrades tasks). Each item is a Debian
package name: lower-case letters, digits, C(+), C(-) and C(.), two or more characters, starting with a letter or digit and not
ending in C(-) (apt reads a trailing minus as a removal). A package that is also in C(system_baseline_remove_packages) or
C(system_baseline_extra_remove_packages) stops the run before any change.
system_baseline_extra_remove_packages:
type: list
elements: str
default: []
description:
- >-
Packages purged, when installed, in addition to the resolved C(system_baseline_remove_packages). The list appends. Each item is a
Debian package name, as for C(system_baseline_extra_packages). A package that is also in C(system_baseline_essential_packages)
stops the run before any change.
system_baseline_update:
type: bool
default: true
@@ -162,6 +189,18 @@ argument_specs:
the reboot.
- The C(update) entry point does not read it.
- In check mode the main flow skips the upgrade itself (a pending update is not drift); autoremove and autoclean are still checked.
system_baseline_skip_upgrade_during_vzdump:
type: bool
default: false
description:
- >-
Skip the apt upgrade while a vzdump backup is running on the Proxmox node. Acts only when C(system_baseline_system_type) is
C(pve): the role runs C(pvesh get /nodes/localhost/tasks --source active), and a C(vzdump) task in that list is a running backup.
The upgrade is then skipped with a message, and the rest of the flow (autoremove, the reboot check) goes on. It does not wait for
the backup. With false, or on any other system type, no C(pvesh) command runs.
- >-
The C(update) entry point reads it too, and a C(pvesh) answer that is not a JSON list fails the run instead of upgrading. In check mode the
main flow skips the upgrade itself, so it does not ask for the tasks.
update:
short_description: Update and upgrade apt packages
description:
@@ -176,6 +215,9 @@ argument_specs:
It creates C(system_baseline_apt_tmpdir), runs the upgrade and the autoremove with C(TMPDIR) set to it, and then opens a new
connection, so that a restart of C(ssh.service) during the upgrade does not remove the files apt needs. It reads that input
although the entry point has no argument specification of its own.
- >-
It also reads C(system_baseline_skip_upgrade_during_vzdump): with true on C(system_baseline_system_type) C(pve) it skips the upgrade while
a vzdump backup is running.
reboot:
short_description: Compute system_baseline_reboot_required and reboot when allowed
description:
@@ -187,7 +229,7 @@ argument_specs:
never reboots, so a caller can read C(system_baseline_reboot_required) (bool) and reboot on its own terms, for example after
draining a node. The fact name and this behaviour are part of the role's interface.
- On a non-Debian host the fact is not set; read it with C(default(false)).
- Reads C(ansible_os_family), so facts must be gathered.
- Reads C(ansible_facts['os_family']), so facts must be gathered.
options:
system_baseline_reboot_if_required:
type: bool
@@ -1,143 +1,11 @@
---
- name: Refuse an unknown system_baseline_system_type
hosts: all
gather_facts: false
tasks:
- name: Run the role with a bad system_baseline_system_type
block:
- name: Include system_baseline
ansible.builtin.include_role:
name: mortis.kamino.system_baseline
vars:
system_baseline_system_type: not_a_type
- name: Unreachable when validation works
ansible.builtin.fail:
msg: system_baseline ran with an invalid system_baseline_system_type
rescue:
- name: The validation stopped the play
ansible.builtin.assert:
that: "'is invalid' in ansible_failed_result.msg | default('')"
quiet: true
# The apt upgrade mode is safe or dist: anything else (here `full`, an apt module value the role does not offer) stops the run before
# any change, with a message that names the input.
- name: An unknown apt upgrade mode is refused
hosts: all
gather_facts: false
tasks:
- name: Run the role with a bad system_baseline_apt_upgrade
block:
- name: Include system_baseline
ansible.builtin.include_role:
name: mortis.kamino.system_baseline
vars:
system_baseline_system_type: ubuntu_lxc
system_baseline_apt_upgrade: full
- name: Unreachable when validation works
ansible.builtin.fail:
msg: system_baseline ran with an invalid system_baseline_apt_upgrade
rescue:
- name: The validation stopped the play
ansible.builtin.assert:
that: "'system_baseline_apt_upgrade is' in ansible_failed_result.msg | default('')"
quiet: true
# The update entry point does not run validate.yml, so it checks the mode itself and stops before it calls the package module.
- name: The update entry point refuses an unknown apt upgrade mode
hosts: all
gather_facts: false
tasks:
- name: Run the update entry point with a bad system_baseline_apt_upgrade
block:
- name: Include system_baseline, tasks_from update
ansible.builtin.include_role:
name: mortis.kamino.system_baseline
tasks_from: update
vars:
system_baseline_apt_upgrade: full
- name: Unreachable when validation works
ansible.builtin.fail:
msg: the update entry point ran with an invalid system_baseline_apt_upgrade
rescue:
- name: The validation stopped the play
ansible.builtin.assert:
that: "'system_baseline_apt_upgrade is' in ansible_failed_result.msg | default('')"
quiet: true
# The apt scratch directory becomes TMPDIR of the upgrade: a path under /tmp or /var/tmp (which a restart of ssh.service can delete), a relative
# path and a `..` each stop the run before any change, in the main flow and in the update entry point (which does not run validate.yml).
- name: A bad apt scratch directory is refused
hosts: all
gather_facts: false
tasks:
- name: Refuse each bad value
ansible.builtin.include_tasks: tasks/refuse_apt_tmpdir_entries.yml
vars:
system_baseline_refused_tmpdir: "{{ item }}"
loop:
- /tmp
- /var/tmp/apt
- /var/cache/../../tmp/x
- var/cache/apt-tmp
- ""
# The reboot inputs are whole numbers, 0 or more: a negative number and a boolean each stop the run before a host reboots,
# in the main flow and in the reboot entry point (which does not run validate.yml).
- name: A bad reboot throttle or post-reboot delay is refused
hosts: all
gather_facts: false
tasks:
- name: Refuse each bad value
ansible.builtin.include_tasks: tasks/refuse_reboot.yml
vars:
system_baseline_refused_reboot: "{{ item }}"
loop:
- {system_baseline_reboot_throttle: -1}
- {system_baseline_reboot_post_delay: -5}
- {system_baseline_reboot_post_delay: true}
# The value is written into a unit file, so a line break (a second directive) is refused.
- name: A bad apt-daily timeout is refused
hosts: all
gather_facts: false
tasks:
- name: Run the role with a line break in system_baseline_apt_daily_timeout
block:
- name: Include system_baseline
ansible.builtin.include_role:
name: mortis.kamino.system_baseline
vars:
system_baseline_system_type: ubuntu_lxc
system_baseline_apt_daily_timeout: "1h\nExecStart=/bin/true"
- name: Unreachable when validation works
ansible.builtin.fail:
msg: system_baseline ran with an invalid system_baseline_apt_daily_timeout
rescue:
- name: The validation stopped the play
ansible.builtin.assert:
that: "'system_baseline_apt_daily_timeout must be' in ansible_failed_result.msg | default('')"
quiet: true
# A quote, a null item and a bare string (not a list) each stop the run: the bare string would otherwise be split into one-character
# patterns, and the null item would become an empty pattern that matches every package.
- name: A bad package blacklist is refused
hosts: all
gather_facts: false
tasks:
- name: Refuse each bad value
ansible.builtin.include_tasks: tasks/refuse_blacklist.yml
vars:
system_baseline_refused_blacklist: "{{ item }}"
loop:
- ['bad"name']
- [null]
- linux-image-.*
- name: Converge the LXC profile
hosts: all
gather_facts: true
vars:
system_baseline_system_type: ubuntu_lxc
system_baseline_extra_packages: [jq]
system_baseline_extra_remove_packages: [ed]
system_baseline_tmux_autostart: true
system_baseline_apt_daily_timeout: 1h
system_baseline_tmux_session: molecule
@@ -145,82 +13,3 @@
- { name: logs, command: "echo 'a b'; true" }
roles:
- role: mortis.kamino.system_baseline
# The remaining plays only load the role's defaults (validate.yml changes nothing) and assert
# the resolved inputs. They cover the profiles the converge above cannot run.
- name: The pve profile resolves
hosts: all
gather_facts: false
vars:
system_baseline_system_type: pve
tasks:
- name: Load the role defaults
ansible.builtin.include_role:
name: mortis.kamino.system_baseline
tasks_from: validate.yml
public: true
- name: Assert the pve profile
ansible.builtin.assert:
that:
- "'ufw' not in system_baseline_essential_packages"
- "'tmux' not in system_baseline_essential_packages"
- "'unattended-upgrades' in system_baseline_essential_packages"
- system_baseline_unattended_upgrade_settings['Unattended-Upgrade::Automatic-Reboot'] == false
- system_baseline_unattended_upgrade_settings['Unattended-Upgrade::Automatic-Reboot-Time'] == '03:00'
- system_baseline_secure_tmp_mounts == ['/dev/shm', '/tmp', '/var/tmp']
- system_baseline_update
- system_baseline_apt_upgrade == 'dist'
- system_baseline_unattended_upgrade_origins | length == 3
- system_baseline_unattended_upgrade_origins | select('search', 'Proxmox') | list == []
quiet: true
- name: The ubuntu_vm profile resolves
hosts: all
gather_facts: false
vars:
system_baseline_system_type: ubuntu_vm
tasks:
- name: Load the role defaults
ansible.builtin.include_role:
name: mortis.kamino.system_baseline
tasks_from: validate.yml
public: true
- name: Assert the ubuntu_vm profile
ansible.builtin.assert:
that:
- "'qemu-guest-agent' in system_baseline_essential_packages"
- "'tmux' in system_baseline_essential_packages"
- system_baseline_unattended_upgrade_settings['Unattended-Upgrade::Automatic-Reboot'] == false
- system_baseline_unattended_upgrade_settings['Unattended-Upgrade::Automatic-Reboot-Time'] == '04:00'
- system_baseline_sysctl_hardening | selectattr('name', 'equalto', 'net.ipv4.conf.all.log_martians') | list | length == 1
- system_baseline_apt_upgrade == 'safe'
- system_baseline_unattended_upgrade_origins == []
quiet: true
# Consumer play vars override the profile.
- name: Consumer overrides win over the profile
hosts: all
gather_facts: false
vars:
system_baseline_system_type: ubuntu_vm
system_baseline_remove_packages: [telnet]
system_baseline_apt_upgrade: dist
system_baseline_profile_overrides:
ubuntu_vm:
unattended_upgrade_settings:
"Unattended-Upgrade::Automatic-Reboot": true
tasks:
- name: Load the role defaults
ansible.builtin.include_role:
name: mortis.kamino.system_baseline
tasks_from: validate.yml
public: true
- name: Assert the overrides
ansible.builtin.assert:
that:
- system_baseline_remove_packages == ['telnet']
- system_baseline_apt_upgrade == 'dist'
- system_baseline_unattended_upgrade_settings['Unattended-Upgrade::Automatic-Reboot'] == true
- system_baseline_unattended_upgrade_settings['Unattended-Upgrade::Automatic-Reboot-Time'] == '04:00'
- "'qemu-guest-agent' in system_baseline_essential_packages"
quiet: true
@@ -53,13 +53,16 @@ verifier:
scenario:
# molecule's default sequence minus both destroys: scripts/run_molecule_scenarios.sh removes the
# container as soon as this scenario ends. After a local run, run `molecule destroy` yourself.
# A check runs before the converge (fresh host) and after it (configured host).
test_sequence:
- dependency
- cleanup
- syntax
- create
- prepare
- check
- converge
- check
- idempotence
- side_effect
- verify
@@ -1,12 +1,18 @@
---
# A package the role must remove, and the locales tool the role assumes exists
# (it does on a stock Ubuntu host).
# (it does on a stock Ubuntu host). jq (system_baseline_extra_packages) must be absent, so that the role is what installs it, and ed
# (system_baseline_extra_remove_packages, on no profile list) must be present, so that the role is what purges it.
- name: Prepare
hosts: all
gather_facts: false
tasks:
- name: Install a package on the role's remove list and locale-gen
ansible.builtin.apt:
name: [telnet, locales]
name: [telnet, locales, ed]
state: present
update_cache: true
- name: Make sure jq is not installed
ansible.builtin.apt:
name: jq
state: absent
@@ -0,0 +1,21 @@
---
# One refusal per call: the role must stop on validation, before it changes anything, with a message that names the inputs.
# The case comes in as system_baseline_refused_case: {install, remove, expect}.
- name: Run the role with a bad extra package list
block:
- name: Include system_baseline
ansible.builtin.include_role:
name: mortis.kamino.system_baseline
vars:
system_baseline_system_type: ubuntu_lxc
system_baseline_extra_packages: "{{ system_baseline_refused_case.install | default([]) }}"
system_baseline_extra_remove_packages: "{{ system_baseline_refused_case.remove | default([]) }}"
- name: Unreachable when validation works
ansible.builtin.fail:
msg: system_baseline ran with a bad extra package list
rescue:
- name: The validation stopped the play with the expected message
ansible.builtin.assert:
that: system_baseline_refused_case.expect in ansible_failed_result.msg | default('')
fail_msg: "Expected '{{ system_baseline_refused_case.expect }}', got: {{ ansible_failed_result.msg | default('') }}"
quiet: true
@@ -0,0 +1,18 @@
---
# One refusal: the role must stop on validation, before it changes anything, with a message that names the variable.
- name: Run the role with a bad system_baseline_journal_max_use
block:
- name: Include system_baseline
ansible.builtin.include_role:
name: mortis.kamino.system_baseline
vars:
system_baseline_system_type: ubuntu_lxc
system_baseline_journal_max_use: "{{ system_baseline_refused_journal }}"
- name: Unreachable when validation works
ansible.builtin.fail:
msg: system_baseline ran with an invalid system_baseline_journal_max_use
rescue:
- name: The validation stopped the play
ansible.builtin.assert:
that: "'system_baseline_journal_max_use must be' in ansible_failed_result.msg | default('')"
quiet: true
@@ -0,0 +1,61 @@
---
# One case of the vzdump guard: a pvesh stub answers with system_baseline_case_answer, the update entry point runs in check mode, and the
# fact that decides the upgrade, and whether pvesh was asked at all, are compared with what the case expects. Kept outside the role's own tasks:
# no CI image is a Proxmox node, so the stub stands for the real `pvesh get /nodes/<node>/tasks` answer.
- name: Write the pvesh stub
check_mode: false
ansible.builtin.copy:
dest: /usr/local/bin/pvesh
mode: "0755"
content: |
#!/bin/sh
echo "$*" >> /var/tmp/pvesh-calls
cat <<'JSON'
{{ system_baseline_case.answer | to_json }}
JSON
- name: Create the apt scratch directory, which a check mode run does not
check_mode: false
ansible.builtin.file:
path: /var/cache/system-baseline-apt-tmp
state: directory
mode: "0700"
- name: Forget earlier calls
ansible.builtin.file:
path: /var/tmp/pvesh-calls
state: absent
- name: Run the update entry point in check mode
check_mode: true
block:
- name: Include system_baseline, tasks_from update
ansible.builtin.include_role:
name: mortis.kamino.system_baseline
tasks_from: update
vars:
system_baseline_system_type: "{{ system_baseline_case.type }}"
system_baseline_skip_upgrade_during_vzdump: "{{ system_baseline_case.input }}"
- name: Read the recorded pvesh calls
ansible.builtin.slurp:
src: /var/tmp/pvesh-calls
register: system_baseline_case_calls
failed_when: false
- name: The guard decided as the case expects, and pvesh was asked only when it should be
ansible.builtin.assert:
that:
- __system_baseline_vzdump_running == system_baseline_case.running
- (system_baseline_case_calls.content is defined) == system_baseline_case.asked
- not system_baseline_case.asked or
"get /nodes/localhost/tasks --source active --limit 0 --output-format json" in (system_baseline_case_calls.content | b64decode)
quiet: true
- name: Remove the pvesh stub and its record
ansible.builtin.file:
path: "{{ item }}"
state: absent
loop:
- /usr/local/bin/pvesh
- /var/tmp/pvesh-calls
@@ -1,4 +1,337 @@
---
# Validation-only plays: they need no container, so they run once, on the controller, in
# check mode so that a refusal that regressed cannot change the controller.
- name: Refuse an unknown system_baseline_system_type
hosts: localhost
connection: local
check_mode: true
gather_facts: false
tasks:
- name: Run the role with a bad system_baseline_system_type
block:
- name: Include system_baseline
ansible.builtin.include_role:
name: mortis.kamino.system_baseline
vars:
system_baseline_system_type: not_a_type
- name: Unreachable when validation works
ansible.builtin.fail:
msg: system_baseline ran with an invalid system_baseline_system_type
rescue:
- name: The validation stopped the play
ansible.builtin.assert:
that: "'is invalid' in ansible_failed_result.msg | default('')"
quiet: true
# The apt upgrade mode is safe or dist: anything else (here `full`, an apt module value the role does not offer) stops the run before
# any change, with a message that names the input.
- name: An unknown apt upgrade mode is refused
hosts: localhost
connection: local
check_mode: true
gather_facts: false
tasks:
- name: Run the role with a bad system_baseline_apt_upgrade
block:
- name: Include system_baseline
ansible.builtin.include_role:
name: mortis.kamino.system_baseline
vars:
system_baseline_system_type: ubuntu_lxc
system_baseline_apt_upgrade: full
- name: Unreachable when validation works
ansible.builtin.fail:
msg: system_baseline ran with an invalid system_baseline_apt_upgrade
rescue:
- name: The validation stopped the play
ansible.builtin.assert:
that: "'system_baseline_apt_upgrade is' in ansible_failed_result.msg | default('')"
quiet: true
# The update entry point does not run validate.yml, so it checks the mode itself and stops before it calls the package module.
- name: The update entry point refuses an unknown apt upgrade mode
hosts: localhost
connection: local
check_mode: true
gather_facts: false
tasks:
- name: Run the update entry point with a bad system_baseline_apt_upgrade
block:
- name: Include system_baseline, tasks_from update
ansible.builtin.include_role:
name: mortis.kamino.system_baseline
tasks_from: update
vars:
system_baseline_apt_upgrade: full
- name: Unreachable when validation works
ansible.builtin.fail:
msg: the update entry point ran with an invalid system_baseline_apt_upgrade
rescue:
- name: The validation stopped the play
ansible.builtin.assert:
that: "'system_baseline_apt_upgrade is' in ansible_failed_result.msg | default('')"
quiet: true
# The apt scratch directory becomes TMPDIR of the upgrade: a path under /tmp or /var/tmp (which a restart of ssh.service can delete), a relative
# path and a `..` each stop the run before any change, in the main flow and in the update entry point (which does not run validate.yml).
- name: A bad apt scratch directory is refused
hosts: localhost
connection: local
check_mode: true
gather_facts: false
tasks:
- name: Refuse each bad value
ansible.builtin.include_tasks: tasks/refuse_apt_tmpdir_entries.yml
vars:
system_baseline_refused_tmpdir: "{{ item }}"
loop:
- /tmp
- /var/tmp/apt
- /var/cache/../../tmp/x
- var/cache/apt-tmp
- ""
# The reboot inputs are whole numbers, 0 or more: a negative number and a boolean each stop the run before a host reboots,
# in the main flow and in the reboot entry point (which does not run validate.yml).
- name: A bad reboot throttle or post-reboot delay is refused
hosts: localhost
connection: local
check_mode: true
gather_facts: false
tasks:
- name: Refuse each bad value
ansible.builtin.include_tasks: tasks/refuse_reboot.yml
vars:
system_baseline_refused_reboot: "{{ item }}"
loop:
- {system_baseline_reboot_throttle: -1}
- {system_baseline_reboot_post_delay: -5}
- {system_baseline_reboot_post_delay: true}
# The value is written into a unit file, so a line break (a second directive) is refused.
- name: A bad apt-daily timeout is refused
hosts: localhost
connection: local
check_mode: true
gather_facts: false
tasks:
- name: Run the role with a line break in system_baseline_apt_daily_timeout
block:
- name: Include system_baseline
ansible.builtin.include_role:
name: mortis.kamino.system_baseline
vars:
system_baseline_system_type: ubuntu_lxc
system_baseline_apt_daily_timeout: "1h\nExecStart=/bin/true"
- name: Unreachable when validation works
ansible.builtin.fail:
msg: system_baseline ran with an invalid system_baseline_apt_daily_timeout
rescue:
- name: The validation stopped the play
ansible.builtin.assert:
that: "'system_baseline_apt_daily_timeout must be' in ansible_failed_result.msg | default('')"
quiet: true
# The journal cap is a size journald reads, or empty: infinity (SystemMaxUse does not take it), a lower-case unit, a unit with a trailing B,
# a line break and a number that is not a string each stop the run before any change.
- name: A bad journal size cap is refused
hosts: localhost
connection: local
check_mode: true
gather_facts: false
tasks:
- name: Refuse each bad value
ansible.builtin.include_tasks: tasks/refuse_journal_max_use.yml
vars:
system_baseline_refused_journal: "{{ item }}"
loop:
- infinity
- "10m"
- "10MB"
- "200M\nStorage=none"
- 300
# A quote, a null item and a bare string (not a list) each stop the run: the bare string would otherwise be split into one-character
# patterns, and the null item would become an empty pattern that matches every package.
- name: A bad package blacklist is refused
hosts: localhost
connection: local
check_mode: true
gather_facts: false
tasks:
- name: Refuse each bad value
ansible.builtin.include_tasks: tasks/refuse_blacklist.yml
vars:
system_baseline_refused_blacklist: "{{ item }}"
loop:
- ['bad"name']
- [null]
- linux-image-.*
# Items that are not Debian package names (whitespace, null, empty, a trailing minus that apt reads as a removal, an option, upper case, a
# version pin), and a package that one input installs and another purges, each stop the run before any change.
# The overlaps are: an extra install against the profile's remove list (telnet), an extra install against an extra remove, and an extra
# remove against the profile's install list (tmux).
- name: A bad extra package list is refused
hosts: localhost
connection: local
check_mode: true
gather_facts: false
tasks:
- name: Refuse each bad value
ansible.builtin.include_tasks: tasks/refuse_extra_packages.yml
vars:
system_baseline_refused_case: "{{ item }}"
loop:
- { install: ['bad name'], expect: 'must be lists of package names' }
- { install: [null], expect: 'must be lists of package names' }
- { install: jq, expect: 'must be lists of package names' }
- { remove: [''], expect: 'must be lists of package names' }
- { install: ['jq-'], expect: 'must be lists of package names' }
- { install: ['-y'], expect: 'must be lists of package names' }
- { remove: ['Telnet'], expect: 'must be lists of package names' }
- { remove: ['ed=1.0'], expect: 'must be lists of package names' }
- { install: [telnet], expect: 'is both installed and purged' }
- { install: [jq], remove: [jq], expect: 'is both installed and purged' }
- { remove: [tmux], expect: 'is both installed and purged' }
# The remaining plays only load the role's defaults (validate.yml changes nothing) and assert
# the resolved inputs. They cover the profiles converge.yml cannot run.
- name: The pve profile resolves
hosts: localhost
connection: local
check_mode: true
gather_facts: false
vars:
system_baseline_system_type: pve
tasks:
- name: Load the role defaults
ansible.builtin.include_role:
name: mortis.kamino.system_baseline
tasks_from: validate.yml
public: true
- name: Assert the pve profile
ansible.builtin.assert:
that:
- "'ufw' not in system_baseline_essential_packages"
- "'tmux' not in system_baseline_essential_packages"
- "'unattended-upgrades' in system_baseline_essential_packages"
- system_baseline_unattended_upgrade_settings['Unattended-Upgrade::Automatic-Reboot'] == false
- system_baseline_unattended_upgrade_settings['Unattended-Upgrade::Automatic-Reboot-Time'] == '03:00'
- system_baseline_secure_tmp_mounts == ['/dev/shm', '/tmp', '/var/tmp']
- system_baseline_update
- system_baseline_apt_upgrade == 'dist'
- system_baseline_unattended_upgrade_origins | length == 3
- system_baseline_unattended_upgrade_origins | select('search', 'Proxmox') | list == []
- __system_baseline_install_packages == system_baseline_essential_packages
- __system_baseline_purge_packages == system_baseline_remove_packages
quiet: true
- name: The ubuntu_vm profile resolves
hosts: localhost
connection: local
check_mode: true
gather_facts: false
vars:
system_baseline_system_type: ubuntu_vm
tasks:
- name: Load the role defaults
ansible.builtin.include_role:
name: mortis.kamino.system_baseline
tasks_from: validate.yml
public: true
- name: Assert the ubuntu_vm profile
ansible.builtin.assert:
that:
- "'qemu-guest-agent' in system_baseline_essential_packages"
- "'tmux' in system_baseline_essential_packages"
- system_baseline_unattended_upgrade_settings['Unattended-Upgrade::Automatic-Reboot'] == false
- system_baseline_unattended_upgrade_settings['Unattended-Upgrade::Automatic-Reboot-Time'] == '04:00'
- system_baseline_sysctl_hardening | selectattr('name', 'equalto', 'net.ipv4.conf.all.log_martians') | list | length == 1
- system_baseline_apt_upgrade == 'safe'
- system_baseline_unattended_upgrade_origins == []
- __system_baseline_install_packages == system_baseline_essential_packages
- __system_baseline_purge_packages == system_baseline_remove_packages
quiet: true
# Consumer play vars override the profile.
- name: Consumer overrides win over the profile
hosts: localhost
connection: local
check_mode: true
gather_facts: false
vars:
system_baseline_system_type: ubuntu_vm
system_baseline_remove_packages: [telnet]
system_baseline_apt_upgrade: dist
system_baseline_profile_overrides:
ubuntu_vm:
unattended_upgrade_settings:
"Unattended-Upgrade::Automatic-Reboot": true
tasks:
- name: Load the role defaults
ansible.builtin.include_role:
name: mortis.kamino.system_baseline
tasks_from: validate.yml
public: true
- name: Assert the overrides
ansible.builtin.assert:
that:
- system_baseline_remove_packages == ['telnet']
- system_baseline_apt_upgrade == 'dist'
- system_baseline_unattended_upgrade_settings['Unattended-Upgrade::Automatic-Reboot'] == true
- system_baseline_unattended_upgrade_settings['Unattended-Upgrade::Automatic-Reboot-Time'] == '04:00'
- "'qemu-guest-agent' in system_baseline_essential_packages"
quiet: true
# The extras append to the resolved lists, whether the profile's list or a flat input supplies them, and a name that is in both is listed once.
- name: Extra packages append to the resolved lists
hosts: localhost
connection: local
check_mode: true
gather_facts: false
vars:
system_baseline_system_type: ubuntu_lxc
system_baseline_essential_packages: [vim, curl]
system_baseline_extra_packages: [jq, vim, unattended-upgrades]
system_baseline_extra_remove_packages: [ed, telnet]
tasks:
- name: Load the role defaults
ansible.builtin.include_role:
name: mortis.kamino.system_baseline
tasks_from: validate.yml
public: true
- name: Assert the lists the role acts on
ansible.builtin.assert:
that:
- __system_baseline_install_packages == ['vim', 'curl', 'jq', 'unattended-upgrades']
- "'ed' in __system_baseline_purge_packages"
- __system_baseline_purge_packages | select('equalto', 'telnet') | list | length == 1
- system_baseline_remove_packages | difference(__system_baseline_purge_packages) | length == 0
quiet: true
# A flat input that is a plain string (the package module accepts one) still counts as a one-item list, with and without extras.
- name: A flat string package list still resolves
hosts: localhost
connection: local
check_mode: true
gather_facts: false
vars:
system_baseline_system_type: ubuntu_lxc
system_baseline_essential_packages: vim
system_baseline_extra_packages: [jq]
tasks:
- name: Load the role defaults
ansible.builtin.include_role:
name: mortis.kamino.system_baseline
tasks_from: validate.yml
public: true
- name: Assert the lists the role acts on
ansible.builtin.assert:
that:
- __system_baseline_install_packages == ['vim', 'jq']
quiet: true
- name: Verify
hosts: all
gather_facts: false
@@ -17,6 +350,16 @@
- "'telnet' not in ansible_facts.packages"
quiet: true
# jq was absent before the role ran and is on no profile list: the extra list installed it, and the profile's own packages (tmux,
# curl above) are still there. ed was present and is on no profile list: the extra remove list purged it.
- name: The extra packages were installed and the extra removal purged
ansible.builtin.assert:
that:
- "'jq' in ansible_facts.packages"
- "'curl' in ansible_facts.packages"
- "'ed' not in ansible_facts.packages"
quiet: true
- name: Read the journald drop-in
ansible.builtin.slurp:
src: /etc/systemd/journald.conf.d/50-system-baseline.conf
@@ -254,6 +597,51 @@
that: not system_baseline_verify_removed.stat.exists
quiet: true
# An extra tmux counts like a profile tmux: a flat package list without it installs no snippet, the same list plus the extra does.
- name: Run the tmux tasks with a flat package list that lacks tmux
ansible.builtin.include_role:
name: mortis.kamino.system_baseline
tasks_from: tmux
vars:
system_baseline_system_type: ubuntu_lxc
system_baseline_tmux_autostart: true
system_baseline_essential_packages: [vim]
- name: Stat the snippet without the extra
ansible.builtin.stat:
path: /etc/profile.d/tmux-autostart.sh
register: system_baseline_verify_no_extra
- name: Run the tmux tasks with tmux as an extra package
ansible.builtin.include_role:
name: mortis.kamino.system_baseline
tasks_from: tmux
vars:
system_baseline_system_type: ubuntu_lxc
system_baseline_tmux_autostart: true
system_baseline_essential_packages: [vim]
system_baseline_extra_packages: [tmux]
- name: Stat the snippet with the extra
ansible.builtin.stat:
path: /etc/profile.d/tmux-autostart.sh
register: system_baseline_verify_with_extra
- name: Only the extra tmux installs the snippet
ansible.builtin.assert:
that:
- not system_baseline_verify_no_extra.stat.exists
- system_baseline_verify_with_extra.stat.exists
quiet: true
- name: Remove the snippet again
ansible.builtin.include_role:
name: mortis.kamino.system_baseline
tasks_from: tmux
vars:
system_baseline_system_type: ubuntu_lxc
system_baseline_tmux_autostart: false
# The pve origins pin, run on this Ubuntu host: Ubuntu's 50unattended-upgrades sets Allowed-Origins, so the merged
# configuration showing only the pinned patterns proves the drop-in clears the earlier lists instead of appending to them.
# The patterns match no Ubuntu origin, which only means nothing would be upgraded; the role's dry run still passes. Here
@@ -395,3 +783,67 @@
- system_baseline_verify_blacklist_dump_removed.stdout_lines | select('match', 'Unattended-Upgrade::Package-Blacklist::\s') | list == []
quiet: true
tags: always
# The vzdump guard (system_baseline_skip_upgrade_during_vzdump): a running backup is a vzdump task without an endtime. With the input off, or on
# a system type other than pve, pvesh is never run. Only the decision is asserted: the upgrade itself is not run in CI.
- name: The vzdump guard skips the upgrade only for a running backup on a pve node
hosts: all
gather_facts: false
tasks:
- name: Run each case
ansible.builtin.include_tasks: tasks/vzdump_guard_case.yml
vars:
system_baseline_case: "{{ item }}"
loop:
- {type: pve, input: true, running: true, asked: true, answer: [{type: vzdump, upid: a, starttime: 1}]}
- {type: pve, input: true, running: true, asked: true, answer: [{type: vzdump, upid: a, starttime: 1}, {type: qmstart, upid: b, starttime: 1}]}
- {type: pve, input: true, running: false, asked: true, answer: [{type: vzdump, upid: a, starttime: 1, endtime: 2}]}
- {type: pve, input: true, running: false, asked: true, answer: [{type: qmstart, upid: b, starttime: 1}]}
- {type: pve, input: true, running: false, asked: true, answer: []}
- {type: pve, input: false, running: false, asked: false, answer: [{type: vzdump, upid: a, starttime: 1}]}
- {type: ubuntu_lxc, input: true, running: false, asked: false, answer: [{type: vzdump, upid: a, starttime: 1}]}
# An empty system_baseline_journal_max_use leaves journald alone: with the drop-in gone, the role neither writes it again nor restarts
# systemd-journald. It runs last, because it applies the role with its defaults (the converge's tmux autostart and apt-daily timeout are
# not set here) and the checks above read what the converge wrote.
# It removes what the converge wrote, so a second `molecule verify` needs a converge first.
- name: An empty journal size cap leaves journald alone
hosts: all
gather_facts: true
tasks:
- name: Remove the drop-in and its directory
ansible.builtin.file:
path: /etc/systemd/journald.conf.d
state: absent
- name: Note when journald last started
ansible.builtin.command:
argv: [systemctl, show, systemd-journald, --property=ActiveEnterTimestampMonotonic, --value]
register: system_baseline_verify_journald_before
changed_when: false
- name: Run the role with an empty cap
ansible.builtin.include_role:
name: mortis.kamino.system_baseline
vars:
system_baseline_system_type: ubuntu_lxc
system_baseline_journal_max_use: ""
- name: Look for the drop-in directory
ansible.builtin.stat:
path: /etc/systemd/journald.conf.d
register: system_baseline_verify_journald_dir
- name: Note when journald last started, after the run
ansible.builtin.command:
argv: [systemctl, show, systemd-journald, --property=ActiveEnterTimestampMonotonic, --value]
register: system_baseline_verify_journald_after
changed_when: false
- name: Nothing was written and journald was not restarted
ansible.builtin.assert:
that:
- not system_baseline_verify_journald_dir.stat.exists
- system_baseline_verify_journald_before.stdout | length > 0
- system_baseline_verify_journald_after.stdout == system_baseline_verify_journald_before.stdout
quiet: true
+2 -1
View File
@@ -17,7 +17,7 @@
- name: Configure unattended-upgrades
ansible.builtin.import_tasks: unattended_upgrades.yml
when: "'unattended-upgrades' in system_baseline_essential_packages"
when: "'unattended-upgrades' in __system_baseline_install_packages"
tags: unattended-upgrades
- name: Set locale
@@ -30,6 +30,7 @@
- name: Cap the journal size
ansible.builtin.import_tasks: journald.yml
when: system_baseline_journal_max_use | length > 0
tags: journald
- name: Bound a hung apt-daily.service
Loaded 100 of 151 files, more files were not shown because too many files have changed in this diff. Show more