122 Commits
Author SHA1 Message Date
Defame1297 15e0b44364 Merge pull request 'chore(release): 1.2.0' (#79) from release/1.2.0 into main
Molecule / molecule (push) Successful in 4m42s
Build / build (push) Successful in 10s
Lint / lint (push) Successful in 16s
Reviewed-on: #79
2026-11-10 18:26:07 +00:00
Defame1297andClaude Sonnet 5.5 de68aadf9b chore(release): 1.2.0
Molecule / molecule (pull_request) Successful in 4m38s
Lint / lint (pull_request) Successful in 17s
Build / build (pull_request) Successful in 9s
Adds the network_interfaces and systemd_hardening roles. Version bump in
galaxy.yml, the changelog built by antsibull-changelog release, README pin
example and status text, CLAUDE.md.

Verified: the commit hooks. Not verified: ansible-test sanity and the
importer (CI). The tag is the maintainer's.

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01MmzvM9skAvYcph2c9EiPcm
2026-11-10 18:16:40 +00:00
Defame1297 db1caa9b28 Merge pull request 'feat(roles): add the systemd_hardening and network_interfaces roles' (#78) from feat/systemd-hardening-network-interfaces-roles into main
Build / build (push) Successful in 10s
Molecule / molecule (push) Successful in 4m42s
Lint / lint (push) Successful in 16s
Reviewed-on: #78
2026-11-10 18:15:52 +00:00
Defame1297andClaude Sonnet 5.5 cf8f4b5bf0 feat(roles): add the systemd_hardening and network_interfaces roles
Molecule / molecule (pull_request) Successful in 4m43s
Lint / lint (pull_request) Successful in 17s
Build / build (pull_request) Successful in 10s
Copied from the environment repository's roles and scrubbed for the
Collection: galaxy namespace mortis, molecule scenarios call the roles by
their FQCN and take their paths from the workflow, README examples use
mortis.kamino.* and documentation addresses, repository-local references
(issue numbers, ADRs, inventory paths) are dropped. network_interfaces
loses its Legacy name guard and the molecule play that tested it: the
guard only protected the in-repo rename, and a new consumer never had the
old names. mock_roles in .ansible-lint lists both FQCNs.

Not verified locally: the molecule scenarios (they run on the
kamino-molecule runner in CI) and ansible-test sanity.

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01MmzvM9skAvYcph2c9EiPcm
2026-11-10 15:09:48 +00:00
kamino-renovate Bot 21dda27b00 Merge pull request 'chore(deps): update git.rkdr.net/mortis/ci docker tag to v0.2.14' (#76) from renovate/git.rkdr.net-mortis-ci-0.x into main
Build / build (push) Successful in 9s
Lint / lint (push) Successful in 14s
2026-11-09 03:21:48 +00:00
renovate-bot 57f16b5129 chore(deps): update git.rkdr.net/mortis/ci docker tag to v0.2.14
renovate/stability-days Updates have met minimum release age requirement
Molecule / molecule (pull_request) Successful in 3m20s
Build / build (pull_request) Successful in 21s
Lint / lint (pull_request) Successful in 14s
2026-11-09 03:17:48 +00:00
Defame1297 e036aa8789 Merge pull request 'chore(release): 1.1.0' (#75) from release/1.1.0 into main
Molecule / molecule (push) Successful in 3m16s
Build / build (push) Successful in 23s
Lint / lint (push) Successful in 16s
Reviewed-on: #75
2026-11-08 21:36:17 +00:00
Defame1297andClaude Sonnet 5.5 ad9b07e399 chore(release): 1.1.0
Molecule / molecule (pull_request) Successful in 3m13s
Build / build (pull_request) Successful in 21s
Lint / lint (pull_request) Successful in 17s
Adds the fail2ban role. Version bump in galaxy.yml, the changelog built by
antsibull-changelog release, README pin example and status text, CLAUDE.md.

Verified: the commit hooks. Not verified: ansible-test sanity and the
importer (CI). The tag is the maintainer's.

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01MmzvM9skAvYcph2c9EiPcm
2026-11-08 21:29:32 +00:00
Defame1297 565b369533 Merge pull request 'feat(fail2ban): add the fail2ban role' (#74) from feat/fail2ban-role into main
Build / build (push) Successful in 22s
Molecule / molecule (push) Successful in 3m12s
Lint / lint (push) Successful in 16s
Reviewed-on: #74
2026-11-08 21:28:33 +00:00
Defame1297andClaude Sonnet 5.5 1ea478b124 feat(fail2ban): add the fail2ban role
Molecule / molecule (pull_request) Successful in 3m11s
Build / build (pull_request) Successful in 23s
Lint / lint (pull_request) Successful in 16s
Copied from the environment repository's roles/fail2ban and scrubbed for the
Collection: galaxy namespace mortis, the molecule scenario calls the role by
its FQCN (and takes its paths from the workflow, like docker's), README
examples use mortis.kamino.fail2ban, repository-local issue references are
dropped. mock_roles in .ansible-lint lists the new FQCN.

Not verified locally: the molecule scenario (runs on the kamino-molecule
runner in CI) and ansible-test sanity.

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01MmzvM9skAvYcph2c9EiPcm
2026-11-08 21:20:08 +00:00
Defame1297 8ff66fb4e8 Merge pull request 'chore(release): 1.0.0' (#73) from release/1.0.0 into main
Molecule / molecule (push) Successful in 2m23s
Build / build (push) Successful in 22s
Lint / lint (push) Successful in 13s
Reviewed-on: #73
2026-11-08 19:28:00 +00:00
Defame1297andClaude Sonnet 5.5 562ed76bfc chore(release): 1.0.0
Molecule / molecule (pull_request) Successful in 2m18s
Build / build (pull_request) Successful in 22s
Lint / lint (pull_request) Successful in 15s
First release, holding the docker role. Version bump in galaxy.yml, the
changelog built by antsibull-changelog release, README and CLAUDE.md no
longer say there are no roles, CHANGELOG.rst is allowed in the archive
(scripts/check_tarball.py) and the generated changelog.yaml is exempt from
yamllint like changelogs/config.yaml.

Verified: the commit hooks; the tarball script's unit tests; a local
ansible-galaxy build of 1.0.0 passes scripts/check_tarball.py. Not verified:
ansible-test sanity and the importer (CI). The tag is the maintainer's.

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01MmzvM9skAvYcph2c9EiPcm
2026-11-08 19:23:44 +00:00
Defame1297 c7d3661887 Merge pull request 'feat(docker): add the docker role (#522)' (#72) from feat/522-docker-role into main
Build / build (push) Successful in 23s
Molecule / molecule (push) Successful in 2m19s
Lint / lint (push) Successful in 14s
Reviewed-on: #72
2026-11-08 19:20:10 +00:00
Defame1297andClaude Sonnet 5.5 922c00ceb0 fix(docker): put the sanity ignore comment on the entry line
Molecule / molecule (pull_request) Successful in 2m18s
Build / build (pull_request) Successful in 22s
Lint / lint (pull_request) Successful in 15s
ansible-test's ignores test rejects a line that holds only a comment.

Verified: the commit hooks.

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01MmzvM9skAvYcph2c9EiPcm
2026-11-08 19:14:11 +00:00
Defame1297andClaude Sonnet 5.5 733d077bdb fix(docker): ignore the shebang sanity test for the molecule helper script
Molecule / molecule (pull_request) Successful in 2m22s
Build / build (pull_request) Failing after 23s
Lint / lint (pull_request) Successful in 14s
ansible-test sanity rejects the bash shebang of the scenario's
build-stub-repo.sh. The script is run by the scenario, not by Ansible, so it
keeps its shebang and gets an ignore entry.

Verified: the commit hooks.

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01MmzvM9skAvYcph2c9EiPcm
2026-11-08 19:08:47 +00:00
Defame1297andClaude Sonnet 5.5 aad59fc339 feat(docker): add the docker role (#522)
Molecule / molecule (pull_request) Successful in 2m18s
Build / build (pull_request) Failing after 22s
Lint / lint (pull_request) Successful in 15s
Extracted from the environment repository, wave 1. Scrubbed of private
references: namespace mortis, no repository paths or issue numbers in
comments and docs, the removed docker_ufw_rules guard dropped, the molecule
scenario uses the FQCN and no provisioner environment overrides.
ansible-lint mocks the role's FQCN because CI checks the Collection out
outside an ansible_collections path.

Verified: the commit hooks. Not verified: the molecule scenario (CI only).

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01MmzvM9skAvYcph2c9EiPcm
2026-11-08 18:59:26 +00:00
Defame1297 903a1a2e5a Merge pull request 'docs(security): publish [email protected] as the reporting contact' (#71) from docs/security-contact into main
Build / build (push) Successful in 21s
Lint / lint (push) Successful in 12s
Reviewed-on: #71
2026-11-08 18:26:09 +00:00
Defame1297andClaude Sonnet 5.5 16fac625a7 docs(security): publish [email protected] as the reporting contact
Molecule / molecule (pull_request) Successful in 1m3s
Build / build (pull_request) Successful in 21s
Lint / lint (pull_request) Successful in 14s
The forge has self-registration disabled, so outsiders cannot open issues or pull requests and a detail-free public issue is not a usable first step. SECURITY.md now gives an email address, and CONTRIBUTING.md says accounts are created by the maintainer.

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01MmzvM9skAvYcph2c9EiPcm
2026-11-08 18:23:25 +00:00
Defame1297andClaude Sonnet 5.5 bdfc420249 docs(security): state that reports start as a detail-free public issue
Molecule / molecule (pull_request) Successful in 1m4s
Lint / lint (pull_request) Successful in 13s
Build / build (pull_request) Successful in 22s
The forge has no private vulnerability reporting or direct messages, so the policy no longer promises a private channel it cannot offer.

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01MmzvM9skAvYcph2c9EiPcm
2026-11-08 18:20:59 +00:00
Defame1297 cf9d4cbc9a Merge pull request 'docs: prepare the repository for publication' (#70) from chore/public-readiness into main
Build / build (push) Successful in 22s
Images / image (Dockerfile, ubuntu:24.04@sha256:fe81560990fae86dc4743202b2cb4d3df98d0bcf949173cecef15ce1127ef852, molecule-ubuntu2404, images/molecule-ubuntu2404, 0.1.5) (push) Successful in 8s
Molecule / molecule (push) Successful in 1m5s
Lint / lint (push) Successful in 16s
Images / image (Dockerfile, ubuntu:26.04@sha256:6a06111c3b0a8600feadb270aec771dc239bf407b25625f93f44ab00e11f4d3c, molecule-ubuntu2604, images/molecule-ubuntu2604, 0.1.3) (push) Successful in 10s
Images / image (images/ci/Dockerfile, ubuntu:26.04@sha256:6a06111c3b0a8600feadb270aec771dc239bf407b25625f93f44ab00e11f4d3c, ci, , 0.2.14) (push) Successful in 10s
Reviewed-on: #70
2026-11-08 18:17:58 +00:00
Defame1297andClaude Sonnet 5.5 686d02d7f7 fix(build): keep SECURITY.md out of the Collection archive
Molecule / molecule (pull_request) Successful in 1m5s
Build / build (pull_request) Successful in 22s
Lint / lint (pull_request) Successful in 14s
scripts/check_tarball.py rejects any top-level file outside its allowlist, so the new SECURITY.md failed Build and the tarball test in Lint. It is repository documentation like CONTRIBUTING.md, so it goes in build_ignore.

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01MmzvM9skAvYcph2c9EiPcm
2026-11-08 17:52:57 +00:00
Defame1297andClaude Sonnet 5.5 79a78f2921 docs: prepare the repository for publication
Molecule / molecule (pull_request) Successful in 1m8s
Build / build (pull_request) Failing after 4s
Lint / lint (pull_request) Failing after 12s
Rewrite stale gate wording and trim private references so the repository
can be made public.

- molecule.yml header: the runner sits in an isolated network segment, not
  behind the Proxmox firewall; state that a fork PR's workflow started
  without approval in a live test (unproven for outsiders) and that the
  `if:` guard is a convenience, not a boundary. Fork PRs are not claimed
  disabled; the repository should not accept them from untrusted users.
- CONTRIBUTING.md: same fork PR statement.
- SECURITY.md: new, with a TODO(operator) for the reporting contact.
- CLAUDE.md trimmed. Removed: the private environment-repo links and issue
  numbers, the two-sentence extraction history, run numbers, the registry
  push secret names and the Renovate token name and scopes, the Renovate
  dry-run and first-live-run narrative, the runner hostname and the
  cron time. Kept: git -C and commit-with-git rules, runner labels, image
  and Renovate rules.
- ADR 0004 references in workflows and scripts now say it lives in the
  maintainer's environment repository; docs/images/ci.md drops "private".

Comment and doc text only; image pins, the bot e-mail and runner labels
are unchanged.

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01MmzvM9skAvYcph2c9EiPcm
2026-11-08 17:38:58 +00:00
kamino-renovate Bot 3c9a93603e Merge pull request 'chore(deps): update dependency ansible-core to v2.22.0' (#67) from renovate/ansible-tooling into main
Build / build (push) Successful in 26s
Images / image (Dockerfile, ubuntu:24.04@sha256:fe81560990fae86dc4743202b2cb4d3df98d0bcf949173cecef15ce1127ef852, molecule-ubuntu2404, images/molecule-ubuntu2404, 0.1.5) (push) Successful in 14s
Images / image (images/ci/Dockerfile, ubuntu:26.04@sha256:6a06111c3b0a8600feadb270aec771dc239bf407b25625f93f44ab00e11f4d3c, ci, , 0.2.14) (push) Successful in 2m59s
Lint / lint (push) Successful in 14s
Images / image (Dockerfile, ubuntu:26.04@sha256:6a06111c3b0a8600feadb270aec771dc239bf407b25625f93f44ab00e11f4d3c, molecule-ubuntu2604, images/molecule-ubuntu2604, 0.1.3) (push) Successful in 10s
2026-11-08 03:19:37 +00:00
renovate-bot e0a7c778dd chore(deps): update dependency ansible-core to v2.22.0
renovate/stability-days Updates have met minimum release age requirement
Molecule / molecule (pull_request) Successful in 1m5s
Lint / lint (pull_request) Successful in 17s
Build / build (pull_request) Successful in 28s
2026-11-08 03:17:45 +00:00
kamino-renovate Bot 863e651017 Merge pull request 'chore(deps): update git.rkdr.net/mortis/ci docker tag to v0.2.13' (#68) from renovate/git.rkdr.net-mortis-ci-0.x into main
Build / build (push) Successful in 9s
Lint / lint (push) Successful in 12s
2026-11-07 03:19:32 +00:00
renovate-bot 0d945da1fc chore(deps): update git.rkdr.net/mortis/ci docker tag to v0.2.13
renovate/stability-days Updates have met minimum release age requirement
Molecule / molecule (pull_request) Successful in 1m5s
Build / build (pull_request) Successful in 22s
Lint / lint (pull_request) Successful in 13s
2026-11-07 03:17:47 +00:00
kamino-renovate Bot 57956b1662 Merge pull request 'chore(deps): update dependency uv to v0.13.7' (#66) from renovate/uv-0.x into main
Build / build (push) Successful in 11s
Images / image (Dockerfile, ubuntu:24.04@sha256:fe81560990fae86dc4743202b2cb4d3df98d0bcf949173cecef15ce1127ef852, molecule-ubuntu2404, images/molecule-ubuntu2404, 0.1.5) (push) Successful in 9s
Images / image (images/ci/Dockerfile, ubuntu:26.04@sha256:6a06111c3b0a8600feadb270aec771dc239bf407b25625f93f44ab00e11f4d3c, ci, , 0.2.13) (push) Successful in 2m54s
Lint / lint (push) Successful in 11s
Images / image (Dockerfile, ubuntu:26.04@sha256:6a06111c3b0a8600feadb270aec771dc239bf407b25625f93f44ab00e11f4d3c, molecule-ubuntu2604, images/molecule-ubuntu2604, 0.1.3) (push) Successful in 9s
2026-11-06 03:19:12 +00:00
renovate-bot e5c5f1377d chore(deps): update dependency uv to v0.13.7
renovate/stability-days Updates have met minimum release age requirement
Molecule / molecule (pull_request) Successful in 57s
Lint / lint (pull_request) Successful in 13s
Build / build (pull_request) Successful in 12s
2026-11-06 03:17:46 +00:00
kamino-renovate Bot 898898480f Merge pull request 'chore(deps): update git.rkdr.net/mortis/ci docker tag to v0.2.12' (#65) from renovate/git.rkdr.net-mortis-ci-0.x into main
Build / build (push) Successful in 10s
Lint / lint (push) Successful in 11s
2026-11-03 03:19:32 +00:00
renovate-bot a9d216b64b chore(deps): update git.rkdr.net/mortis/ci docker tag to v0.2.12
renovate/stability-days Updates have met minimum release age requirement
Molecule / molecule (pull_request) Successful in 1m7s
Build / build (pull_request) Successful in 22s
Lint / lint (pull_request) Successful in 13s
2026-11-03 03:17:48 +00:00
kamino-renovate Bot 7904c4db38 Merge pull request 'chore(deps): update dependency reuse to v6.3.0' (#64) from renovate/reuse-6.x into main
Build / build (push) Successful in 11s
Images / image (Dockerfile, ubuntu:24.04@sha256:fe81560990fae86dc4743202b2cb4d3df98d0bcf949173cecef15ce1127ef852, molecule-ubuntu2404, images/molecule-ubuntu2404, 0.1.5) (push) Successful in 11s
Images / image (images/ci/Dockerfile, ubuntu:26.04@sha256:6a06111c3b0a8600feadb270aec771dc239bf407b25625f93f44ab00e11f4d3c, ci, , 0.2.12) (push) Successful in 3m2s
Lint / lint (push) Successful in 13s
Images / image (Dockerfile, ubuntu:26.04@sha256:6a06111c3b0a8600feadb270aec771dc239bf407b25625f93f44ab00e11f4d3c, molecule-ubuntu2604, images/molecule-ubuntu2604, 0.1.3) (push) Successful in 13s
2026-11-02 16:51:15 +00:00
renovate-bot 6459583a57 chore(deps): update dependency reuse to v6.3.0
renovate/stability-days Updates have met minimum release age requirement
Molecule / molecule (pull_request) Successful in 56s
Build / build (pull_request) Successful in 12s
Lint / lint (pull_request) Successful in 13s
2026-11-02 16:49:49 +00:00
kamino-renovate Bot 6e6d4cda03 Merge pull request 'chore(deps): update git.rkdr.net/mortis/ci docker tag to v0.2.11' (#63) from renovate/git.rkdr.net-mortis-ci-0.x into main
Build / build (push) Successful in 10s
Lint / lint (push) Successful in 12s
2026-11-02 03:19:16 +00:00
renovate-bot 212c4d38bb chore(deps): update git.rkdr.net/mortis/ci docker tag to v0.2.11
renovate/stability-days Updates have met minimum release age requirement
Molecule / molecule (pull_request) Successful in 56s
Build / build (pull_request) Successful in 21s
Lint / lint (pull_request) Successful in 13s
2026-11-02 03:17:44 +00:00
kamino-renovate Bot 91097f7919 Merge pull request 'chore(deps): update git.rkdr.net/mortis/molecule-ubuntu2604 docker tag to v0.1.3' (#62) from renovate/git.rkdr.net-mortis-molecule-ubuntu2604-0.x into main
Build / build (push) Successful in 10s
Molecule / molecule (push) Successful in 1m7s
Lint / lint (push) Successful in 12s
2026-11-01 20:40:17 +00:00
Defame1297 0ba3f5b389 Merge branch 'main' into renovate/git.rkdr.net-mortis-molecule-ubuntu2604-0.x
Molecule / molecule (pull_request) Successful in 1m5s
Build / build (pull_request) Successful in 10s
Lint / lint (pull_request) Successful in 13s
2026-11-01 20:37:09 +00:00
kamino-renovate Bot 070002c8a6 Merge pull request 'chore(deps): update git.rkdr.net/mortis/molecule-ubuntu2404 docker tag to v0.1.5' (#61) from renovate/git.rkdr.net-mortis-molecule-ubuntu2404-0.x into main
Molecule / molecule (push) Canceled after 0s
Build / build (push) Successful in 11s
Lint / lint (push) Successful in 13s
2026-11-01 20:33:14 +00:00
renovate-bot deebbfeae0 chore(deps): update git.rkdr.net/mortis/molecule-ubuntu2604 docker tag to v0.1.3
renovate/stability-days Updates have met minimum release age requirement
Molecule / molecule (pull_request) Successful in 1m5s
Lint / lint (pull_request) Successful in 12s
Build / build (pull_request) Successful in 10s
2026-11-01 20:31:28 +00:00
renovate-bot c5d783d59c chore(deps): update git.rkdr.net/mortis/molecule-ubuntu2404 docker tag to v0.1.5
renovate/stability-days Updates have met minimum release age requirement
Molecule / molecule (pull_request) Successful in 1m1s
Lint / lint (pull_request) Successful in 15s
Build / build (pull_request) Successful in 11s
2026-11-01 20:31:26 +00:00
Defame1297 e72fa18e8a Merge pull request 'chore(deps): update ubuntu:26.04 docker digest to 6a06111' (#60) from renovate/job-container-ubuntu-26.04 into main
Build / build (push) Successful in 10s
Images / image (Dockerfile, ubuntu:24.04@sha256:fe81560990fae86dc4743202b2cb4d3df98d0bcf949173cecef15ce1127ef852, molecule-ubuntu2404, images/molecule-ubuntu2404, 0.1.5) (push) Successful in 14s
Lint / lint (push) Successful in 12s
Images / image (Dockerfile, ubuntu:26.04@sha256:6a06111c3b0a8600feadb270aec771dc239bf407b25625f93f44ab00e11f4d3c, molecule-ubuntu2604, images/molecule-ubuntu2604, 0.1.3) (push) Successful in 17s
Images / image (images/ci/Dockerfile, ubuntu:26.04@sha256:6a06111c3b0a8600feadb270aec771dc239bf407b25625f93f44ab00e11f4d3c, ci, , 0.2.11) (push) Successful in 3m41s
Reviewed-on: #60
2026-11-01 20:29:28 +00:00
Defame1297 1a7b994ff4 Merge branch 'main' into renovate/job-container-ubuntu-26.04
Molecule / molecule (pull_request) Successful in 57s
Lint / lint (pull_request) Successful in 26s
Build / build (pull_request) Successful in 10s
2026-10-30 15:17:56 +00:00
kamino-renovate Bot 5c2b523d73 Merge pull request 'chore(deps): update ubuntu:26.04 docker digest to 6a06111' (#59) from renovate/ubuntu-26.04 into main
Build / build (push) Successful in 10s
Images / image (Dockerfile, ubuntu:24.04@sha256:fe81560990fae86dc4743202b2cb4d3df98d0bcf949173cecef15ce1127ef852, molecule-ubuntu2404, images/molecule-ubuntu2404, 0.1.5) (push) Successful in 10s
Images / image (Dockerfile, ubuntu:26.04@sha256:19fcd1bf268f02b60aca3bd30bd8a6d9a11759a430e32921833e65f16d87348a, molecule-ubuntu2604, images/molecule-ubuntu2604, 0.1.3) (push) Successful in 32s
Images / image (images/ci/Dockerfile, ubuntu:26.04@sha256:19fcd1bf268f02b60aca3bd30bd8a6d9a11759a430e32921833e65f16d87348a, ci, , 0.2.11) (push) Failing after 3m33s
Lint / lint (push) Successful in 12s
2026-10-30 15:15:44 +00:00
Defame1297 09813a866c Merge branch 'main' into renovate/ubuntu-26.04
Molecule / molecule (pull_request) Successful in 1m1s
Build / build (pull_request) Successful in 10s
Lint / lint (pull_request) Successful in 12s
2026-10-30 15:14:17 +00:00
Defame1297 bd055a02db Merge pull request 'chore(deps): update ubuntu:24.04 docker digest to fe81560' (#58) from renovate/job-container-ubuntu-24.04 into main
Build / build (push) Successful in 11s
Images / image (Dockerfile, ubuntu:24.04@sha256:fe81560990fae86dc4743202b2cb4d3df98d0bcf949173cecef15ce1127ef852, molecule-ubuntu2404, images/molecule-ubuntu2404, 0.1.5) (push) Successful in 12s
Lint / lint (push) Successful in 13s
Images / image (Dockerfile, ubuntu:26.04@sha256:19fcd1bf268f02b60aca3bd30bd8a6d9a11759a430e32921833e65f16d87348a, molecule-ubuntu2604, images/molecule-ubuntu2604, 0.1.2) (push) Successful in 12s
Images / image (images/ci/Dockerfile, ubuntu:26.04@sha256:19fcd1bf268f02b60aca3bd30bd8a6d9a11759a430e32921833e65f16d87348a, ci, , 0.2.10) (push) Successful in 13s
Reviewed-on: #58
2026-10-30 15:08:30 +00:00
Defame1297 48959a632b Merge branch 'main' into renovate/job-container-ubuntu-24.04
Molecule / molecule (pull_request) Successful in 1m5s
Build / build (pull_request) Successful in 10s
Lint / lint (pull_request) Successful in 13s
2026-10-30 15:06:28 +00:00
kamino-renovate Bot a2c8f14321 Merge pull request 'chore(deps): update ubuntu:24.04 docker digest to fe81560' (#57) from renovate/ubuntu-24.04 into main
Build / build (push) Successful in 10s
Images / image (Dockerfile, ubuntu:24.04@sha256:24737cef17f4e22b1977df7d9a05e77c4e28b7da5b8911f8d8ccda136bf3573c, molecule-ubuntu2404, images/molecule-ubuntu2404, 0.1.5) (push) Successful in 31s
Lint / lint (push) Successful in 12s
Images / image (Dockerfile, ubuntu:26.04@sha256:19fcd1bf268f02b60aca3bd30bd8a6d9a11759a430e32921833e65f16d87348a, molecule-ubuntu2604, images/molecule-ubuntu2604, 0.1.2) (push) Successful in 14s
Images / image (images/ci/Dockerfile, ubuntu:26.04@sha256:19fcd1bf268f02b60aca3bd30bd8a6d9a11759a430e32921833e65f16d87348a, ci, , 0.2.10) (push) Successful in 12s
2026-10-30 15:03:59 +00:00
renovate-bot 7697cd98ea chore(deps): update ubuntu:26.04 docker digest to 6a06111
renovate/stability-days Updates have met minimum release age requirement
Molecule / molecule (pull_request) Successful in 58s
Build / build (pull_request) Successful in 9s
Lint / lint (pull_request) Successful in 12s
2026-10-30 15:02:27 +00:00
renovate-bot 5019343242 chore(deps): update ubuntu:26.04 docker digest to 6a06111
renovate/stability-days Updates have met minimum release age requirement
Molecule / molecule (pull_request) Canceled after 0s
Build / build (pull_request) Successful in 10s
Lint / lint (pull_request) Successful in 13s
2026-10-30 15:02:25 +00:00
renovate-bot 1e51850b33 chore(deps): update ubuntu:24.04 docker digest to fe81560
renovate/stability-days Updates have met minimum release age requirement
Molecule / molecule (pull_request) Canceled after 0s
Build / build (pull_request) Successful in 11s
Lint / lint (pull_request) Successful in 13s
2026-10-30 15:02:24 +00:00
renovate-bot 4c7f461850 chore(deps): update ubuntu:24.04 docker digest to fe81560
renovate/stability-days Updates have met minimum release age requirement
Molecule / molecule (pull_request) Successful in 1m1s
Build / build (pull_request) Successful in 13s
Lint / lint (pull_request) Successful in 15s
2026-10-30 15:02:22 +00:00
kamino-renovate Bot 0c590a38f8 Merge pull request 'chore(deps): update git.rkdr.net/mortis/molecule-ubuntu2604 docker tag to v0.1.2' (#56) from renovate/git.rkdr.net-mortis-molecule-ubuntu2604-0.x into main
Build / build (push) Successful in 10s
Molecule / molecule (push) Successful in 1m2s
Lint / lint (push) Successful in 12s
2026-10-27 10:50:09 +00:00
Defame1297 186839ac3d Merge branch 'main' into renovate/git.rkdr.net-mortis-molecule-ubuntu2604-0.x
Molecule / molecule (pull_request) Successful in 1m6s
Build / build (pull_request) Successful in 11s
Lint / lint (pull_request) Successful in 12s
2026-10-27 10:48:26 +00:00
kamino-renovate Bot 4eaefa3738 Merge pull request 'chore(deps): update git.rkdr.net/mortis/molecule-ubuntu2404 docker tag to v0.1.4' (#55) from renovate/git.rkdr.net-mortis-molecule-ubuntu2404-0.x into main
Build / build (push) Successful in 11s
Molecule / molecule (push) Successful in 1m10s
Lint / lint (push) Successful in 13s
2026-10-27 10:46:57 +00:00
Defame1297 20312e8fc2 Merge branch 'main' into renovate/git.rkdr.net-mortis-molecule-ubuntu2404-0.x
Molecule / molecule (pull_request) Successful in 1m7s
Build / build (pull_request) Successful in 13s
Lint / lint (pull_request) Successful in 15s
2026-10-27 10:45:15 +00:00
kamino-renovate Bot cc301bbff2 Merge pull request 'chore(deps): update git.rkdr.net/mortis/ci docker tag to v0.2.10' (#54) from renovate/git.rkdr.net-mortis-ci-0.x into main
Build / build (push) Successful in 11s
Lint / lint (push) Successful in 14s
2026-10-27 10:42:13 +00:00
renovate-bot 3d8986c12d chore(deps): update git.rkdr.net/mortis/molecule-ubuntu2604 docker tag to v0.1.2
renovate/stability-days Updates have met minimum release age requirement
Molecule / molecule (pull_request) Successful in 1m8s
Build / build (pull_request) Successful in 13s
Lint / lint (pull_request) Successful in 16s
2026-10-27 10:40:06 +00:00
renovate-bot 4567093418 chore(deps): update git.rkdr.net/mortis/molecule-ubuntu2404 docker tag to v0.1.4
renovate/stability-days Updates have met minimum release age requirement
Molecule / molecule (pull_request) Canceled after 0s
Build / build (pull_request) Successful in 15s
Lint / lint (pull_request) Successful in 17s
2026-10-27 10:40:00 +00:00
renovate-bot 76ad68574d chore(deps): update git.rkdr.net/mortis/ci docker tag to v0.2.10
renovate/stability-days Updates have met minimum release age requirement
Molecule / molecule (pull_request) Successful in 1m14s
Build / build (pull_request) Successful in 31s
Lint / lint (pull_request) Successful in 15s
2026-10-27 10:39:53 +00:00
kamino-renovate Bot 39f77012d3 Merge pull request 'chore(deps): update dependency uv to v0.13.6' (#53) from renovate/uv-0.x into main
Build / build (push) Successful in 10s
Images / image (Dockerfile, ubuntu:24.04@sha256:24737cef17f4e22b1977df7d9a05e77c4e28b7da5b8911f8d8ccda136bf3573c, molecule-ubuntu2404, images/molecule-ubuntu2404, 0.1.4) (push) Successful in 9s
Lint / lint (push) Successful in 11s
Images / image (Dockerfile, ubuntu:26.04@sha256:19fcd1bf268f02b60aca3bd30bd8a6d9a11759a430e32921833e65f16d87348a, molecule-ubuntu2604, images/molecule-ubuntu2604, 0.1.2) (push) Successful in 11s
Images / image (images/ci/Dockerfile, ubuntu:26.04@sha256:19fcd1bf268f02b60aca3bd30bd8a6d9a11759a430e32921833e65f16d87348a, ci, , 0.2.10) (push) Successful in 3m14s
2026-10-27 10:34:44 +00:00
renovate-bot 6229342b93 chore(deps): update dependency uv to v0.13.6
renovate/stability-days Updates have not met minimum release age requirement
Molecule / molecule (pull_request) Successful in 1m2s
Build / build (pull_request) Successful in 10s
Lint / lint (pull_request) Successful in 13s
2026-10-27 10:33:17 +00:00
Defame1297 f302d701a4 Merge pull request 'chore(deps): update ubuntu:26.04 docker digest to 19fcd1b' (#52) from renovate/job-container-ubuntu-26.04 into main
Build / build (push) Successful in 11s
Images / image (Dockerfile, ubuntu:24.04@sha256:24737cef17f4e22b1977df7d9a05e77c4e28b7da5b8911f8d8ccda136bf3573c, molecule-ubuntu2404, images/molecule-ubuntu2404, 0.1.4) (push) Successful in 10s
Images / image (images/ci/Dockerfile, ubuntu:26.04@sha256:19fcd1bf268f02b60aca3bd30bd8a6d9a11759a430e32921833e65f16d87348a, ci, , 0.2.9) (push) Successful in 10s
Lint / lint (push) Successful in 13s
Images / image (Dockerfile, ubuntu:26.04@sha256:19fcd1bf268f02b60aca3bd30bd8a6d9a11759a430e32921833e65f16d87348a, molecule-ubuntu2604, images/molecule-ubuntu2604, 0.1.2) (push) Successful in 13s
Reviewed-on: #52
2026-10-27 10:25:12 +00:00
Defame1297 1a7708ad4c Merge branch 'main' into renovate/job-container-ubuntu-26.04
Molecule / molecule (pull_request) Successful in 1m9s
Build / build (pull_request) Successful in 11s
Lint / lint (pull_request) Successful in 14s
2026-10-27 10:23:18 +00:00
kamino-renovate Bot 9312ab98dd Merge pull request 'chore(deps): update ubuntu:26.04 docker digest to 19fcd1b' (#51) from renovate/ubuntu-26.04 into main
Build / build (push) Successful in 11s
Images / image (Dockerfile, ubuntu:24.04@sha256:24737cef17f4e22b1977df7d9a05e77c4e28b7da5b8911f8d8ccda136bf3573c, molecule-ubuntu2404, images/molecule-ubuntu2404, 0.1.4) (push) Successful in 14s
Images / image (images/ci/Dockerfile, ubuntu:26.04@sha256:c098726dd9b9733f3e885f8de0ef375206a311b0a317eadc40d347b1115fb944, ci, , 0.2.9) (push) Successful in 3m10s
Lint / lint (push) Successful in 13s
Images / image (Dockerfile, ubuntu:26.04@sha256:c098726dd9b9733f3e885f8de0ef375206a311b0a317eadc40d347b1115fb944, molecule-ubuntu2604, images/molecule-ubuntu2604, 0.1.2) (push) Successful in 35s
2026-10-27 10:22:08 +00:00
Defame1297 5adda40e43 Merge branch 'main' into renovate/ubuntu-26.04
Molecule / molecule (pull_request) Successful in 1m4s
Build / build (pull_request) Successful in 11s
Lint / lint (pull_request) Successful in 14s
2026-10-27 10:20:18 +00:00
Defame1297 7f22b23244 Merge pull request 'chore(deps): update ubuntu:24.04 docker digest to 24737ce' (#50) from renovate/job-container-ubuntu-24.04 into main
Build / build (push) Successful in 12s
Images / image (Dockerfile, ubuntu:24.04@sha256:24737cef17f4e22b1977df7d9a05e77c4e28b7da5b8911f8d8ccda136bf3573c, molecule-ubuntu2404, images/molecule-ubuntu2404, 0.1.4) (push) Successful in 12s
Images / image (Dockerfile, ubuntu:26.04@sha256:c098726dd9b9733f3e885f8de0ef375206a311b0a317eadc40d347b1115fb944, molecule-ubuntu2604, images/molecule-ubuntu2604, 0.1.1) (push) Successful in 12s
Lint / lint (push) Successful in 14s
Images / image (images/ci/Dockerfile, ubuntu:26.04@sha256:c098726dd9b9733f3e885f8de0ef375206a311b0a317eadc40d347b1115fb944, ci, , 0.2.8) (push) Successful in 12s
Reviewed-on: #50
2026-10-27 10:19:50 +00:00
Defame1297 fd8406906f Merge branch 'main' into renovate/job-container-ubuntu-24.04
Molecule / molecule (pull_request) Successful in 1m15s
Lint / lint (pull_request) Successful in 14s
Build / build (pull_request) Successful in 11s
2026-10-27 10:17:20 +00:00
kamino-renovate Bot 4e00123dbc Merge pull request 'chore(deps): update ubuntu:24.04 docker digest to 24737ce' (#49) from renovate/ubuntu-24.04 into main
Build / build (push) Successful in 11s
Images / image (Dockerfile, ubuntu:24.04@sha256:68ee22004a9109b44973313b02ff7b1de250f1de0f5ecb628d73f579aaff33ac, molecule-ubuntu2404, images/molecule-ubuntu2404, 0.1.4) (push) Successful in 34s
Images / image (Dockerfile, ubuntu:26.04@sha256:c098726dd9b9733f3e885f8de0ef375206a311b0a317eadc40d347b1115fb944, molecule-ubuntu2604, images/molecule-ubuntu2604, 0.1.1) (push) Successful in 12s
Lint / lint (push) Successful in 13s
Images / image (images/ci/Dockerfile, ubuntu:26.04@sha256:c098726dd9b9733f3e885f8de0ef375206a311b0a317eadc40d347b1115fb944, ci, , 0.2.8) (push) Successful in 12s
2026-10-27 10:14:18 +00:00
renovate-bot 97842f0734 chore(deps): update ubuntu:26.04 docker digest to 19fcd1b
renovate/stability-days Updates have met minimum release age requirement
Molecule / molecule (pull_request) Canceled after 0s
Build / build (pull_request) Successful in 11s
Lint / lint (pull_request) Successful in 14s
2026-10-27 10:12:37 +00:00
renovate-bot fe003fbbea chore(deps): update ubuntu:26.04 docker digest to 19fcd1b
renovate/stability-days Updates have met minimum release age requirement
Molecule / molecule (pull_request) Canceled after 0s
Lint / lint (pull_request) Successful in 14s
Build / build (pull_request) Successful in 12s
2026-10-27 10:12:35 +00:00
renovate-bot 53efd72e0a chore(deps): update ubuntu:24.04 docker digest to 24737ce
renovate/stability-days Updates have met minimum release age requirement
Molecule / molecule (pull_request) Canceled after 0s
Build / build (pull_request) Successful in 12s
Lint / lint (pull_request) Successful in 14s
2026-10-27 10:12:33 +00:00
renovate-bot 18135969d4 chore(deps): update ubuntu:24.04 docker digest to 24737ce
renovate/stability-days Updates have met minimum release age requirement
Molecule / molecule (pull_request) Successful in 1m8s
Build / build (pull_request) Successful in 13s
Lint / lint (pull_request) Successful in 15s
2026-10-27 10:12:31 +00:00
Defame1297 1a98aed1b0 Merge pull request 'ci(renovate): drop the report shape dump and record what the report cannot tell' (#48) from ci/renovate-drop-report-dump into main
Build / build (push) Successful in 9s
Lint / lint (push) Successful in 12s
Reviewed-on: #48
2026-10-26 20:25:31 +00:00
Defame1297andClaude Sonnet 5.5 b0e7932a76 ci(renovate): drop the report shape dump and record what the report cannot tell
Molecule / molecule (pull_request) Successful in 59s
Build / build (pull_request) Successful in 10s
Lint / lint (pull_request) Successful in 12s
Run 2597 printed it: a branch entry holds branchName, prNo, prTitle, result and upgrades, with no
field for a failed post-upgrade task. The protection against an unbumped pull request stays the
red renovate/artifacts status and the bump check in Lint.

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01MmzvM9skAvYcph2c9EiPcm
2026-10-26 20:22:20 +00:00
kamino-renovate Bot 23face54cf Merge pull request 'chore(deps): update git.rkdr.net/mortis/ci docker tag to v0.2.8' (#47) from renovate/git.rkdr.net-mortis-ci-0.x into main
Build / build (push) Successful in 9s
Lint / lint (push) Successful in 12s
2026-10-26 20:18:01 +00:00
renovate-bot 934112e7d9 chore(deps): update git.rkdr.net/mortis/ci docker tag to v0.2.8
renovate/stability-days Updates have met minimum release age requirement
Molecule / molecule (pull_request) Successful in 1m3s
Build / build (pull_request) Successful in 23s
Lint / lint (pull_request) Successful in 12s
2026-10-26 20:16:19 +00:00
Defame1297 a565050451 Merge pull request 'ci: run Molecule on every same-repo pull request and print the Renovate report shape' (#46) from ci/molecule-on-all-prs into main
Build / build (push) Successful in 11s
Molecule / molecule (push) Successful in 1m2s
Lint / lint (push) Successful in 12s
Reviewed-on: #46
2026-10-26 20:14:14 +00:00
Defame1297andClaude Sonnet 5.5 a6583db5d5 ci: run Molecule on every same-repo pull request and print the Renovate report shape
Molecule / molecule (pull_request) Successful in 1m2s
Build / build (pull_request) Successful in 11s
Lint / lint (pull_request) Successful in 13s
Molecule skipped bot branches and used a path filter, so a Renovate pin pull request for the
molecule image merged without a single scenario having run on it (#35, then #44): the first test
of a new image was main. Now it runs on every same-repo pull request, bot branches included, and
with no path filter it can be a required check. A bot pull request stays limited to pin and
version lines by the bot-diff gate, so it adds no capability a pusher does not already have.

The Renovate job prints the shape of its JSON report (top-level keys, per-branch fields) once, so
a check that fails the job on a failed post-upgrade task can be written against a real field.

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01MmzvM9skAvYcph2c9EiPcm
2026-10-26 20:09:55 +00:00
Defame1297 6f9d9c8a9d Merge pull request 'chore(renovate): let ansible-core minor bumps automerge' (#45) from chore/automerge-ansible-core-minor into main
Build / build (push) Successful in 11s
Images / image (Dockerfile, ubuntu:24.04@sha256:68ee22004a9109b44973313b02ff7b1de250f1de0f5ecb628d73f579aaff33ac, molecule-ubuntu2404, images/molecule-ubuntu2404, 0.1.3) (push) Successful in 10s
Images / image (Dockerfile, ubuntu:26.04@sha256:c098726dd9b9733f3e885f8de0ef375206a311b0a317eadc40d347b1115fb944, molecule-ubuntu2604, images/molecule-ubuntu2604, 0.1.1) (push) Successful in 9s
Lint / lint (push) Successful in 12s
Images / image (images/ci/Dockerfile, ubuntu:26.04@sha256:c098726dd9b9733f3e885f8de0ef375206a311b0a317eadc40d347b1115fb944, ci, , 0.2.8) (push) Successful in 3m1s
Reviewed-on: #45
2026-10-26 20:09:00 +00:00
Defame1297andClaude Sonnet 5.5 6d8187aa41 docs(deps): say what a bump of requirements-dev.txt really does
Molecule / molecule (pull_request) Skipped
Build / build (pull_request) Successful in 10s
Lint / lint (pull_request) Successful in 13s
The comment claimed the pins match the environment repo's runner image and that Renovate bumps
them. Now: they started equal and are not kept equal, and a bump rebuilds the ci image and moves
the consumers' pins. The file is an input of the ci image, so ci gets its PATCH bump.

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01MmzvM9skAvYcph2c9EiPcm
2026-10-26 20:08:03 +00:00
Defame1297andClaude Sonnet 5.5 f67ce1c391 chore(renovate): let ansible-core minor bumps automerge
The shared sanity ignore list covers the known findings of a new core, and the Build check
(ansible-test sanity) is the gate: a minor that shows new findings stays red and is not merged.
Majors stay manual through the general rule. Also: the image.yml rule description names the
per-entry job_image lines.

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01MmzvM9skAvYcph2c9EiPcm
2026-10-26 20:03:53 +00:00
kamino-renovate Bot 236cefc95b Merge pull request 'chore(deps): update git.rkdr.net/mortis/molecule-ubuntu2604 docker tag to v0.1.1' (#44) from renovate/git.rkdr.net-mortis-molecule-ubuntu2604-0.x into main
Build / build (push) Successful in 10s
Molecule / molecule (push) Successful in 59s
Lint / lint (push) Successful in 11s
2026-10-26 19:57:05 +00:00
renovate-bot 6c89da43c3 chore(deps): update git.rkdr.net/mortis/molecule-ubuntu2604 docker tag to v0.1.1
Molecule / molecule (pull_request) Skipped
renovate/stability-days Updates have met minimum release age requirement
Build / build (pull_request) Successful in 11s
Lint / lint (pull_request) Successful in 13s
2026-10-26 19:56:37 +00:00
kamino-renovate Bot 392328c0f7 Merge pull request 'chore(deps): update git.rkdr.net/mortis/molecule-ubuntu2404 docker tag to v0.1.3' (#43) from renovate/git.rkdr.net-mortis-molecule-ubuntu2404-0.x into main
Build / build (push) Successful in 10s
Molecule / molecule (push) Successful in 58s
Lint / lint (push) Successful in 12s
2026-10-26 19:54:37 +00:00
Defame1297 37bcae54c5 Merge branch 'main' into renovate/git.rkdr.net-mortis-molecule-ubuntu2404-0.x
Molecule / molecule (pull_request) Skipped
Build / build (pull_request) Successful in 11s
Lint / lint (pull_request) Successful in 12s
2026-10-26 19:53:45 +00:00
kamino-renovate Bot 77c5bac9e1 Merge pull request 'chore(deps): update git.rkdr.net/mortis/ci docker tag to v0.2.7' (#42) from renovate/git.rkdr.net-mortis-ci-0.x into main
Build / build (push) Successful in 10s
Lint / lint (push) Successful in 11s
2026-10-26 19:53:27 +00:00
renovate-bot 00663ed942 chore(deps): update git.rkdr.net/mortis/molecule-ubuntu2404 docker tag to v0.1.3
Molecule / molecule (pull_request) Skipped
renovate/stability-days Updates have met minimum release age requirement
Build / build (pull_request) Successful in 11s
Lint / lint (pull_request) Canceled after 13s
2026-10-26 19:52:45 +00:00
renovate-bot e623c0907b chore(deps): update git.rkdr.net/mortis/ci docker tag to v0.2.7
Molecule / molecule (pull_request) Skipped
renovate/stability-days Updates have met minimum release age requirement
Lint / lint (pull_request) Successful in 13s
Build / build (pull_request) Successful in 24s
2026-10-26 19:52:42 +00:00
Defame1297 f37f448e12 Merge pull request 'fix(image): no single quote in a label (kaniko rejects it) and a check for it' (#41) from fix/image-label-apostrophe into main
Build / build (push) Successful in 10s
Images / image (Dockerfile, ubuntu:24.04@sha256:68ee22004a9109b44973313b02ff7b1de250f1de0f5ecb628d73f579aaff33ac, molecule-ubuntu2404, images/molecule-ubuntu2404, 0.1.3) (push) Successful in 10s
Images / image (Dockerfile, ubuntu:26.04@sha256:c098726dd9b9733f3e885f8de0ef375206a311b0a317eadc40d347b1115fb944, molecule-ubuntu2604, images/molecule-ubuntu2604, 0.1.1) (push) Successful in 10s
Images / image (images/ci/Dockerfile, ubuntu:26.04@sha256:c098726dd9b9733f3e885f8de0ef375206a311b0a317eadc40d347b1115fb944, ci, , 0.2.7) (push) Successful in 3m8s
Lint / lint (push) Successful in 12s
Reviewed-on: #41
2026-10-26 19:45:35 +00:00
Defame1297andClaude Sonnet 5.5 6c85d61827 fix(image): no single quote in a label (kaniko rejects it) and a check for it
Molecule / molecule (pull_request) Skipped
Build / build (pull_request) Successful in 11s
Lint / lint (pull_request) Successful in 13s
Run 2556: the ci image failed at its LABEL step (unexpected end of statement while looking for
matching single-quote) on the apostrophe in 'the distribution's python3'. Docker accepts it,
kaniko's own LABEL parser does not, and the molecule images built only because their labels
have none. The label text is reworded and check_image_versions.py pins now fails on a single
quote in any label. ci 0.2.6 was never pushed; the gate wants a higher version than main's,
so the fix is 0.2.7.

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01MmzvM9skAvYcph2c9EiPcm
2026-10-26 19:44:12 +00:00
Defame1297 c5c98bb543 Merge pull request 'feat(image): describe every image: labels, a readme page and build metadata' (#40) from docs/image-metadata into main
Build / build (push) Successful in 11s
Images / image (Dockerfile, ubuntu:24.04@sha256:68ee22004a9109b44973313b02ff7b1de250f1de0f5ecb628d73f579aaff33ac, molecule-ubuntu2404, images/molecule-ubuntu2404, 0.1.3) (push) Successful in 32s
Molecule / molecule (push) Successful in 57s
Images / image (Dockerfile, ubuntu:26.04@sha256:c098726dd9b9733f3e885f8de0ef375206a311b0a317eadc40d347b1115fb944, molecule-ubuntu2604, images/molecule-ubuntu2604, 0.1.1) (push) Successful in 31s
Images / image (images/ci/Dockerfile, ubuntu:26.04@sha256:c098726dd9b9733f3e885f8de0ef375206a311b0a317eadc40d347b1115fb944, ci, , 0.2.6) (push) Failing after 2m31s
Lint / lint (push) Successful in 12s
Reviewed-on: #40
2026-10-26 19:37:38 +00:00
Defame1297andClaude Sonnet 5.5 b90acd7147 style(tests): one blank line fewer before labelled() (pep8 E303)
Molecule / molecule (pull_request) Successful in 1m6s
Lint / lint (pull_request) Successful in 14s
Build / build (pull_request) Successful in 9s
Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01MmzvM9skAvYcph2c9EiPcm
2026-10-26 19:34:35 +00:00
Defame1297andClaude Sonnet 5.5 aa1848a995 fix(image): act on the review of the image metadata
Molecule / molecule (pull_request) Successful in 58s
Build / build (pull_request) Failing after 10s
Lint / lint (pull_request) Successful in 13s
Label parser: split the LABEL instruction like a shell (a value may hold NAME=value text), read
the last stage only, require base.name and tie it to the FROM tag, require the documentation
link to be <source>/src/branch/main/docs/images/<name>.md and the page to be non-empty.
Docs: do not name a Python version the base may not ship, show the lint.yml pin check as it
is, say which workflow paths start a build, name the system-language local hooks, add the
apparmor option and the registry path to the molecule usage, and soften unverified Renovate
and host-release statements.

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01MmzvM9skAvYcph2c9EiPcm
2026-10-26 19:32:03 +00:00
Defame1297andClaude Sonnet 5.5 c3c665e799 feat(image): describe every image: labels, a readme page and build metadata
The registry page shows the description as plain text, every label, and links to source,
documentation and licence; it renders no readme. Each Dockerfile now carries one label
block (title, description, source, url, documentation, licenses, authors, base.name and
net.rkdr.mortis.purpose/contents/usage), the build adds version, revision and created, and
docs/images/<name>.md says what the image is for, what it contains and how to use it.
check_image_versions.py pins fails when a label or that page is missing. The labels are
image inputs, so the three images get their PATCH bump.

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01MmzvM9skAvYcph2c9EiPcm
2026-10-26 19:27:15 +00:00
Defame1297 01f90c1f6a Merge pull request 'feat(molecule): test the 26.04 image and move the 24.04 pin to 0.1.2' (#39) from feat/molecule-2604-scenario into main
Build / build (push) Successful in 10s
Molecule / molecule (push) Successful in 1m11s
Lint / lint (push) Successful in 12s
Reviewed-on: #39
2026-10-26 19:19:52 +00:00
Defame1297andClaude Sonnet 5.5 b27513f0bd feat(molecule): test the 26.04 image and move the 24.04 pin to 0.1.2
Molecule / molecule (pull_request) Successful in 1m2s
Build / build (pull_request) Successful in 11s
Lint / lint (pull_request) Successful in 12s
Adds the image-smoke-2604 scenario (asserts Ubuntu 26.04) and the MOLECULE_IMAGE_2604 pin
(molecule-ubuntu2604 0.1.0, the digest its first build printed, run 2534). Moves
MOLECULE_IMAGE to molecule-ubuntu2404 0.1.2 (digest printed by run 2541): the 0.1.1 image
is Ubuntu 26.04, so image-smoke has failed on main since the base bump. The Renovate
pattern for the multi-line pin now also reads MOLECULE_IMAGE_<release>.

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01MmzvM9skAvYcph2c9EiPcm
2026-10-26 19:16:51 +00:00
Defame1297 e389cfa10d Merge pull request 'fix(image): give every image its own job container release' (#38) from fix/image-job-container-per-entry into main
Build / build (push) Successful in 10s
Images / image (Dockerfile, ubuntu:24.04@sha256:68ee22004a9109b44973313b02ff7b1de250f1de0f5ecb628d73f579aaff33ac, molecule-ubuntu2404, images/molecule-ubuntu2404, 0.1.2) (push) Successful in 30s
Lint / lint (push) Successful in 11s
Images / image (Dockerfile, ubuntu:26.04@sha256:c098726dd9b9733f3e885f8de0ef375206a311b0a317eadc40d347b1115fb944, molecule-ubuntu2604, images/molecule-ubuntu2604, 0.1.0) (push) Successful in 10s
Images / image (images/ci/Dockerfile, ubuntu:26.04@sha256:c098726dd9b9733f3e885f8de0ef375206a311b0a317eadc40d347b1115fb944, ci, , 0.2.5) (push) Successful in 3m11s
Reviewed-on: #38
2026-10-26 19:09:32 +00:00
Defame1297andClaude Sonnet 5.5 28a96e2ee5 docs(image): correct the ci Dockerfile base-image comment and bump ci to 0.2.5
Molecule / molecule (pull_request) Skipped
Build / build (pull_request) Successful in 10s
Lint / lint (pull_request) Successful in 12s
The comment still named ubuntu:24.04 above a FROM ubuntu:26.04. A Dockerfile edit is an
image input, so ci gets its PATCH bump (scripts/bump_image_versions.py) and a rebuild.

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01MmzvM9skAvYcph2c9EiPcm
2026-10-26 19:08:32 +00:00
Defame1297andClaude Sonnet 5.5 43b8acbe87 fix(image): drop the ci Dockerfile comment edit and the empty f-strings
A comment edit in images/ci/Dockerfile is an image input, so the bump check wants a
version bump and a rebuild for nothing; the stale base comment waits for the next real ci
change. Two test strings had no interpolation (pylint f-string-without-interpolation).

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01MmzvM9skAvYcph2c9EiPcm
2026-10-26 19:06:53 +00:00
Defame1297andClaude Sonnet 5.5 bc5ae09de7 fix(image): make the job container check fail closed
Molecule / molecule (pull_request) Skipped
Lint / lint (pull_request) Failing after 6s
Build / build (pull_request) Failing after 10s
Review findings: a non-ubuntu or variable FROM went unchecked, the registry-prefixed
ubuntu forms were missed, the container line could be satisfied by a lookalike in a run
block, and a quoted job_image passed the check but not the bot-diff guard or Renovate.
Also: stale ci Dockerfile base comment, the pins error now says what to edit, and the
docs state that a job_image-only bump rebuilds nothing.

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01MmzvM9skAvYcph2c9EiPcm
2026-10-26 19:03:19 +00:00
Defame1297andClaude Sonnet 5.5 c3d0d7df65 fix(image): give every image its own job container release
kaniko runs inside the job container and unpacks the image it builds over it, so the
job container must be the same Ubuntu release as the image's FROM lines. A single
ubuntu:26.04 job container broke the molecule-ubuntu2404 build (run 2529: GLIBC_2.42
not found, then the credential cleanup step died too).

Each matrix entry now names job_image, check_image_versions.py pins fails when it
differs from the Dockerfile's release, the bot-diff guard allows tag and digest edits
of job_image lines, Renovate tracks them with a regex manager (never automerged), and
major ubuntu updates are disabled everywhere: a new release is a deliberate edit.

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01MmzvM9skAvYcph2c9EiPcm
2026-10-26 18:58:21 +00:00
Defame1297 3c471b8986 Merge pull request 'feat(image): add molecule-ubuntu2604, the target release next to 24.04' (#37) from feat/molecule-ubuntu2604-image into main
Build / build (push) Successful in 10s
Images / image (Dockerfile, molecule-ubuntu2604, images/molecule-ubuntu2604, 0.1.0) (push) Successful in 34s
Images / image (Dockerfile, molecule-ubuntu2404, images/molecule-ubuntu2404, 0.1.2) (push) Failing after 25s
Lint / lint (push) Successful in 11s
Images / image (images/ci/Dockerfile, ci, , 0.2.4) (push) Successful in 11s
Reviewed-on: #37
2026-10-26 18:53:51 +00:00
Defame1297andClaude Sonnet 5.5 69f29e2c28 feat(image): add molecule-ubuntu2604, the target release next to 24.04
Molecule / molecule (pull_request) Skipped
Build / build (pull_request) Successful in 9s
Lint / lint (pull_request) Successful in 11s
The hosts run Ubuntu 24.04 today and 26.04 is where they are going, so the roles are
tested on both. This adds only the image (Dockerfile, build matrix entry 0.1.0); the
scenario and the consumer pin follow in a second pull request, because the pin needs the
digest of the first build.

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01MmzvM9skAvYcph2c9EiPcm
2026-10-26 18:49:02 +00:00
Defame1297 7308d8e133 Merge pull request 'fix(image): keep molecule-ubuntu2404 on Ubuntu 24.04 and stop Renovate bumping its release' (#36) from fix/molecule-image-stay-on-2404 into main
Build / build (push) Successful in 10s
Images / image (Dockerfile, molecule-ubuntu2404, images/molecule-ubuntu2404, 0.1.2) (push) Failing after 28s
Lint / lint (push) Successful in 11s
Images / image (images/ci/Dockerfile, ci, , 0.2.4) (push) Successful in 12s
Reviewed-on: #36
2026-10-26 18:48:33 +00:00
Defame1297andClaude Sonnet 5.5 bfef5caf4f fix(image): keep molecule-ubuntu2404 on Ubuntu 24.04 and stop Renovate bumping its release
Molecule / molecule (pull_request) Skipped
Lint / lint (pull_request) Successful in 12s
Build / build (pull_request) Successful in 11s
The ubuntu 26.04 base bump (#33) made the image 26.04 under a 24.04 name, and
image-smoke correctly failed on main after the pin followed (run 2525). Restore the
24.04 digest, bump the image to 0.1.2 and disable major ubuntu updates for this
Dockerfile only; the ci image keeps following the newest release.

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01MmzvM9skAvYcph2c9EiPcm
2026-10-26 18:42:10 +00:00
kamino-renovate Bot e849521c7d Merge pull request 'chore(deps): update git.rkdr.net/mortis/molecule-ubuntu2404 docker tag to v0.1.1' (#35) from renovate/git.rkdr.net-mortis-molecule-ubuntu2404-0.x into main
Build / build (push) Successful in 11s
Molecule / molecule (push) Failing after 33s
Lint / lint (push) Successful in 12s
2026-10-26 18:39:19 +00:00
Defame1297 34d5fc089f Merge branch 'main' into renovate/git.rkdr.net-mortis-molecule-ubuntu2404-0.x
Molecule / molecule (pull_request) Skipped
Lint / lint (pull_request) Successful in 12s
Build / build (pull_request) Successful in 10s
2026-10-26 18:38:31 +00:00
kamino-renovate Bot e3a2ea2e2d Merge pull request 'chore(deps): update git.rkdr.net/mortis/ci docker tag to v0.2.4' (#34) from renovate/git.rkdr.net-mortis-ci-0.x into main
Build / build (push) Successful in 10s
Lint / lint (push) Successful in 12s
2026-10-26 18:38:21 +00:00
renovate-bot b71208dba4 chore(deps): update git.rkdr.net/mortis/molecule-ubuntu2404 docker tag to v0.1.1
Molecule / molecule (pull_request) Skipped
renovate/stability-days Updates have met minimum release age requirement
Lint / lint (pull_request) Canceled after 0s
Build / build (pull_request) Canceled after 13s
2026-10-26 18:37:38 +00:00
renovate-bot 0635c9f880 chore(deps): update git.rkdr.net/mortis/ci docker tag to v0.2.4
Molecule / molecule (pull_request) Skipped
renovate/stability-days Updates have met minimum release age requirement
Build / build (pull_request) Successful in 26s
Lint / lint (pull_request) Successful in 12s
2026-10-26 18:37:35 +00:00
Defame1297 59bd96de34 Merge pull request 'chore(deps): update ubuntu docker tag to v26' (#33) from renovate/job-container-ubuntu-26.x into main
Build / build (push) Successful in 13s
Images / image (Dockerfile, molecule-ubuntu2404, images/molecule-ubuntu2404, 0.1.1) (push) Successful in 14s
Lint / lint (push) Successful in 13s
Images / image (images/ci/Dockerfile, ci, , 0.2.4) (push) Successful in 10s
Reviewed-on: #33
2026-10-26 18:32:32 +00:00
Defame1297 977d98fd48 Merge branch 'main' into renovate/job-container-ubuntu-26.x
Molecule / molecule (pull_request) Skipped
Build / build (pull_request) Successful in 12s
Lint / lint (pull_request) Successful in 13s
2026-10-26 18:31:28 +00:00
kamino-renovate Bot 1f0a7664ff Merge pull request 'chore(deps): update dependency antsibull-changelog to v0.36.0' (#32) from renovate/antsibull-changelog-0.x into main
Build / build (push) Successful in 12s
Images / image (Dockerfile, molecule-ubuntu2404, images/molecule-ubuntu2404, 0.1.1) (push) Successful in 10s
Lint / lint (push) Successful in 13s
Images / image (images/ci/Dockerfile, ci, , 0.2.4) (push) Successful in 3m10s
2026-10-26 18:31:08 +00:00
renovate-bot 4d120f2262 chore(deps): update ubuntu docker tag to v26
Molecule / molecule (pull_request) Skipped
renovate/stability-days Updates have met minimum release age requirement
Build / build (pull_request) Successful in 11s
Lint / lint (pull_request) Canceled after 12s
2026-10-26 18:30:38 +00:00
renovate-bot 651485fd7a chore(deps): update dependency antsibull-changelog to v0.36.0
Molecule / molecule (pull_request) Skipped
renovate/stability-days Updates have not met minimum release age requirement
Build / build (pull_request) Successful in 13s
Lint / lint (pull_request) Successful in 13s
2026-10-26 18:30:35 +00:00
Defame1297 34dfa4e674 Merge pull request 'chore(deps): update ubuntu docker tag to v26' (#31) from renovate/ubuntu-26.x into main
Build / build (push) Successful in 10s
Images / image (Dockerfile, molecule-ubuntu2404, images/molecule-ubuntu2404, 0.1.1) (push) Successful in 35s
Lint / lint (push) Successful in 11s
Images / image (images/ci/Dockerfile, ci, , 0.2.3) (push) Successful in 3m6s
Reviewed-on: #31
2026-10-26 18:23:10 +00:00
Defame1297 1aef3e6281 Merge branch 'main' into renovate/ubuntu-26.x
Molecule / molecule (pull_request) Skipped
Build / build (pull_request) Successful in 11s
Lint / lint (pull_request) Successful in 11s
2026-10-26 18:22:30 +00:00
kamino-renovate Bot ab77dcede6 Merge pull request 'chore(deps): update git.rkdr.net/mortis/ci docker tag to v0.2.2' (#30) from renovate/git.rkdr.net-mortis-ci-0.x into main
Build / build (push) Successful in 11s
Lint / lint (push) Successful in 11s
2026-10-26 18:21:02 +00:00
renovate-bot b6b3cfd696 chore(deps): update ubuntu docker tag to v26
Molecule / molecule (pull_request) Skipped
renovate/stability-days Updates have met minimum release age requirement
Lint / lint (pull_request) Successful in 15s
Build / build (pull_request) Successful in 30s
2026-10-26 18:20:19 +00:00
renovate-bot 6f1efb3448 chore(deps): update git.rkdr.net/mortis/ci docker tag to v0.2.2
Molecule / molecule (pull_request) Skipped
renovate/stability-days Updates have met minimum release age requirement
Build / build (pull_request) Successful in 26s
Lint / lint (pull_request) Successful in 12s
2026-10-26 18:20:16 +00:00
Defame1297 84751e5cbe Merge pull request 'feat(renovate): follow our own image pins and automerge them' (#29) from feat/renovate-pin-follow into main
Build / build (push) Successful in 30s
Lint / lint (push) Successful in 14s
Reviewed-on: #29
2026-10-26 18:18:53 +00:00
Defame1297andClaude Sonnet 5.5 4240b0c6b6 feat(renovate): follow our own image pins and automerge them
Molecule / molecule (pull_request) Skipped
Build / build (pull_request) Successful in 29s
Lint / lint (pull_request) Successful in 15s
The mortis/* pin rule was disabled until Phase 4. Enabled with automerge: the
pin pull request's own Lint and Build run in the new image before the merge,
the bot-diff gate allows only the pin lines, and check_image_versions pins
rejects a pin ahead of the matrix. Majors stay manual.

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01MmzvM9skAvYcph2c9EiPcm
2026-10-26 17:42:47 +00:00
Defame1297 6cf2080202 Merge pull request 'chore(deps): update ansible tooling' (#25) from renovate/ansible-tooling into main
Build / build (push) Successful in 29s
Images / image (images/ci/Dockerfile, ci, , 0.2.2) (push) Successful in 3m0s
Images / image (Dockerfile, molecule-ubuntu2404, images/molecule-ubuntu2404, 0.1.0) (push) Successful in 9s
Lint / lint (push) Successful in 14s
Reviewed-on: #25
2026-10-26 17:33:18 +00:00
100 changed files with 3394 additions and 224 deletions

No files matched your search

+9
View File
@@ -8,3 +8,12 @@ exclude_paths:
- .venv
- changelogs
- images
# The Collection is checked out outside an ansible_collections/mortis/kamino path (CI clones it
# into the workspace), so ansible-lint cannot resolve a role of this Collection by its FQCN in
# a scenario's converge play. List the roles the scenarios call by FQCN.
mock_roles:
- mortis.kamino.docker
- mortis.kamino.fail2ban
- mortis.kamino.network_interfaces
- mortis.kamino.systemd_hardening
+3 -2
View File
@@ -1,7 +1,8 @@
name: Build
# Builds the Collection tarball and checks it. On a v* tag it also checks the release
# invariants of ADR 0004 (annotated tag, tag equals v + galaxy.yml version). Nothing is
# invariants of ADR 0004 (annotated tag, tag equals v + galaxy.yml version; the ADR is in the
# maintainer's environment repository). Nothing is
# uploaded: the tarball is built in a temporary directory and discarded. Releases are
# consumed by git tag, so there is no publish step. No org secret is used; the job token (secrets.GITHUB_TOKEN) clones the repository.
on: # yamllint disable-line rule:truthy
@@ -31,7 +32,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.0@sha256:0eedfabb16fc95322b05b33917d2e551dccc6121c1537cef6a52cd5372a855eb
image: git.rkdr.net/mortis/ci:0.2.14@sha256:301bdf3981014664aae2d2b8b283347c722980405b46c792499fcd2796890e87
env:
PIP_DISABLE_PIP_VERSION_CHECK: "1"
steps:
+24 -6
View File
@@ -1,8 +1,8 @@
name: Images
# Builds the images under images/ with kaniko (osscontainertools fork, v1.28.6) and
# pushes them to git.rkdr.net/mortis/<name> (ADR 0004, Image distribution): the molecule
# test target (molecule-ubuntu2404) and the lint/build tooling (ci).
# pushes them to git.rkdr.net/mortis/<name> (ADR 0004 in the maintainer's environment repository, Image distribution): the molecule
# test targets (molecule-ubuntu2404, molecule-ubuntu2604) and the lint/build tooling (ci).
#
# Never on pull_request: a workflow file comes from the PR head, so a fork PR could
# otherwise push to the registry. This workflow has no pull_request trigger, and the job
@@ -12,11 +12,16 @@ name: Images
# - Sources: the job container has no Node, so actions/checkout cannot run. Kaniko
# clones the repository itself (git:// build context, over HTTPS, authenticated
# with the job token as Basic-auth password, which Gitea 28 accepts for task tokens).
# - Job container: ubuntu:24.04 by digest, not the kaniko image. gitea/act starts every
# - Job container: ubuntu by digest, not the kaniko image. gitea/act starts every
# job container with the entrypoint `/bin/sleep`, which the kaniko `-debug` image
# lacks (its /bin holds only `sh`), and `container.options: --entrypoint` is appended
# to that entrypoint, not substituted. The pinned kaniko executor is therefore
# downloaded by layer digest and verified with sha256sum.
# - Job container release: kaniko unpacks the image it builds over the job container's own
# root, so each matrix entry names its job container (job_image) and that must be the
# same Ubuntu release as the FROM lines of the image's Dockerfile (check_image_versions.py
# pins enforces it; run 2529 broke a 24.04 build in a 26.04 job container: GLIBC_2.42
# not found).
# - Credentials: the job token is tried first (permissions: packages: write). Gitea 28
# refuses it for an organisation-owned package (HTTP 401 on a write probe, run 2237:
# the Actions user is not an org member, services/context/package.go, TODO ActionUser
@@ -71,15 +76,22 @@ jobs:
matrix:
include:
- name: molecule-ubuntu2404
version: 0.1.0
version: 0.1.5
subpath: images/molecule-ubuntu2404
dockerfile: Dockerfile
job_image: ubuntu:24.04@sha256:fe81560990fae86dc4743202b2cb4d3df98d0bcf949173cecef15ce1127ef852
- name: molecule-ubuntu2604
version: 0.1.3
subpath: images/molecule-ubuntu2604
dockerfile: Dockerfile
job_image: ubuntu:26.04@sha256:6a06111c3b0a8600feadb270aec771dc239bf407b25625f93f44ab00e11f4d3c
- name: ci
version: 0.2.2
version: 0.2.14
subpath: ""
dockerfile: images/ci/Dockerfile
job_image: ubuntu:26.04@sha256:6a06111c3b0a8600feadb270aec771dc239bf407b25625f93f44ab00e11f4d3c
container:
image: ubuntu:24.04@sha256:68ee22004a9109b44973313b02ff7b1de250f1de0f5ecb628d73f579aaff33ac
image: ${{ matrix.job_image }}
# Keeps a runaway build from taking the whole 3 GB runner LXC down with it.
options: --memory=2g --memory-swap=2g
env:
@@ -280,6 +292,11 @@ jobs:
exit 0
fi
dests=(--destination "${image}:${IMAGE_VERSION}" --destination "${image}:latest")
# Labels only the build knows (the static ones are in the Dockerfile). The package page of
# the registry lists them next to the Dockerfile's.
labels=(--label "org.opencontainers.image.version=${IMAGE_VERSION}"
--label "org.opencontainers.image.revision=${SHA}"
--label "org.opencontainers.image.created=$(date -u +%Y-%m-%dT%H:%M:%SZ)")
# Context: this commit of this repository, cloned by kaniko (#<ref>#<sha>:
# clone <ref>, check out <sha>). With a sub-path only that directory is the
@@ -302,6 +319,7 @@ jobs:
--context "git://${registry}/${REPO}.git#${REF}#${SHA}" \
"${ctx[@]}" \
"${dests[@]}" \
"${labels[@]}" \
--snapshot-mode=redo \
--cache=false \
--push-retry 3 \
+1 -1
View File
@@ -34,7 +34,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.0@sha256:0eedfabb16fc95322b05b33917d2e551dccc6121c1537cef6a52cd5372a855eb
image: git.rkdr.net/mortis/ci:0.2.14@sha256:301bdf3981014664aae2d2b8b283347c722980405b46c792499fcd2796890e87
env:
PIP_DISABLE_PIP_VERSION_CHECK: "1"
PRE_COMMIT_HOME: /opt/pre-commit
+23 -19
View File
@@ -1,33 +1,31 @@
name: Molecule
# Behavioural tests of the Collection: every molecule scenario under
# extensions/molecule/*/ and roles/*/molecule/*/. extensions/molecule/image-smoke
# tests the test image itself, so it runs even before any role exists.
# extensions/molecule/*/ and roles/*/molecule/*/. extensions/molecule/image-smoke and
# image-smoke-2604 test the test images themselves, so they run even before any role exists.
#
# It runs on the `kamino-molecule` label, a host executor on kamino-runner, which uses
# that LXC's own Docker daemon; no job container is given the Docker socket. That makes
# the job root-equivalent on the runner LXC, which is rebuildable and holds no
# production secret (ADR 0004, Runner isolation). The runner's firewall is inert until
# the Proxmox datacenter firewall is enabled, so a scenario can reach the whole LAN:
# keep mortis/kamino private and accepting no fork pull requests until then. The `if:`
# guard is a convenience filter, not a boundary: the workflow file comes from the PR
# head. The real condition is that only trusted people can push branches here.
# production secret (ADR 0004 in the maintainer's environment repository, Runner
# isolation). The runner sits in an isolated network segment (outbound DNS to two
# resolvers and web traffic only; inbound SSH from two management hosts only), so a
# scenario cannot reach the LAN. A live test on 2026-11-08 showed a fork pull request's
# Build workflow starting on the runner at once, with no approval step (the tester may
# have had write access, so this is unproven for outsiders). The `if:` guard is a
# convenience filter, not a boundary: a fork controls its own workflow file. So the
# repository should not accept fork pull requests from untrusted users until the
# operator decides otherwise; the real condition is that only trusted people can push
# branches or open pull requests here.
#
# Tooling is provisioned on the runner by the gitea_runner role (molecule venv and the
# collections the roles use); this job installs nothing. The test image is pulled from
# the registry by tag and digest (the digest is what is enforced). Bump both here when
# image.yml publishes a new molecule-ubuntu2404 version.
# image.yml publishes a new molecule-ubuntu2404 or molecule-ubuntu2604 version.
on: # yamllint disable-line rule:truthy
pull_request:
branches:
- main
paths:
- 'roles/**'
- 'extensions/**'
- 'plugins/**'
- 'meta/**'
- 'galaxy.yml'
- '.gitea/workflows/molecule.yml'
push:
branches:
- main
@@ -50,12 +48,14 @@ concurrency:
jobs:
molecule:
# Same-repo, non-bot branches only; a push to main or a manual dispatch always runs.
# Same-repo branches only (bot branches included: a Renovate pin pull request is what tests a new
# image); a push to main or a manual dispatch always runs. No paths filter on pull requests, so
# that Molecule can be a required check: a required check that a pull request never starts would
# block it. A fork pull request is skipped by the guard below.
if: >-
github.repository == 'mortis/kamino' &&
(github.event_name != 'pull_request' ||
(github.event.pull_request.head.repo.full_name == github.repository &&
!startsWith(github.head_ref, 'renovate/')))
github.event.pull_request.head.repo.full_name == github.repository)
runs-on: [kamino-molecule]
timeout-minutes: 30
env:
@@ -64,7 +64,11 @@ jobs:
# 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.0@sha256:80dbfa7f88309072e954ae20e80ee8171bd750abc7c1d9563c746bf6f0121f04
git.rkdr.net/mortis/molecule-ubuntu2404:0.1.5@sha256:57123de013ad0ca0c4c64723f7f86636de07a1d6a40a7bc4f064ec664cd463f9
# 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: >-
git.rkdr.net/mortis/molecule-ubuntu2604:0.1.3@sha256:7a90a9ff1819e99be17b28decff273f4f6405470a302c0fe961a61427e72bad6
steps:
# Provisioned by the gitea_runner role (install_services); fail with a clear
# message when this runs before it has.
+1
View File
@@ -5,6 +5,7 @@ ignore: |
.venv/**
# Written and rewritten by antsibull-changelog, which does not indent sequences.
changelogs/config.yaml
changelogs/changelog.yaml
rules:
trailing-spaces:
+37
View File
@@ -0,0 +1,37 @@
===========================
mortis.kamino Release Notes
===========================
.. contents:: Topics
v1.2.0
======
Minor Changes
-------------
- network_interfaces - New role. Renders /etc/network/interfaces from a layout of manual interfaces and bridges, validates it with ifreload and restores the backup if validation fails.
- systemd_hardening - New role. Disables and masks risky services per system type, writes a systemd manager hardening drop-in and renders opt-in per-service sandboxing drop-ins.
v1.1.0
======
Minor Changes
-------------
- fail2ban - New role. Installs Fail2Ban, manages jail.local and the service, deploys per-service jails into jail.d.
v1.0.0
======
Release Summary
---------------
First release. It holds the docker role; further roles follow in waves.
Minor Changes
-------------
- The Collection archive no longer contains extensions/ (the image-smoke molecule scenario), the roles' molecule scenarios, CLAUDE.md or other repository tooling; the Build workflow now fails when the archive holds anything outside an allow list, a member that is not a regular file or directory (symlinks, hardlinks, devices), or a path that is absolute or holds an empty, '..' or '.git' component (compared case-insensitively), a backslash or a control or zero-width character; it also fails on duplicate members, an empty archive or one that lacks MANIFEST.json, FILES.json, COPYING, README.md, meta/runtime.yml or changelogs/changelog.yaml, and on symlinks in the source tree (which ansible-galaxy would dereference).
- The archive check also rejects any file name containing "vault", SSH key and .envrc/.env* files, names that Windows or macOS extraction would read differently (trailing space or dot, reserved device names such as CON or NUL, "::", 8.3 aliases of .git, non-ASCII spaces, surrogate, private-use and unassigned characters, components over 255 bytes), case-insensitive duplicates and a name used as both a file and a directory. The Build workflow fails with a clear message unless exactly one tarball was built.
- docker - New role. Installs, updates or removes Docker Engine from the upstream APT repository and adds users to the docker group.
+54 -90
View File
@@ -5,14 +5,13 @@ Guidance for Claude Code (claude.ai/code) in this repository.
## What this is
`mortis.kamino`: an Ansible Collection (GPL-3.0-or-later, REUSE-compliant), extracted role by
role from the author's homelab Environment repo (`Defame1297/ansible-homelab-mono`). The
design contract is ADR 0004 in that repo (`docs/adr/0004-collection-consumption-and-release.md`)
and the tracking issue is its epic #486. There are no roles here yet: wave 1 arrives with the
extraction.
role from the author's homelab environment repository. The design contract is ADR 0004 (in the
maintainer's environment repository). Roles arrive here wave by wave; `docker` is in 1.0.0, `fail2ban` in 1.1.0, `network_interfaces` and `systemd_hardening` in 1.2.0.
The repo is **private and takes no fork pull requests** until the author has verified the
isolation of its CI runner. Do not change visibility, repository settings, branch or tag
protection, or create tags: those are the operator's.
Fork pull requests from untrusted users are not accepted for now: a fork controls its own
workflow file, so the `if:` guards are a convenience, not a boundary (see the header of
`molecule.yml`). Do not change visibility, repository settings, branch or tag protection,
or create tags: those are the operator's.
## Working here
@@ -40,13 +39,20 @@ protection, or create tags: those are the operator's.
- Lint and Build run in the `ci` image. After the checkout they compare the pin files with the
checksums baked into the image: a PR that changes `requirements-dev.txt` or
`.pre-commit-config.yaml` takes the slower path that installs the pinned tools.
- Molecule runs on every same-repo pull request, Renovate's included (a new image is tested by its own pin
pull request), with no path filter, so that it can be a required check. Fork pull requests are skipped.
- Molecule discovers `extensions/molecule/*/` and `roles/*/molecule/*/`. The `image-smoke`
scenario tests the molecule image itself.
and `image-smoke-2604` scenarios test the molecule images themselves (24.04 and 26.04); a role scenario that
must pass on both takes `image: ${MOLECULE_IMAGE}` or `${MOLECULE_IMAGE_2604}` per platform.
## Images (`images/`)
- `ci` and `molecule-ubuntu2404`, built by `image.yml` with kaniko on push to `main` (never on
- `ci`, `molecule-ubuntu2404` and `molecule-ubuntu2604`, built by `image.yml` with kaniko on push to `main` (never on
pull requests) and pushed to `git.rkdr.net/mortis/<name>`.
- The molecule images are one Ubuntu release each, by name: the hosts run 24.04 today and 26.04 is the
target, so roles are tested on both. A new release is a new image added by hand (Renovate's major `ubuntu`
updates are disabled everywhere); retire an image when no host runs its release. A new image's
first consumer pin is a hand-made PR with the digest its first build printed; Renovate follows it after.
- Each has a semver `version:` in the workflow's build matrix. A published version tag is never
moved and never rebuilt (the job looks it up in the registry first and ends without building):
bump the version in the PR that changes the image. A new version is pushed as `<version>` and
@@ -57,90 +63,48 @@ protection, or create tags: those are the operator's.
- Consumers pin `image:<version>@sha256:<digest>` (`lint.yml`, `build.yml`, `molecule.yml`).
A build prints the new digest; moving a pin is a reviewed edit, and every build has a new
digest.
- kaniko runs inside the job container and unpacks the image it builds over it, so each matrix entry names its
job container (`job_image: ubuntu:<release>@sha256:...`) and its release must equal the `FROM ubuntu:` release
of the image's Dockerfile (`check_image_versions.py pins` fails otherwise). Moving an image to a new release is one edit: the Dockerfile `FROM`, the `job_image`
tag and digest, and the version bump. Digest drift within a release is tolerated. A `job_image`-only bump is
not an image input: no version bump, nothing rebuilt; the post-merge Images run only reaches the prepare step
for published versions, so that is its only exercise.
- Image metadata: Gitea's package page shows the description as plain text (no markdown), lists every label,
and links source, documentation and licence; it renders no README. So each Dockerfile carries the same
label block (`org.opencontainers.image.*` plus `net.rkdr.mortis.purpose/contents/usage`), the build adds
`version`, `revision` and `created`, and the readme-style text lives in `docs/images/<name>.md`, which the
`documentation` label links to. `check_image_versions.py pins` fails when a label or that file is missing.
The docs sit outside the image directories on purpose: editing them is not an image input, so it needs no
new version. Editing a label in a Dockerfile is an input and does.
- Each pushed layer must stay below 100 MB: Cloudflare rejects larger request bodies with
HTTP 413. That is why the `ci` image deletes the Go toolchains from the hook cache.
- `image.yml` tries the job token first with a write probe; Gitea 28 refuses it for the org's packages
(HTTP 401, run 2237), so the push uses the org Actions secrets `PACKAGE_PUSH_USER` and
`PACKAGE_PUSH_TOKEN`. Never print or use them anywhere else.
- `image.yml` is the only workflow that may reference the org Actions secrets (the registry push credential). Never print or use them anywhere else.
## Dependency automation (Renovate)
`renovate.json` is run by `.gitea/workflows/renovate.yml` (see below). Items marked unverified have not run yet.
`renovate.json` is run by `.gitea/workflows/renovate.yml` (daily cron and `workflow_dispatch`) on the
`kamino-docker` runner, as a Kamino-only bot user, so code from this repository never runs in the
maintainer's production environment. Never reuse another Renovate credential here.
- **Policy:** minor and patch bumps automerge, majors are manual. `ansible-core` minor and major
are manual too (a new minor can show new sanity findings), and `ansible-core` and
`ansible-lint` bump in one group. Dockerfile base-image tag and digest bumps (`images/*/Dockerfile`)
stay automergeable: Kamino is the untrusted side and the pin PR's CI exercises the new image. The
`ubuntu` job container of `image.yml` never automerges: that job holds the registry push credential.
kaniko is pinned by layer digests in `image.yml`; no Renovate manager reads them, so it is updated by
hand (the `/kaniko/` rule in `renovate.json` is only a safety net).
- **Two-PR loop for an image input** (`requirements-dev.txt`, `.pre-commit-config.yaml`,
`images/**`): PR 1 carries the input change plus the PATCH bump of the image `version:` in
`image.yml` (`scripts/bump_image_versions.py [<base-ref>]`, idempotent, edits only the
version line; `check_image_versions.py bump` then passes). The merge builds the image on
`main`. PR 2 moves the consumers' `image:<version>@sha256:<digest>` pins to that digest.
`renovate.json` runs the script as a `postUpgradeTasks` command of a catch-all rule (matches every package, since
only the first upgrade of a branch counts; branch mode, file filter `image.yml`; allowed by the one anchored regex in `RENOVATE_ALLOWED_COMMANDS` of `renovate.yml`),
so PR 1 carries the bump. PR 2 stays a hand edit until Phase 4 (pin-follow for
`git.rkdr.net/mortis/*` is `enabled: false`; it needs a dry run against the registry first).
- **Bot-diff gate:** the `lint` workflow runs `scripts/check_bot_pr_diff.py` on pull requests. A
head ref starting `renovate/` may only change version lines in `requirements-dev.txt`, `rev:`
lines in `.pre-commit-config.yaml`, FROM tags/digests and the `uv==` pin in `images/*/Dockerfile`,
the matrix `version:` lines and the ubuntu job container pin in `image.yml`, and the image
pins in `lint.yml`, `build.yml` and `molecule.yml`. Anything else fails, `renovate.json` included.
Tags are `[A-Za-z0-9._-]` only, FROM and ubuntu lines must keep their digest, matrix versions must stay in
place and rise, and a binary or one-sided change fails.
The branch name is attacker-controlled, so this only constrains the bot's own pull requests; its
purpose is that automerging them cannot alter workflow logic or reach the org secrets.
- **No Collection release from tooling bumps:** everything involved is in `galaxy.yml`
`build_ignore`, so the Collection archive and version do not change. A role-visible change needs
a changelog fragment and a new `galaxy.yml` version, and only the operator tags.
- **No production images:** `check_image_versions.py pins` fails when anything under
`.gitea/workflows` mentions `git.rkdr.net/defame1297/`.
- **Where Renovate runs:** `.gitea/workflows/renovate.yml`, a daily cron (03:17 UTC) plus
`workflow_dispatch`, on the `kamino-runner` (`kamino-docker`): the untrusted side, so code from this
repository never runs in the production cluster (ADR 0004). It authenticates as a Kamino-only bot user
(write access to this repository only, no admin, no other repository) whose token is the repository
secret `RENOVATE_BOT_TOKEN` (scopes `write:repository`, `write:issue`, `read:user`, `read:organization`; not an org secret:
only `image.yml` may reference those). `read:organization` is needed because Renovate reads the owner organisation when it initialises the repository (dry run 2450: 403 without it). Never reuse the in-cluster Renovate user's token here: it
reaches the production repository. The workflow's own job token does not work: Renovate filters
its pull request lookups by its own username, which is the virtual user `gitea-actions`, and Gitea
answers `400 user does not exist` (dry run 2445). The bot user must not be able to push to `main`
or merge past the required checks (branch protection). The job container is `renovate/renovate:<version>-full@sha256:...` from Docker Hub
(the `-full` flavour for `python3`), same version as the cluster's CronJob, hand-bumped (renovate.json
disables updates for the workflow file). Lookups of the github.com pre-commit hooks are
unauthenticated (no `RENOVATE_GITHUB_COM_TOKEN` exists) and may hit rate limits: best effort.
- **Dry run:** Actions > Renovate > Run workflow with `dry_run=true` (the default for a manual run;
sets `RENOVATE_DRY_RUN=full`, `LOG_LEVEL=debug`). Read the debug log: no branch or PR is created. The
schedule runs live. The job fails (it used to stay green) when Renovate exits non-zero
(`RENOVATE_EXIT_CODE_FOR_ERRORS`, 7 for a failed clone) or when the JSON report
(`RENOVATE_REPORT_TYPE=file`) is missing or holds an ERROR or FATAL problem; warnings do not fail it.
A first good dry run shows a clone (no `external-host-error`, no `could not read Username`).
- **Open item: the first live run (do not enable automerge for bot PRs until one has shown it gets Lint and
Build).** The dry run proves the READS (lookups, config, branch plan) and, from the Renovate 44.161.0
source (confirm by the log line for the post-upgrade task), also runs `postUpgradeTasks`. Dry run 2445
already showed that git over HTTPS works with the global `http.<server>/.extraheader`
(`AUTHORIZATION: bearer <token>`, like `lint.yml`; Renovate does not pass `GIT_CONFIG_*` from its
environment to git but does pass `HOME`), which fixed the redirect failure of run 2439. Still unproven
until a run with the bot token: (1) that the bearer header is accepted for a personal access token (if
not, use basic auth with the bot user name); (2) that the first LIVE run can push a branch and open a
PR; (3) that PRs opened by the bot user trigger the PR workflows (it is a normal user, so they should; if
the required `Lint` and `Build` never start, automerge cannot work); (4) that bot PRs are held by
`main`'s required status checks (check the branch protection). Also confirm in the log: Renovate clones
blobless with full history, so `origin/main` exists for the script (source-based); `python3` is in the
image (no PyYAML: the scripts the bump step imports use the standard library only, dry run 2453); `github.head_ref` is populated (the gate fails closed on an empty one, via `EVENT_NAME`). Safety
net: a failing or disallowed post-upgrade command opens the PR WITHOUT the bump plus a red
`renovate/artifacts` status, and `check_image_versions.py bump` then fails lint.
- **The workflow holds the runner's slot:** the `kamino-runner` host has a single slot (the label is
`kamino-docker`), and the Renovate job may run up to 30 minutes (`timeout-minutes`) from 03:17 UTC, so
Lint, Build and Molecule checks queue behind it.
- **Not enabled yet:** credentials for the `git.rkdr.net` registry (`hostRules`) and pin-follow. The
`pre-commit` manager is beta.
- **Hand edits on a bot branch:** a commit pushed by hand to a `renovate/` branch makes Renovate treat
the branch as modified: it stops rebasing it, so merge that pull request by hand.
- **The guard runs from `main`:** the lint step extracts `scripts/` from `origin/main` and runs the
guard from there, so a pull request cannot weaken its own gate (the PR copy runs only while `main`
has no guard). A change to the guard takes effect for other PRs after it merges.
- A pin-only pull request (only `lint.yml`, `build.yml`, `molecule.yml`) does not match any
`image.yml` push path (`images/**`, `requirements-dev.txt`, `.pre-commit-config.yaml`,
`.gitea/workflows/image.yml`), so it rebuilds nothing.
- **Policy:** minor and patch bumps automerge, majors are manual; the Lint and Build checks are the gate.
A new Ubuntu release is a deliberate edit, never a bump. The `job_image` of each matrix entry in `image.yml`
never automerges: that job holds the registry push credential. kaniko is pinned by layer digests in
`image.yml` and updated by hand.
- **Two-PR loop for an image input** (`requirements-dev.txt`, `.pre-commit-config.yaml`, `images/**`): PR 1
carries the input change plus the PATCH bump of the image `version:` in `image.yml`
(`scripts/bump_image_versions.py [<base-ref>]`; `check_image_versions.py bump` then passes; Renovate runs it
as a post-upgrade task). The merge builds the image on `main`. PR 2 moves the consumers' pins to the new
digest (Renovate's pin-follow rule for the `mortis/*` images; a major version stays manual).
- **Bot-diff gate:** `scripts/check_bot_pr_diff.py` runs in the lint workflow, from `origin/main`'s copy so a
pull request cannot weaken it. A `renovate/` head ref may only change version lines (tool pins, hook `rev:`
lines, Dockerfile FROM tags and digests, matrix `version:` lines, `job_image:` pins, consumer image pins);
anything else fails, `renovate.json` included. The branch name is attacker-controlled, so this only
constrains the bot's own pull requests.
- **No Collection release from tooling bumps:** tooling files are in `galaxy.yml` `build_ignore`. A
role-visible change needs a changelog fragment and a new `galaxy.yml` version; only the operator tags.
- **No production images:** `check_image_versions.py pins` fails when anything under `.gitea/workflows`
mentions the maintainer's production image namespace.
- **Hand edits on a bot branch:** a commit pushed by hand to a `renovate/` branch makes Renovate stop
rebasing it, so merge that pull request by hand.
- **The runner has a single slot:** the Renovate job (up to 30 minutes) delays Lint, Build and Molecule.
- **Open item:** do not enable automerge for bot PRs until a live run has shown that they get Lint and Build.
+6 -4
View File
@@ -1,9 +1,11 @@
# Contributing
- Open a pull request against `main`. A first-time contributor's fork pull
request needs a maintainer's approval before workflows run (Gitea waives this
once you have a merged pull request). Workflows on fork pull requests get no
secrets and a read-only token.
- Open a pull request against `main`. The forge does not allow self-registration, so only
accounts the maintainer has created can open pull requests or issues for now. Fork
pull requests are not a supported path: a fork controls its own workflow file, and a test
showed workflows starting without an approval step. Workflows on fork pull requests get
no secrets and a read-only token. To discuss a contribution, write to the address in
`SECURITY.md`.
- Commit messages follow [Conventional Commits](https://www.conventionalcommits.org/)
(`feat:`, `fix:`, `docs:`, `ci:` ...). CI checks every commit.
- Every user-visible change needs a changelog fragment in `changelogs/fragments/`
+2 -3
View File
@@ -4,8 +4,7 @@ An Ansible Collection of reusable, hardened roles for a self-hosted home lab:
Linux baseline, firewall, SSH, user management and, in later releases, Proxmox,
Gitea and Gitea Actions runner roles.
Status: scaffolding. The Collection holds no roles yet; roles arrive in waves.
Version 1.0.0 is reserved for the first stable release.
Status: roles arrive in waves. Release 1.2.0 holds the `docker`, `fail2ban`, `network_interfaces` and `systemd_hardening` roles.
## Consuming
@@ -17,7 +16,7 @@ name (FQCN) only, `mortis.kamino.<role>`:
collections:
- name: https://git.rkdr.net/mortis/kamino.git
type: git
version: v0.1.0
version: v1.2.0
```
```yaml
+16
View File
@@ -0,0 +1,16 @@
# Security policy
## Reporting a vulnerability
Report a suspected vulnerability privately by email to security@rkdr.net. Do not open a
public issue or pull request for it.
A report should say which role, script or workflow is affected, how to reproduce the
problem and what impact you expect. The maintainer will acknowledge the report and
coordinate a fix and its disclosure with you.
## Scope
This repository holds Ansible roles, CI workflows and the container images they use. Roles
change the hosts they run against, so a flaw that weakens a hardening default or leaks a
secret is in scope. Only the latest release is supported.
+35
View File
@@ -0,0 +1,35 @@
objects:
role:
docker:
description: Install, update or remove Docker Engine
name: docker
version_added: null
fail2ban:
description: Install and configure Fail2Ban
name: fail2ban
version_added: null
network_interfaces:
description: Manage /etc/network/interfaces
name: network_interfaces
version_added: null
systemd_hardening:
description: Harden systemd for a system type
name: systemd_hardening
version_added: null
plugins:
become: {}
cache: {}
callback: {}
cliconf: {}
connection: {}
filter: {}
httpapi: {}
inventory: {}
lookup: {}
module: {}
netconf: {}
shell: {}
strategy: {}
test: {}
vars: {}
version: 1.2.0
+54 -1
View File
@@ -1,2 +1,55 @@
ancestor: null
releases: {}
releases:
1.0.0:
changes:
minor_changes:
- The Collection archive no longer contains extensions/ (the image-smoke molecule
scenario), the roles' molecule scenarios, CLAUDE.md or other repository tooling;
the Build workflow now fails when the archive holds anything outside an allow
list, a member that is not a regular file or directory (symlinks, hardlinks,
devices), or a path that is absolute or holds an empty, '..' or '.git' component
(compared case-insensitively), a backslash or a control or zero-width character;
it also fails on duplicate members, an empty archive or one that lacks MANIFEST.json,
FILES.json, COPYING, README.md, meta/runtime.yml or changelogs/changelog.yaml,
and on symlinks in the source tree (which ansible-galaxy would dereference).
- The archive check also rejects any file name containing "vault", SSH key and
.envrc/.env* files, names that Windows or macOS extraction would read differently
(trailing space or dot, reserved device names such as CON or NUL, "::", 8.3
aliases of .git, non-ASCII spaces, surrogate, private-use and unassigned characters,
components over 255 bytes), case-insensitive duplicates and a name used as
both a file and a directory. The Build workflow fails with a clear message
unless exactly one tarball was built.
- docker - New role. Installs, updates or removes Docker Engine from the upstream
APT repository and adds users to the docker group.
release_summary: First release. It holds the docker role; further roles follow
in waves.
fragments:
- ci-concurrency-main-runs.yml
- collection-tarball-contents.yml
- credential-and-workflow-comments.yml
- dev-setup-robustness.yml
- docker-role.yml
- image-version-and-pin-check.yml
- release-1.0.0.yml
- scaffold.yml
release_date: '2026-11-08'
1.1.0:
changes:
minor_changes:
- fail2ban - New role. Installs Fail2Ban, manages jail.local and the service,
deploys per-service jails into jail.d.
fragments:
- fail2ban-role.yml
release_date: '2026-11-08'
1.2.0:
changes:
minor_changes:
- network_interfaces - New role. Renders /etc/network/interfaces from a layout
of manual interfaces and bridges, validates it with ifreload and restores
the backup if validation fails.
- systemd_hardening - New role. Disables and masks risky services per system
type, writes a systemd manager hardening drop-in and renders opt-in per-service
sandboxing drop-ins.
fragments:
- systemd-hardening-network-interfaces-roles.yml
release_date: '2026-11-10'
@@ -1,4 +0,0 @@
trivial:
- >-
A later push to main no longer cancels the Lint and Build runs of an earlier one; pull request
runs still cancel their predecessors, and in the Build workflow a tag run has its own group.
@@ -1,16 +0,0 @@
minor_changes:
- >-
The Collection archive no longer contains extensions/ (the image-smoke molecule scenario),
the roles' molecule scenarios, CLAUDE.md or other repository tooling; the Build workflow
now fails when the archive holds anything outside an allow list, a member that is not a
regular file or directory (symlinks, hardlinks, devices), or a path that is absolute or
holds an empty, '..' or '.git' component (compared case-insensitively), a backslash or a
control or zero-width character; it also fails on duplicate members, an empty archive or one
that lacks MANIFEST.json, FILES.json, COPYING, README.md, meta/runtime.yml or
changelogs/changelog.yaml, and on symlinks in the source tree (which ansible-galaxy would
dereference).
- >-
The archive check also rejects any file name containing "vault", SSH key and .envrc/.env* files, names that Windows or macOS extraction
would read differently (trailing space or dot, reserved device names such as CON or NUL, "::", 8.3 aliases of .git, non-ASCII spaces,
surrogate, private-use and unassigned characters, components over 255 bytes), case-insensitive duplicates and a name used as both a
file and a directory. The Build workflow fails with a clear message unless exactly one tarball was built.
@@ -1,2 +0,0 @@
trivial:
- Document the credential model in CLAUDE.md, CONTRIBUTING.md and the workflow headers, and rename the image workflow to Images.
@@ -1,6 +0,0 @@
trivial:
- >-
scripts/dev-setup.sh checks for Python 3.11 or newer (KAMINO_PYTHON selects one), derives the repository from its own location, rebuilds an older
virtualenv, shell-quotes the repository path it writes into the installed hooks, lifts a repo-local core.hooksPath that points at this
repository's own hooks (including a multi-valued, empty or newline-containing one) for the install and restores it exactly, and fails early
only when core.hooksPath points elsewhere or is set outside the repository's config (a global value), or when the hooks are missing.
@@ -1,9 +0,0 @@
trivial:
- >-
Add scripts/check_image_versions.py and its tests, and run them in the Lint workflow:
image pins must name an image of the build matrix, and a pull request that changes an
image's inputs must bump its version.
- >-
scripts/check_image_versions.py reports a pin written in any case, with a port, in a nested path or without a tag; fails closed (naming
file and line) on a Dockerfile COPY source with a variable, quote or comment character and on a RUN --mount of the build context; says so
for a non-UTF-8 diff path and an empty image.yml; requires lint.yml and lists the consumer files it checked.
-2
View File
@@ -1,2 +0,0 @@
trivial:
- Initial repository scaffolding, CI workflows and the molecule base image definition.
+83
View File
@@ -0,0 +1,83 @@
# ci
The **CI tooling image** of the [`mortis.kamino`](https://git.rkdr.net/mortis/kamino) Collection: everything the Lint and Build
workflows used to install on each run is baked in, so a job only checks out the code and runs.
## What is in it
Ubuntu 26.04 with:
- **Python tools** in `/opt/venv` (on `PATH`), from `requirements-dev.txt`: `ansible-core`,
`ansible-lint`, `pre-commit`, `antsibull-changelog`, `galaxy-importer`, `reuse`.
- **Every pre-commit hook environment** of `.pre-commit-config.yaml` in `/opt/pre-commit`
(`PRE_COMMIT_HOME`): conventional-pre-commit, gitleaks, yamllint, pre-commit-hooks and actionlint. The Go
hooks are prebuilt; their toolchains are removed to keep layers small. The local hooks (`reuse-lint`,
`antsibull-changelog-lint`, `ansible-lint`) are `language: system`: they run from `/opt/venv`, which is why
that directory must be on `PATH` (it is, in the image).
- **`ansible-test sanity` virtualenvs**, primed in `/root/.ansible/test`, and Python 3.11 and 3.13 as
`python3.11` / `python3.13` (python-build-standalone, installed with uv) next to the distribution's
`python3`, so sanity runs its compile test for those interpreters instead of skipping it.
- `git`, `shellcheck` (actionlint runs it over `run:` blocks), `python3`, `python3-venv` and `ca-certificates`.
The image runs as root and sets no working directory.
- `/opt/ci-pins.sha256`: the checksums of the two pin files this image was built from.
It has no Node, so JavaScript actions (`actions/checkout`) cannot run in it: clone with `git`.
## How to use it
As the job container of a workflow on the `kamino-docker` runner, pinned by tag and digest. This is the
shape of `.gitea/workflows/lint.yml` (which also holds the checkout step with the job-token authentication the
repository needs; read it for the full version):
```yaml
jobs:
lint:
runs-on: kamino-docker
container:
image: git.rkdr.net/mortis/ci:<version>@sha256:<digest>
env:
PRE_COMMIT_HOME: /opt/pre-commit
steps:
# ... clone the repository and check out the commit (the image has no Node, so no actions/checkout)
- name: Check the baked tooling against the pins # run from the checkout root
run: |
if ! sha256sum --quiet -c /opt/ci-pins.sha256; then
/opt/venv/bin/pip install --quiet -r requirements-dev.txt # a pin changed: install the pinned tools
fi
- name: Run pre-commit on all files
run: |
export PATH="/opt/venv/bin:$PATH"
pre-commit run --all-files --show-diff-on-failure
```
`/opt/ci-pins.sha256` lists the two pin files by relative name, so `sha256sum -c` runs in the checkout root. When
the checkout's `requirements-dev.txt` and `.pre-commit-config.yaml` match, the baked tools are used as they are.
When a pull request changes a pin the check fails and the job installs the pinned tools itself for that run
(slower, same result), until the image is rebuilt from `main`. `lint.yml` and `build.yml` are the real consumers.
## Tags and pinning
- `<version>` is semver, independent of the Collection's version. A published version is never moved or
rebuilt, so one digest belongs to exactly one version. `latest` is the newest version, for looking only.
- Pin `ci:<version>@sha256:<digest>`; the digest is what is enforced. Consumers: `lint.yml` and `build.yml`.
- Renovate is configured to move the pins to a new version after the image is built on `main` (the rule is in
`renovate.json`; the first pin of a brand-new image is made by hand).
## How it is built and kept up to date
`.gitea/workflows/image.yml` builds it with kaniko (repository root as build context, because the pin
files are copied in). The workflow runs on pushes to `main` that touch `images/**`, `requirements-dev.txt`,
`.pre-commit-config.yaml` or the workflow itself, never on a pull request, and builds an image only when its
`version:` in the workflow's matrix is not yet published. A change to the image's inputs therefore needs a new
`version:` (Lint enforces it, and Renovate's bump step does it for dependency updates), and the merge builds
the image. Each pushed layer stays below 100 MB (Cloudflare's request limit), which is why the Go toolchains
are deleted from the hook cache.
## Image metadata
The `org.opencontainers.image.*` labels (title, description, version, revision, created, source,
documentation, licenses, authors) and `net.rkdr.mortis.*` labels (what it is for, what it contains,
how to use it; the base image is `base.name`) are listed on the package page of the registry; `version`,
`revision` and `created` are set by the build.
Source: [https://git.rkdr.net/mortis/kamino](https://git.rkdr.net/mortis/kamino), `images/ci/Dockerfile`. Licence: GPL-3.0-or-later.
+81
View File
@@ -0,0 +1,81 @@
# molecule-ubuntu2404
A disposable **Ubuntu 24.04** test target for the molecule scenarios of the
[`mortis.kamino`](https://git.rkdr.net/mortis/kamino) Ansible Collection: a container that behaves like a small
24.04 host (systemd as PID 1), so a role can be converged and verified in it without a VM.
It is the release of the home lab's LXC hosts today.
## What is in it
- Ubuntu 24.04 (the official `ubuntu:24.04` image, pinned by digest in the Dockerfile).
- systemd as the init system (`systemd`, `systemd-sysv`), D-Bus, `sudo`, `iproute2`,
`ca-certificates`.
- Python for Ansible on the target: `python3`, `python3-apt`, `python3-systemd`.
- The packages the roles manage, preinstalled so a converge makes no network calls:
`iptables`, `ufw`, `fail2ban`, `openssh-server` (the `ssh` unit is enabled).
- Throwaway SSH host keys and a machine-id generated at build time. They are not secrets and the
image is a test target that must never be exposed to a network.
Package versions are not pinned: they are whatever the 24.04 archive held at build time.
`image-smoke`-style checks (below) assert the contract, not versions.
## How to use it
In a molecule scenario (`extensions/molecule/*/molecule.yml` or `roles/*/molecule/*/molecule.yml`)
with the docker driver:
```yaml
driver:
name: docker
platforms:
- name: instance
image: ${MOLECULE_IMAGE} # git.rkdr.net/mortis/molecule-ubuntu2404:<version>@sha256:<digest>, set by molecule.yml
pre_build_image: true
pull: true
command: /sbin/init
cgroupns_mode: host
volumes:
- /sys/fs/cgroup:/sys/fs/cgroup:rw
tmpfs:
- /run
- /run/lock
capabilities:
- NET_ADMIN
security_opts:
- apparmor=unconfined
```
systemd needs a writable cgroup (`cgroupns_mode: host`, the `/sys/fs/cgroup` mount and tmpfs on `/run`), the
firewall tools need `NET_ADMIN`, AppArmor is left unconfined for the container (`apparmor=unconfined`), and
nothing runs privileged. The docker driver needs molecule's docker plugin, which the runner provides.
The scenario `extensions/molecule/image-smoke` tests this image against that contract (release,
systemd, packages, the `dbus` and `ssh` units, the Python bindings, `NET_ADMIN`).
## Tags and pinning
- `<version>` is semver (`MAJOR.MINOR.PATCH`), independent of the Collection's version. A published
version is never moved or rebuilt, so one digest belongs to exactly one version. `latest` is the
newest version and is for looking, not for pinning.
- Pin `molecule-ubuntu2404:<version>@sha256:<digest>`; the digest is what is enforced. Consumers here:
`.gitea/workflows/molecule.yml`.
- Renovate is configured to move the pin to a new version after the image is built on `main` (the rule is in
`renovate.json`; the first pin of a brand-new image is made by hand).
## How it is built and kept up to date
`.gitea/workflows/image.yml` builds it with kaniko. The workflow runs on pushes to `main` that touch `images/**`,
`requirements-dev.txt`, `.pre-commit-config.yaml` or the workflow itself, never on a pull request, and builds an
image only when its `version:` in the workflow's matrix is not yet published. A change under
`images/molecule-ubuntu2404/` therefore needs a new `version:` (Lint enforces it) and the merge builds the image. The
Ubuntu release is fixed by the name: a new Ubuntu release is a new image (`molecule-ubuntuNNNN`), and the roles
are tested on every release the hosts run or are moving to.
## Image metadata
The `org.opencontainers.image.*` labels (title, description, version, revision, created, source,
documentation, licenses, authors) and `net.rkdr.mortis.*` labels (what it is for, what it contains,
how to use it; the base image is `base.name`) are listed on the package page of the registry; `version`,
`revision` and `created` are set by the build.
Source: [https://git.rkdr.net/mortis/kamino](https://git.rkdr.net/mortis/kamino), `images/molecule-ubuntu2404/Dockerfile`. Licence: GPL-3.0-or-later.
+81
View File
@@ -0,0 +1,81 @@
# molecule-ubuntu2604
A disposable **Ubuntu 26.04** test target for the molecule scenarios of the
[`mortis.kamino`](https://git.rkdr.net/mortis/kamino) Ansible Collection: a container that behaves like a small
26.04 host (systemd as PID 1), so a role can be converged and verified in it without a VM.
It is the release the hosts are moving to; the roles are tested on it next to 24.04.
## What is in it
- Ubuntu 26.04 (the official `ubuntu:26.04` image, pinned by digest in the Dockerfile).
- systemd as the init system (`systemd`, `systemd-sysv`), D-Bus, `sudo`, `iproute2`,
`ca-certificates`.
- Python for Ansible on the target: `python3`, `python3-apt`, `python3-systemd`.
- The packages the roles manage, preinstalled so a converge makes no network calls:
`iptables`, `ufw`, `fail2ban`, `openssh-server` (the `ssh` unit is enabled).
- Throwaway SSH host keys and a machine-id generated at build time. They are not secrets and the
image is a test target that must never be exposed to a network.
Package versions are not pinned: they are whatever the 26.04 archive held at build time.
`image-smoke`-style checks (below) assert the contract, not versions.
## How to use it
In a molecule scenario (`extensions/molecule/*/molecule.yml` or `roles/*/molecule/*/molecule.yml`)
with the docker driver:
```yaml
driver:
name: docker
platforms:
- name: instance
image: ${MOLECULE_IMAGE_2604} # git.rkdr.net/mortis/molecule-ubuntu2604:<version>@sha256:<digest>, set by molecule.yml
pre_build_image: true
pull: true
command: /sbin/init
cgroupns_mode: host
volumes:
- /sys/fs/cgroup:/sys/fs/cgroup:rw
tmpfs:
- /run
- /run/lock
capabilities:
- NET_ADMIN
security_opts:
- apparmor=unconfined
```
systemd needs a writable cgroup (`cgroupns_mode: host`, the `/sys/fs/cgroup` mount and tmpfs on `/run`), the
firewall tools need `NET_ADMIN`, AppArmor is left unconfined for the container (`apparmor=unconfined`), and
nothing runs privileged. The docker driver needs molecule's docker plugin, which the runner provides.
The scenario `extensions/molecule/image-smoke-2604` tests this image against that contract (release,
systemd, packages, the `dbus` and `ssh` units, the Python bindings, `NET_ADMIN`).
## Tags and pinning
- `<version>` is semver (`MAJOR.MINOR.PATCH`), independent of the Collection's version. A published
version is never moved or rebuilt, so one digest belongs to exactly one version. `latest` is the
newest version and is for looking, not for pinning.
- Pin `molecule-ubuntu2604:<version>@sha256:<digest>`; the digest is what is enforced. Consumers here:
`.gitea/workflows/molecule.yml`.
- Renovate is configured to move the pin to a new version after the image is built on `main` (the rule is in
`renovate.json`; the first pin of a brand-new image is made by hand).
## How it is built and kept up to date
`.gitea/workflows/image.yml` builds it with kaniko. The workflow runs on pushes to `main` that touch `images/**`,
`requirements-dev.txt`, `.pre-commit-config.yaml` or the workflow itself, never on a pull request, and builds an
image only when its `version:` in the workflow's matrix is not yet published. A change under
`images/molecule-ubuntu2604/` therefore needs a new `version:` (Lint enforces it) and the merge builds the image. The
Ubuntu release is fixed by the name: a new Ubuntu release is a new image (`molecule-ubuntuNNNN`), and the roles
are tested on every release the hosts run or are moving to.
## Image metadata
The `org.opencontainers.image.*` labels (title, description, version, revision, created, source,
documentation, licenses, authors) and `net.rkdr.mortis.*` labels (what it is for, what it contains,
how to use it; the base image is `base.name`) are listed on the package page of the registry; `version`,
`revision` and `created` are set by the build.
Source: [https://git.rkdr.net/mortis/kamino](https://git.rkdr.net/mortis/kamino), `images/molecule-ubuntu2604/Dockerfile`. Licence: GPL-3.0-or-later.
@@ -0,0 +1,7 @@
---
- name: Converge
hosts: all
gather_facts: true
tasks:
- name: Reach the instance over the container connection
ansible.builtin.ping:
@@ -0,0 +1,27 @@
---
# Tests the molecule test image itself (images/molecule-ubuntu2604): the contract the
# role scenarios rely on. Same instance settings as a role scenario: systemd needs a
# writable cgroup, the firewall tools need NET_ADMIN, nothing is privileged. The image
# comes from the environment (MOLECULE_IMAGE_2604, set by .gitea/workflows/molecule.yml).
driver:
name: docker
platforms:
- name: image-smoke-2604
image: ${MOLECULE_IMAGE_2604}
pre_build_image: true
pull: true
command: /sbin/init
cgroupns_mode: host
volumes:
- /sys/fs/cgroup:/sys/fs/cgroup:rw
tmpfs:
- /run
- /run/lock
capabilities:
- NET_ADMIN
security_opts:
- apparmor=unconfined
provisioner:
name: ansible
verifier:
name: ansible
@@ -0,0 +1,58 @@
---
- name: Verify the molecule image contract
hosts: all
gather_facts: true
tasks:
- name: The instance is Ubuntu 26.04 with systemd as the service manager
ansible.builtin.assert:
that:
- ansible_facts['distribution'] == 'Ubuntu'
- ansible_facts['distribution_version'] == '26.04'
- ansible_facts['service_mgr'] == 'systemd'
quiet: true
- name: Gather package facts
ansible.builtin.package_facts:
manager: auto
- name: The packages the roles manage are preinstalled
ansible.builtin.assert:
that: item in ansible_facts['packages']
quiet: true
loop:
- systemd
- systemd-sysv
- dbus
- sudo
- iproute2
- ca-certificates
- python3
- python3-apt
- python3-systemd
- iptables
- ufw
- fail2ban
- openssh-server
- name: Query the units a role scenario relies on
ansible.builtin.systemd:
name: "{{ item }}"
register: kamino_smoke_units
loop:
- dbus
- ssh
- name: The dbus unit is running and ssh is enabled
ansible.builtin.assert:
that:
- (kamino_smoke_units.results | selectattr('item', 'equalto', 'dbus') | first).status.ActiveState == 'active'
- (kamino_smoke_units.results | selectattr('item', 'equalto', 'ssh') | first).status.UnitFileState == 'enabled'
quiet: true
- name: The Python bindings Ansible's apt and systemd support need import
ansible.builtin.command: /usr/bin/python3 -c 'import apt, systemd.journal'
changed_when: false
- name: NET_ADMIN is granted, so the firewall tools can work
ansible.builtin.command: iptables -S
changed_when: false
+3 -1
View File
@@ -1,7 +1,7 @@
---
namespace: mortis
name: kamino
version: 0.1.0
version: 1.2.0
readme: README.md
authors:
- Defame1297
@@ -30,9 +30,11 @@ build_ignore:
- .reuse
- .venv
- .yamllint
- docs
- .ansible-lint
- CLAUDE.md
- CONTRIBUTING.md
- SECURITY.md
- HANDOFF.md
- extensions
- images
+14 -8
View File
@@ -9,8 +9,8 @@
# image: git.rkdr.net/mortis/ci@sha256:<digest>
#
# What is baked in, and from where:
# - OS packages: git, shellcheck (actionlint runs it over run: blocks), Python 3.12
# (the distribution's) and ca-certificates.
# - OS packages: git, shellcheck (actionlint runs it over run: blocks), the
# distribution's python3 and ca-certificates.
# - /opt/venv: requirements-dev.txt (ansible-core, ansible-lint, pre-commit,
# antsibull-changelog, galaxy-importer, reuse).
# - /opt/pre-commit: every hook environment of .pre-commit-config.yaml, installed by
@@ -30,10 +30,9 @@
# Layers: each COPY / RUN below is one layer, and a layer is pushed as one request,
# so it must stay below Cloudflare's 100 MB request-body limit on git.rkdr.net. The
# build stage prints the sizes it will copy; the first push is the real test.
# Base image: ubuntu:24.04 index digest as of 2026-10-24 (24.04.5), same as the
# molecule image.
# Base image: ubuntu:26.04 index digest as of 2026-10-26, same as molecule-ubuntu2604.
FROM ubuntu:24.04@sha256:68ee22004a9109b44973313b02ff7b1de250f1de0f5ecb628d73f579aaff33ac AS os
FROM ubuntu:26.04@sha256:6a06111c3b0a8600feadb270aec771dc239bf407b25625f93f44ab00e11f4d3c AS os
ENV DEBIAN_FRONTEND=noninteractive
@@ -62,7 +61,7 @@ RUN python3 -m venv /opt/venv \
# uv only lives in the build stage (its own venv): the final image keeps the
# interpreters it downloaded, not the installer.
RUN python3 -m venv /opt/uv-venv \
&& /opt/uv-venv/bin/pip install uv==0.13.5 \
&& /opt/uv-venv/bin/pip install uv==0.13.7 \
&& /opt/uv-venv/bin/uv python install 3.11 3.13
# pre-commit needs a git repository to resolve a config. The hook repositories are
@@ -116,9 +115,16 @@ RUN set -eu; \
FROM os AS final
LABEL org.opencontainers.image.title="ci" \
org.opencontainers.image.description="Lint and build tooling for mortis.kamino, baked in" \
org.opencontainers.image.description="CI tooling image for the mortis.kamino Ansible Collection: the Lint and Build workflows run in it, so a job only checks out the code and runs. It bakes in ansible-core, ansible-lint, pre-commit with every hook environment of the repository, antsibull-changelog, galaxy-importer, reuse, git, shellcheck, Python 3.11 and 3.13 next to the distribution python3 and primed ansible-test sanity virtualenvs. Use it as a job container pinned by tag and digest; it has no Node, so clone with git." \
org.opencontainers.image.source="https://git.rkdr.net/mortis/kamino" \
org.opencontainers.image.licenses="GPL-3.0-or-later"
org.opencontainers.image.url="https://git.rkdr.net/mortis/kamino" \
org.opencontainers.image.documentation="https://git.rkdr.net/mortis/kamino/src/branch/main/docs/images/ci.md" \
org.opencontainers.image.licenses="GPL-3.0-or-later" \
org.opencontainers.image.authors="Defame1297 and contributors" \
org.opencontainers.image.base.name="ubuntu:26.04" \
net.rkdr.mortis.purpose="CI tooling image for the mortis.kamino Ansible Collection: the Lint and Build workflows run in it, so a job only checks out the code and runs." \
net.rkdr.mortis.contents="Ubuntu 26.04, /opt/venv (ansible-core, ansible-lint, pre-commit, antsibull-changelog, galaxy-importer, reuse), /opt/pre-commit hook environments, ansible-test sanity venvs, python3 (distribution), python3.11, python3.13, git, shellcheck, /opt/ci-pins.sha256" \
net.rkdr.mortis.usage="Job container on the kamino-docker runner: container image git.rkdr.net/mortis/ci:version@sha256:digest with PRE_COMMIT_HOME set to /opt/pre-commit; in the checkout root run sha256sum -c /opt/ci-pins.sha256 and install the pinned tools when a pull request changed them, else use /opt/venv/bin. See the documentation label."
ENV PIP_DISABLE_PIP_VERSION_CHECK=1 \
PRE_COMMIT_HOME=/opt/pre-commit \
+10 -3
View File
@@ -25,12 +25,19 @@
# 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:68ee22004a9109b44973313b02ff7b1de250f1de0f5ecb628d73f579aaff33ac
FROM ubuntu:24.04@sha256:fe81560990fae86dc4743202b2cb4d3df98d0bcf949173cecef15ce1127ef852
LABEL org.opencontainers.image.title="molecule-ubuntu2404" \
org.opencontainers.image.description="systemd-capable Ubuntu 24.04 molecule test target for mortis.kamino" \
org.opencontainers.image.description="Disposable Ubuntu 24.04 test target for the molecule scenarios of the mortis.kamino Ansible Collection. systemd runs as PID 1 with D-Bus, sudo, python3 and the packages the roles manage (iptables, ufw, fail2ban, openssh-server) preinstalled, so a converge makes no network calls. Start it as a molecule platform (usage label); it carries throwaway SSH host keys and is a test target only, never to be exposed." \
org.opencontainers.image.source="https://git.rkdr.net/mortis/kamino" \
org.opencontainers.image.licenses="GPL-3.0-or-later"
org.opencontainers.image.url="https://git.rkdr.net/mortis/kamino" \
org.opencontainers.image.documentation="https://git.rkdr.net/mortis/kamino/src/branch/main/docs/images/molecule-ubuntu2404.md" \
org.opencontainers.image.licenses="GPL-3.0-or-later" \
org.opencontainers.image.authors="Defame1297 and contributors" \
org.opencontainers.image.base.name="ubuntu:24.04" \
net.rkdr.mortis.purpose="Disposable Ubuntu 24.04 test target for the molecule scenarios of the mortis.kamino Ansible Collection." \
net.rkdr.mortis.contents="Ubuntu 24.04, systemd, systemd-sysv, dbus, sudo, iproute2, ca-certificates, python3, python3-apt, python3-systemd, iptables, ufw, fail2ban, openssh-server (ssh enabled)" \
net.rkdr.mortis.usage="Molecule docker-driver platform with pre_build_image true, command /sbin/init, cgroupns_mode host, /sys/fs/cgroup mounted rw, tmpfs on /run and /run/lock, capability NET_ADMIN, security_opts apparmor=unconfined (not privileged). Pin git.rkdr.net/mortis/name:version@sha256:digest. See the documentation label."
ENV DEBIAN_FRONTEND=noninteractive
+58
View File
@@ -0,0 +1,58 @@
# Molecule test target for the roles of this Collection: Ubuntu 26.04 with systemd
# as PID 1 and the packages the roles manage preinstalled, so a converge makes no
# network calls. It replaces the molecule test image that used to be built locally
# on the CI runner.
#
# Built by .gitea/workflows/image.yml with kaniko and pushed (never on pull
# requests) to git.rkdr.net/mortis/molecule-ubuntu2604. Consumers reference it
# by digest, never by tag:
#
# container:
# image: git.rkdr.net/mortis/molecule-ubuntu2604@sha256:<digest>
#
# or, in a molecule scenario: platforms[].image with pre_build_image: true. The
# scenario starts it with command /sbin/init, cgroupns_mode host, /sys/fs/cgroup
# mounted rw, tmpfs on /run and /run/lock, capability NET_ADMIN. No privileged mode.
#
# One RUN layer: about 30 MB compressed on top of the 29.8 MB base (estimated from
# the real .debs, with the .pyc files the postinst scripts compile), far below
# Cloudflare's 100 MB request-body limit on git.rkdr.net (kaniko pushes a layer as
# one request). apt packages are not version-pinned, as in the original image; the
# base image is pinned by digest and a rebuild is a reviewed digest bump downstream.
#
# The image carries SSH host keys and a machine-id generated at build time (the
# openssh-server and systemd postinst scripts). ssh.service runs `sshd -t` and
# 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:26.04 index digest as of 2026-10-26.
FROM ubuntu:26.04@sha256:6a06111c3b0a8600feadb270aec771dc239bf407b25625f93f44ab00e11f4d3c
LABEL org.opencontainers.image.title="molecule-ubuntu2604" \
org.opencontainers.image.description="Disposable Ubuntu 26.04 test target for the molecule scenarios of the mortis.kamino Ansible Collection. systemd runs as PID 1 with D-Bus, sudo, python3 and the packages the roles manage (iptables, ufw, fail2ban, openssh-server) preinstalled, so a converge makes no network calls. Start it as a molecule platform (usage label); it carries throwaway SSH host keys and is a test target only, never to be exposed." \
org.opencontainers.image.source="https://git.rkdr.net/mortis/kamino" \
org.opencontainers.image.url="https://git.rkdr.net/mortis/kamino" \
org.opencontainers.image.documentation="https://git.rkdr.net/mortis/kamino/src/branch/main/docs/images/molecule-ubuntu2604.md" \
org.opencontainers.image.licenses="GPL-3.0-or-later" \
org.opencontainers.image.authors="Defame1297 and contributors" \
org.opencontainers.image.base.name="ubuntu:26.04" \
net.rkdr.mortis.purpose="Disposable Ubuntu 26.04 test target for the molecule scenarios of the mortis.kamino Ansible Collection." \
net.rkdr.mortis.contents="Ubuntu 26.04, systemd, systemd-sysv, dbus, sudo, iproute2, ca-certificates, python3, python3-apt, python3-systemd, iptables, ufw, fail2ban, openssh-server (ssh enabled)" \
net.rkdr.mortis.usage="Molecule docker-driver platform with pre_build_image true, command /sbin/init, cgroupns_mode host, /sys/fs/cgroup mounted rw, tmpfs on /run and /run/lock, capability NET_ADMIN, security_opts apparmor=unconfined (not privileged). Pin git.rkdr.net/mortis/name:version@sha256:digest. See the documentation label."
ENV DEBIAN_FRONTEND=noninteractive
# systemd as PID 1 with D-Bus, sudo and networking tools; the Python Ansible needs on
# the target (python3-apt for the apt module); the firewall and intrusion-prevention
# packages the roles manage (python3-systemd is a dependency of fail2ban's systemd
# backend); sshd, enabled so a converge can test it under systemd.
RUN apt-get update \
&& apt-get install -y --no-install-recommends \
systemd systemd-sysv dbus sudo iproute2 ca-certificates \
python3 python3-apt python3-systemd \
iptables ufw fail2ban \
openssh-server \
&& rm -rf /var/lib/apt/lists/* \
&& systemctl enable ssh
STOPSIGNAL SIGRTMIN+3
CMD ["/sbin/init"]
+28 -20
View File
@@ -57,12 +57,24 @@
},
{
"customType": "regex",
"description": "The MOLECULE_IMAGE value of molecule.yml is a multi-line `>-` scalar, which the github-actions manager does not read; matched here by its exact shape. Only used by the pin-follow rule below, which is disabled until Phase 4.",
"description": "The job container of each image of image.yml (matrix job_image, ubuntu by digest). kaniko unpacks the image over the job container, so its release must equal the Dockerfile's (check_image_versions.py pins). Tag and digest updates within a release arrive here; a new release is a deliberate edit of both (rule below disables major ubuntu updates). Never automerged: the job holds the registry push credential (image.yml rule below).",
"managerFilePatterns": [
"/^\\.gitea/workflows/image\\.yml$/"
],
"matchStrings": [
"job_image:\\s*(?<depName>ubuntu):(?<currentValue>[0-9][^@\\s]*)@(?<currentDigest>sha256:[0-9a-f]{64})"
],
"datasourceTemplate": "docker",
"versioningTemplate": "ubuntu"
},
{
"customType": "regex",
"description": "The MOLECULE_IMAGE and MOLECULE_IMAGE_<release> values of molecule.yml are a multi-line `>-` scalar, which the github-actions manager does not read; matched here by its exact shape. Used by the pin-follow rule below.",
"managerFilePatterns": [
"/^\\.gitea/workflows/molecule\\.yml$/"
],
"matchStrings": [
"MOLECULE_IMAGE:\\s*>-\\s*\\n\\s*(?<depName>git\\.rkdr\\.net/mortis/[a-z0-9._-]+):(?<currentValue>[^@\\s]+)@(?<currentDigest>sha256:[0-9a-f]{64})"
"MOLECULE_IMAGE(?:_[0-9]+)?:\\s*>-\\s*\\n\\s*(?<depName>git\\.rkdr\\.net/mortis/[a-z0-9._-]+):(?<currentValue>[^@\\s]+)@(?<currentDigest>sha256:[0-9a-f]{64})"
],
"datasourceTemplate": "docker",
"versioningTemplate": "semver"
@@ -98,6 +110,16 @@
],
"enabled": false
},
{
"description": "A new Ubuntu release is a deliberate edit, never a bump. The molecule-ubuntu<NNNN> images are one release by name and by contract (extensions/molecule/image-smoke* assert it), and every image's job container must run the same release as its Dockerfile (check_image_versions.py pins), so a base-image major in one file alone would fail the check or the build. Tag and digest updates within a release still arrive.",
"matchPackageNames": [
"ubuntu"
],
"matchUpdateTypes": [
"major"
],
"enabled": false
},
{
"description": "Majors are reviewed by hand.",
"matchUpdateTypes": [
@@ -109,7 +131,7 @@
]
},
{
"description": "ansible-core and ansible-lint move together (the lint rules follow the core version). A new ansible-core minor can bring new sanity findings (the shared tests/sanity/ignore-common.txt covers the known ones), so its minor and major bumps are manual; patches of both follow the global automerge.",
"description": "ansible-core and ansible-lint move together (the lint rules follow the core version). Minor and patch bumps automerge like the rest, majors are manual. A new ansible-core minor can bring new sanity findings: the shared tests/sanity/ignore-common.txt covers the known ones, and the Build check (ansible-test sanity) is the gate, so a bump that shows new findings stays red and is not merged.",
"groupName": "ansible tooling",
"matchDatasources": [
"pypi"
@@ -120,21 +142,7 @@
]
},
{
"description": "ansible-core minor and major bumps: a new core can bring new sanity findings, so a human reviews them.",
"matchDatasources": [
"pypi"
],
"matchPackageNames": [
"ansible-core"
],
"matchUpdateTypes": [
"minor",
"major"
],
"automerge": false
},
{
"description": "The job container of image.yml (ubuntu by digest) holds the org registry push credential while the image job runs: never automerged, and kept in its own branch so the Dockerfile base-image bumps are not held back with it.",
"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.",
"matchFileNames": [
".gitea/workflows/image.yml"
],
@@ -149,11 +157,11 @@
"automerge": false
},
{
"description": "Pin follow-up for our own images (git.rkdr.net/mortis/*): DISABLED. Phase 4, after a dry run against the registry; until then moving a pin is a reviewed hand edit (scripts/check_image_versions.py pins).",
"description": "Pin follow-up for our own images (git.rkdr.net/mortis/*): moves the image:<version>@sha256:<digest> pins of lint.yml, build.yml and molecule.yml to the newest published version and its digest, and automerges (PR 2 of the update loop). The pull request's own Lint and Build run in the new image before the merge, scripts/check_bot_pr_diff.py allows only these pin lines, and scripts/check_image_versions.py pins fails a pin that is newer than the matrix. The registry lists tags and digests anonymously, so no hostRules are needed. A major version stays manual (rule above).",
"matchPackageNames": [
"git.rkdr.net/mortis/**"
],
"enabled": false
"automerge": true
}
]
}
+7 -5
View File
@@ -1,10 +1,12 @@
# Pinned tooling for lint and build, used by CI (.gitea/workflows) and locally:
# python3 -m venv .venv && . .venv/bin/activate && pip install -r requirements-dev.txt
# ansible-core and ansible-lint match the environment repo's runner image
# (hosts/group_vars/all/ci_python_tools.yml there). Renovate bumps these pins.
ansible-core==2.21.5
# ansible-core and ansible-lint started equal to the environment repo's runner image
# (hosts/group_vars/all/ci_python_tools.yml there) and are no longer kept equal automatically.
# Renovate (renovate.json) bumps these pins; a bump rebuilds the ci image (images/ci) and
# Renovate then moves the consumers' pins to it.
ansible-core==2.22.0
ansible-lint==26.10.1
pre-commit==4.7.0
antsibull-changelog==0.35.2
antsibull-changelog==0.36.0
galaxy-importer==0.4.44
reuse==6.2.0
reuse==6.3.0
View File
Whitespace-only changes.
+72
View File
@@ -0,0 +1,72 @@
# docker
Installs Docker Engine from the upstream Docker APT repository, optionally updates it, or removes it, and adds listed users to the `docker` group. Variables and their types are defined in [`meta/argument_specs.yml`](meta/argument_specs.yml), which is the source of truth.
## Supported platforms
Ubuntu. The key and repository URLs point at `download.docker.com/linux/ubuntu`, and the source line uses `ansible_distribution_release`. The default architecture is `amd64`. A limited molecule scenario covers the role's own logic (see [Tests](#tests)); the real Docker Engine is not tested.
## Requirements and run order
- Needs gathered facts and privilege escalation.
- Use it by its fully qualified name, `mortis.kamino.docker`.
- Run it before any role that needs the Docker group. Roles that install later and create their own user must add that user to the group themselves (see `docker_users`).
- The `ufw` role is not a dependency and is not called: Docker publishes ports through iptables and owns no UFW rule.
## Role variables
| Variable | Default | Required | Description |
|---|---|---|---|
| `docker_remove` | `false` | no | Remove Docker instead of installing it. |
| `docker_remove_data` | `false` | no | With `docker_remove`, purge packages and delete `/var/lib/docker`. |
| `docker_update` | `false` | no | Upgrade packages to their current candidate version. |
| `docker_packages` | `docker-ce`, `docker-ce-cli`, `containerd.io` | no | Packages managed. |
| `docker_keyring_path` | `/etc/apt/keyrings/docker.asc` | no | Repository key location. |
| `docker_apt_list_path` | `/etc/apt/sources.list.d/docker.list` | no | APT source file. |
| `docker_gpg_url` | `https://download.docker.com/linux/ubuntu/gpg` | no | Key URL. |
| `docker_repo_base_url` | `https://download.docker.com/linux/ubuntu` | no | Repository base URL. |
| `docker_apt_arch` | `amd64` | no | Architecture in the APT source. |
| `docker_service` | `docker` | no | systemd unit name. |
| `docker_group` | `docker` | no | Group for `docker_users`. |
| `docker_users` | `[]` | no | Users added to the group. |
## Tags
`docker` (everything), `install`, `update`, `remove`, `configure` (group membership). The tasks in `remove.yml` carry `docker` and `remove`.
Update (`docker_update: true`) and removal (`docker_remove: true`) are opt-in: run them on a host that is safe to change.
## Example play
```yaml
- hosts: standalone_vms
roles:
- role: mortis.kamino.docker
vars:
docker_users: [deploy]
```
## Tests
`molecule/default` runs in CI only (`.gitea/workflows/molecule.yml`, no local runner), in the `molecule-ubuntu2404` test container. A real Docker Engine cannot run there: `dockerd` needs the bridge, iptables rules and a delegated cgroup, and the container has no privileged mode. So the scenario builds a local APT repository, signs it with a throwaway key, and points the role at it with `docker_gpg_url` and `docker_repo_base_url`. The repository holds empty stand-ins for `docker-ce`, `docker-ce-cli` and `containerd.io`. The stand-in `docker-ce` ships a stub `docker.service` (`sleep infinity`) and creates the `docker` group, as the real package does.
What it shows, with the role's tasks running unchanged:
- 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 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`.
- The argument check refuses a mapping for `docker_users` and a non-boolean `docker_remove`.
- A second run changes nothing (molecule's idempotence check).
What it does not show: that the upstream repository and key at `download.docker.com` are reachable and valid, that the real packages install, that `dockerd` starts, anything about container networking or iptables, the `docker_update` path (`tasks/update.yml`), and removal without `docker_remove_data` (the removal stops the unit first, so it can run only once per install). It needs the Ubuntu mirrors, for `gnupg` in `prepare.yml` and the `curl` the role installs. These gaps are a known residual risk of the role.
## Notes
- `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`.
- Installing or updating the packages notifies `Restart docker`. The `meta: flush_handlers` at the end of `tasks/main.yml` is untagged, so it runs only without a `--tags` selection; under `--tags update` (or `install`) it is skipped and the handler runs at the end of the play instead.
- Do not combine with anything that installs the distro `docker.io` package on the same host: this role installs `docker-ce` from Docker's repository, and the two packages conflict.
- Docker bypasses UFW for published ports (`-p`), so UFW rules do not restrict container ports.
- `no_log` is not used: the role handles no secrets.
+31
View File
@@ -0,0 +1,31 @@
---
docker_update: false
docker_remove_data: false
docker_remove: false
docker_packages:
- docker-ce
- docker-ce-cli
- containerd.io
docker_keyring_path: /etc/apt/keyrings/docker.asc
docker_apt_list_path: /etc/apt/sources.list.d/docker.list
docker_gpg_url: https://download.docker.com/linux/ubuntu/gpg
docker_repo_base_url: https://download.docker.com/linux/ubuntu
# Override per host if a host is not amd64.
docker_apt_arch: amd64
docker_service: docker
docker_group: docker
# Usernames to add to the `docker` group at install time. Left empty by
# default: a role that needs Docker access but installs *after* this one in
# a host's `services:` list won't have created its run-as user yet when this
# role runs, so it must add itself to the group in its own tasks instead.
# This list only helps a role/user that already exists before `docker` runs.
docker_users: []
# Docker manipulates iptables directly for any published container port
# (`-p`), bypassing UFW rules entirely - so the role owns no UFW rule and does
# not call the ufw role.
+6
View File
@@ -0,0 +1,6 @@
---
- name: Restart docker
become: true
ansible.builtin.systemd:
name: "{{ docker_service }}"
state: restarted
+79
View File
@@ -0,0 +1,79 @@
---
argument_specs:
main:
short_description: Install, update or remove Docker Engine
description:
- >-
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).
options:
docker_remove:
type: bool
default: false
description:
- >-
Removes Docker instead of installing it. Stops the service, removes the packages, the APT source and the keyring,
and skips the install, update and group tasks.
docker_remove_data:
type: bool
default: false
description:
- >-
Only used with C(docker_remove). Purges the packages and deletes C(/var/lib/docker), which destroys images, containers and volumes.
docker_update:
type: bool
default: false
description:
- >-
Upgrades each package in C(docker_packages) to its current APT candidate version, pinned as package=version.
The C(Restart docker) handler is notified only when a package actually changes.
docker_packages:
type: list
elements: str
default: [docker-ce, docker-ce-cli, containerd.io]
description:
- Packages installed, updated or removed.
docker_keyring_path:
type: path
default: /etc/apt/keyrings/docker.asc
description:
- Where the Docker repository key is stored.
docker_apt_list_path:
type: path
default: /etc/apt/sources.list.d/docker.list
description:
- APT source file written for the Docker repository.
docker_gpg_url:
type: str
default: https://download.docker.com/linux/ubuntu/gpg
description:
- URL of the repository signing key.
docker_repo_base_url:
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.
docker_apt_arch:
type: str
default: amd64
description:
- Architecture written into the APT source. Override per host if a host is not amd64.
docker_service:
type: str
default: docker
description:
- Name of the systemd unit that is enabled, started, restarted and stopped.
docker_group:
type: str
default: docker
description:
- Group that C(docker_users) are added to.
docker_users:
type: list
elements: str
default: []
description:
- >-
Existing users added to C(docker_group) with append. Empty by default, because a role that installs after docker creates its
run-as user too late and must join the group itself.
+17
View File
@@ -0,0 +1,17 @@
---
galaxy_info:
role_name: docker
namespace: mortis
author: Defame1297
license: GPL-3.0-or-later
description: Install, update or remove Docker Engine from the upstream Docker APT repository and add users to the docker group.
min_ansible_version: "2.19"
platforms:
- name: Ubuntu
versions:
- all
galaxy_tags:
- docker
- containers
- apt
dependencies: []
@@ -0,0 +1,61 @@
---
# The role runs unchanged against a signed local repository of stand-in packages (see
# prepare.yml), so the key fetch, the source line, the package install, the unit, the group
# membership and the handler are the real tasks. Only the packages are stand-ins: no Docker
# Engine is installed, and nothing here shows that dockerd works.
- name: Converge the role against the stand-in repository
hosts: all
vars:
docker_gpg_url: file:///srv/docker-stub-repo/docker.asc
docker_repo_base_url: file:///srv/docker-stub-repo
docker_users: [moleculeuser]
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
+101
View File
@@ -0,0 +1,101 @@
#!/bin/bash
# Builds the signed APT repository the docker scenario installs from, so the role's own key,
# source-line and package tasks run for real without the real Docker Engine.
#
# build-stub-repo.sh <repo-root> <codename> <work-dir>
#
# The repository holds empty stand-ins for docker-ce, docker-ce-cli and containerd.io (the
# default docker_packages). docker-ce ships a stub docker.service and a postinst that creates
# the docker group, as the real package does. The Release file is signed with a throwaway key
# generated here; the matching public key is exported to <repo-root>/docker.asc, which is what
# the role fetches as its keyring. The secret key stays in <work-dir> and is never installed.
set -euo pipefail
repo=${1:?usage: build-stub-repo.sh <repo-root> <codename> <work-dir>}
codename=${2:?usage: build-stub-repo.sh <repo-root> <codename> <work-dir>}
work=${3:?usage: build-stub-repo.sh <repo-root> <codename> <work-dir>}
version=0.0.1~molecule
rm -rf "$repo" "$work"
mkdir -p "$repo/pool" "$repo/dists/$codename/stable/binary-amd64" "$work/gnupg" "$work/pkg"
chmod 0700 "$work/gnupg"
build_deb() {
local name=$1 tree="$work/pkg/$1"
mkdir -p "$tree/DEBIAN"
cat > "$tree/DEBIAN/control" <<CONTROL
Package: $name
Version: $version
Architecture: all
Maintainer: Molecule <molecule@invalid>
Description: stand-in for $name in the docker role's molecule scenario
Empty package. It installs nothing from Docker.
CONTROL
if [ "$name" = docker-ce ]; then
mkdir -p "$tree/usr/lib/systemd/system"
cat > "$tree/usr/lib/systemd/system/docker.service" <<'UNIT'
[Unit]
Description=Stand-in for the Docker Engine (molecule)
[Service]
ExecStart=/bin/sleep infinity
[Install]
WantedBy=multi-user.target
UNIT
cat > "$tree/DEBIAN/postinst" <<'POSTINST'
#!/bin/sh
set -e
if [ "$1" = configure ]; then
getent group docker > /dev/null || groupadd --system docker
systemctl daemon-reload || true
fi
POSTINST
chmod 0755 "$tree/DEBIAN/postinst"
fi
dpkg-deb --root-owner-group --build "$tree" "$repo/pool/${name}_${version}_all.deb" > /dev/null
}
for name in docker-ce docker-ce-cli containerd.io; do
build_deb "$name"
done
index="$repo/dists/$codename/stable/binary-amd64/Packages"
: > "$index"
for deb in "$repo"/pool/*.deb; do
{
dpkg-deb --field "$deb"
echo "Filename: pool/$(basename "$deb")"
echo "Size: $(stat --format %s "$deb")"
echo "SHA256: $(sha256sum "$deb" | cut -d' ' -f1)"
echo
} >> "$index"
done
release="$repo/dists/$codename/Release"
{
echo "Origin: molecule-stub"
echo "Label: molecule-stub"
echo "Suite: $codename"
echo "Codename: $codename"
echo "Date: $(LC_ALL=C date -u '+%a, %d %b %Y %H:%M:%S UTC')"
echo "Architectures: amd64"
echo "Components: stable"
echo "SHA256:"
echo " $(sha256sum "$index" | cut -d' ' -f1) $(stat --format %s "$index") stable/binary-amd64/Packages"
} > "$release"
export GNUPGHOME="$work/gnupg"
gpg --batch --quiet --pinentry-mode loopback --passphrase '' \
--quick-generate-key 'molecule stub repository <molecule@invalid>' rsa2048 sign never
gpg --batch --quiet --yes --armor --export > "$repo/docker.asc"
gpg --batch --quiet --yes --pinentry-mode loopback --passphrase '' --clearsign \
--output "$repo/dists/$codename/InRelease" "$release"
gpg --batch --quiet --yes --pinentry-mode loopback --passphrase '' --armor --detach-sign \
--output "$repo/dists/$codename/Release.gpg" "$release"
# The _apt user reads the repository during apt update.
chmod -R a+rX "$repo"
# Stop the gpg-agent that gpg started, so it does not outlive the script.
gpgconf --kill gpg-agent || true
@@ -0,0 +1,28 @@
---
# Runs on the repository's own runner (label kamino-molecule), in the molecule-ubuntu2404 image
# (MOLECULE_IMAGE, the pin in .gitea/workflows/molecule.yml). No privileged mode: systemd needs a
# writable cgroup, nothing else. NET_ADMIN is kept so the platform matches the other scenarios;
# this role does not need it, because the Docker Engine is a stand-in package and no daemon,
# bridge or iptables rule is created.
driver:
name: docker
platforms:
- name: docker-instance
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
capabilities:
- NET_ADMIN
security_opts:
- apparmor=unconfined
provisioner:
name: ansible
verifier:
name: ansible
+55
View File
@@ -0,0 +1,55 @@
---
# The real Docker Engine cannot run in an unprivileged test container (dockerd needs the
# bridge, iptables and a delegated cgroup), so the role installs stand-in packages from a
# local APT repository. The repository is built and signed here, with a throwaway key, so the
# role's own tasks run unchanged: fetch the key, write the source line, install, enable and
# start the unit, join the group. Like the pihole and system_baseline scenarios, this needs
# the Ubuntu mirrors for gnupg and for the curl the role installs.
- name: Prepare
hosts: all
vars:
docker_molecule_repo: /srv/docker-stub-repo
docker_molecule_work: /var/tmp/docker-stub-work
tasks:
- name: Install gnupg, which signs the stand-in repository
ansible.builtin.apt:
name: gnupg
state: present
update_cache: true
- name: Copy the repository builder
ansible.builtin.copy:
src: build-stub-repo.sh
dest: /var/tmp/build-stub-repo.sh
owner: root
group: root
mode: "0755"
- name: Build and sign the stand-in repository
ansible.builtin.command:
argv:
- /var/tmp/build-stub-repo.sh
- "{{ docker_molecule_repo }}"
- "{{ ansible_facts['distribution_release'] }}"
- "{{ docker_molecule_work }}"
creates: "{{ docker_molecule_repo }}/docker.asc"
- name: Remove the signing key and the builder
ansible.builtin.file:
path: "{{ item }}"
state: absent
loop:
- "{{ docker_molecule_work }}"
- /var/tmp/build-stub-repo.sh
- name: Create a user for the docker group
ansible.builtin.user:
name: moleculeuser
shell: /usr/sbin/nologin
create_home: false
- name: Seed a Docker data directory for the removal test
ansible.builtin.file:
path: /var/lib/docker/molecule-marker
state: directory
mode: "0755"
+134
View File
@@ -0,0 +1,134 @@
---
# 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
# runs the removal, which would break the checks of the first, so it comes last.
- name: Verify the install
hosts: all
vars:
docker_verify_packages: [docker-ce, docker-ce-cli, containerd.io]
tasks:
- name: Read the source list and the two keys
ansible.builtin.slurp:
src: "{{ item }}"
loop:
- /etc/apt/sources.list.d/docker.list
- /etc/apt/keyrings/docker.asc
- /srv/docker-stub-repo/docker.asc
register: docker_verify_files
- name: The source line carries the arch, the keyring and the release
ansible.builtin.assert:
that:
- >-
(docker_verify_files.results[0].content | b64decode) ==
'deb [arch=amd64 signed-by=/etc/apt/keyrings/docker.asc] file:///srv/docker-stub-repo '
~ ansible_facts['distribution_release'] ~ ' stable\n'
quiet: true
- name: The keyring is the key the repository published
ansible.builtin.assert:
that:
- docker_verify_files.results[1].content == docker_verify_files.results[2].content
quiet: true
- name: Stat the keyring
ansible.builtin.stat:
path: /etc/apt/keyrings/docker.asc
register: docker_verify_keyring
- name: The keyring is world-readable, as apt needs
ansible.builtin.assert:
that: docker_verify_keyring.stat.mode == "0644"
quiet: true
- name: Ask apt where docker-ce comes from
ansible.builtin.command: apt-cache policy docker-ce
register: docker_verify_policy
changed_when: false
- name: Apt installed docker-ce from the signed stand-in repository
ansible.builtin.assert:
that:
- "'Installed: 0.0.1~molecule' in docker_verify_policy.stdout"
- "'file:/srv/docker-stub-repo' in docker_verify_policy.stdout"
quiet: true
- name: Ask dpkg for the package states
ansible.builtin.command:
argv: [dpkg-query, --show, --showformat, "${db:Status-Status}\\n", "{{ item }}"]
loop: "{{ docker_verify_packages }}"
register: docker_verify_dpkg
changed_when: false
- name: Every package is installed
ansible.builtin.assert:
that: docker_verify_dpkg.results | map(attribute='stdout') | map('trim') | unique | list == ['installed']
quiet: true
- name: Ask systemd about the unit
ansible.builtin.systemd:
name: docker.service
register: docker_verify_unit
check_mode: true
- name: The unit is enabled and running
ansible.builtin.assert:
that:
- docker_verify_unit.status.UnitFileState == "enabled"
- docker_verify_unit.status.ActiveState == "active"
quiet: true
- name: Ask which groups the user is in
ansible.builtin.command: id -nG moleculeuser
register: docker_verify_groups
changed_when: false
- name: The user joined the docker group
ansible.builtin.assert:
that: "'docker' in docker_verify_groups.stdout.split()"
quiet: true
# docker_remove_data is set, so this also covers the destructive path: the packages are
# purged and /var/lib/docker, seeded in prepare.yml, is deleted. The removal stops the unit
# before the package takes it away, so it can only run once; a second run would fail on the
# missing unit, which is why it is not in the converge.
- name: Verify the removal
hosts: all
gather_facts: false
vars:
docker_remove: true
docker_remove_data: true
docker_verify_packages: [docker-ce, docker-ce-cli, containerd.io]
tasks:
- name: Remove Docker with its data
ansible.builtin.include_role:
name: mortis.kamino.docker
- name: Stat what the removal must delete
ansible.builtin.stat:
path: "{{ item }}"
loop:
- /etc/apt/sources.list.d/docker.list
- /etc/apt/keyrings/docker.asc
- /var/lib/docker
- /usr/lib/systemd/system/docker.service
register: docker_verify_gone
- name: The source list, the keyring, the data and the unit are gone
ansible.builtin.assert:
that: docker_verify_gone.results | map(attribute='stat.exists') | unique | list == [false]
quiet: true
- name: Ask dpkg for the package states
ansible.builtin.command:
argv: [dpkg-query, --show, --showformat, "${db:Status-Status}\\n", "{{ item }}"]
loop: "{{ docker_verify_packages }}"
register: docker_verify_dpkg
changed_when: false
failed_when: false
- name: No package is installed any more
ansible.builtin.assert:
that: "'installed' not in docker_verify_dpkg.results | map(attribute='stdout') | map('trim') | list"
quiet: true
+52
View File
@@ -0,0 +1,52 @@
---
- name: Install prerequisite packages
become: true
ansible.builtin.apt:
name:
- ca-certificates
- curl
state: present
update_cache: true
tags: [docker, install]
- name: Ensure APT keyrings directory exists
become: true
ansible.builtin.file:
path: /etc/apt/keyrings
state: directory
mode: "0755"
tags: [docker, install]
- name: Install Docker APT GPG key
become: true
ansible.builtin.get_url:
url: "{{ docker_gpg_url }}"
dest: "{{ docker_keyring_path }}"
mode: "0644"
tags: [docker, install]
- name: Install Docker APT source list
become: true
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
mode: "0644"
tags: [docker, install]
- name: Install Docker Engine packages
become: true
ansible.builtin.apt:
name: "{{ docker_packages }}"
state: present
update_cache: true
notify: Restart docker
tags: [docker, install]
- name: Enable and start Docker service
become: true
ansible.builtin.systemd:
name: "{{ docker_service }}"
enabled: true
state: started
tags: [docker, install]
+30
View File
@@ -0,0 +1,30 @@
---
- name: Remove Docker (explicit only)
ansible.builtin.include_tasks: remove.yml
when: docker_remove | default(false) | bool
tags: [docker, remove]
- name: Install Docker Engine
ansible.builtin.include_tasks: install.yml
when: not (docker_remove | default(false) | bool)
tags: [docker, install]
- name: Ensure Docker Engine is up-to-date
ansible.builtin.include_tasks: update.yml
when:
- not (docker_remove | default(false) | bool)
- docker_update | bool
tags: [docker, update]
- name: Add configured users to the docker group
become: true
ansible.builtin.user:
name: "{{ item }}"
groups: "{{ docker_group }}"
append: true
loop: "{{ docker_users }}"
when: not (docker_remove | default(false) | bool)
tags: [docker, configure]
- name: Flush handlers
ansible.builtin.meta: flush_handlers
+39
View File
@@ -0,0 +1,39 @@
---
# Run with docker_remove=true (and docker_remove_data=true to purge) on a host that is safe to change.
- name: Stop and disable Docker service
become: true
ansible.builtin.systemd:
name: "{{ docker_service }}"
state: stopped
enabled: false
tags: [docker, remove]
- name: Remove Docker Engine packages
become: true
ansible.builtin.apt:
name: "{{ docker_packages }}"
state: absent
purge: "{{ docker_remove_data | default(false) | bool }}"
tags: [docker, remove]
- name: Remove Docker APT source list
become: true
ansible.builtin.file:
path: "{{ docker_apt_list_path }}"
state: absent
tags: [docker, remove]
- name: Remove Docker APT keyring
become: true
ansible.builtin.file:
path: "{{ docker_keyring_path }}"
state: absent
tags: [docker, remove]
- name: Remove Docker data directory (images, containers, volumes)
become: true
ansible.builtin.file:
path: /var/lib/docker
state: absent
when: docker_remove_data | default(false) | bool
tags: [docker, remove]
+61
View File
@@ -0,0 +1,61 @@
---
# Run with docker_update=true (tag: update).
- name: Refresh APT cache before checking for Docker updates
become: true
ansible.builtin.apt:
update_cache: true
tags: [docker, update]
- name: Determine latest available candidate version for each Docker package
ansible.builtin.command: "apt-cache policy {{ item }}"
register: docker_apt_policy
changed_when: false
# Read-only, so it also runs in the --check preview. Skipped there, there is no stdout to read the
# candidate from.
check_mode: false
loop: "{{ docker_packages }}"
loop_control:
label: "{{ item }}"
tags: [docker, update]
- name: Extract candidate version for each Docker package
ansible.builtin.set_fact:
docker_candidates: >-
{{ docker_candidates | default({}) | combine({item.item:
item.stdout | regex_search('Candidate:\s+(\S+)', '\1')
| default([''], true) | first}) }}
loop: "{{ docker_apt_policy.results }}"
loop_control:
label: "{{ item.item }}"
tags: [docker, update]
- name: Fail if any Docker package has no installable candidate
ansible.builtin.fail:
msg: >-
No installable candidate version found for Docker package '{{ item.key }}'
(apt-cache policy reported candidate '{{ item.value }}'). Check that the
Docker APT repo is reachable and the package name in docker_packages is
correct.
loop: "{{ docker_candidates | dict2items }}"
loop_control:
label: "{{ item.key }}"
when: not item.value or item.value == '(none)'
tags: [docker, update]
# Pinned to each package's resolved candidate version (never state=latest)
# so this task stays idempotent and passes ansible-lint's package-latest rule.
- name: Build pinned package=version list from candidates
ansible.builtin.set_fact:
docker_pinned_packages: "{{ docker_pinned_packages | default([]) + [item.key ~ '=' ~ item.value] }}"
loop: "{{ docker_candidates | dict2items }}"
loop_control:
label: "{{ item.key }}"
tags: [docker, update]
- name: Update Docker Engine packages to latest candidate versions
become: true
ansible.builtin.apt:
name: "{{ docker_pinned_packages }}"
state: present
notify: Restart docker
tags: [docker, update]
+73
View File
@@ -0,0 +1,73 @@
# fail2ban
Installs Fail2Ban, writes `/etc/fail2ban/jail.local` from `fail2ban_jails`, ensures the service runs and verifies the enabled jails loaded. A second entry point, `service_jail`, lets a service role deploy its own jail and filter into `jail.d`. 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), the image the molecule scenario runs on. The default `sshd` jail reads the systemd journal because sshd logs there on that release. The role installs `python3-systemd`, which `backend = systemd` jails need.
## Requirements and run order
- Use it by its fully qualified name, `mortis.kamino.fail2ban`.
- No hard prerequisite. `system_baseline` also lists `fail2ban` among its packages, so it normally runs first; this role installs it regardless.
- Main entry point: apply it after `ufw` in the play that hardens a host.
- `service_jail` entry point: called by a service role such as `gitea` (`include_role` with `tasks_from: service_jail`) after it has installed the service.
- A file named by a jail's `logpath` must exist when `fail2ban-client -t` runs, or the configuration test fails.
## Role variables
Main entry point:
| Variable | Default | Required | Description |
|---|---|---|---|
| `fail2ban_package_name` | `fail2ban` | no | Package name. |
| `fail2ban_jails` | one `sshd` jail (systemd backend, maxretry 3, bantime 1h, findtime 10m) | no | Jails written to `jail.local`. Each needs `name`, `enabled`, `filter`, `maxretry`, `bantime`, `findtime` and `logpath`, `journalmatch` or `backend: systemd`. |
| `fail2ban_service` | `enabled: true`, `state: started` | no | Service enablement and state. |
| `fail2ban_defaults` | `maxretry: 5`, `bantime: 600`, `findtime: 600` | no | Fallbacks for those keys. Only used by the `service_jail` entry point; main-entry jails must set all three (`tasks/validate.yml` asserts them), so there the fallback only applies when validation is skipped, for example under `--tags fail2ban_configure`. |
`service_jail` entry point:
| Variable | Default | Required | Description |
|---|---|---|---|
| `fail2ban_service_name` | none | yes | Jail name and file name under `filter.d` and `jail.d`. |
| `fail2ban_service_jail` | none | yes | Jail mapping; needs `logpath` or `journalmatch`. |
| `fail2ban_service_filter` | none | yes | Filter mapping; needs `failregex`, optional `ignoreregex`. |
| `fail2ban_package_name`, `fail2ban_defaults` | as above | no | Read from the role defaults. |
## Tags
Main entry point: `fail2ban` (everything), `fail2ban_install`, `fail2ban_validate`, `fail2ban_configure`, `fail2ban_service`.
`service_jail`: `fail2ban`, `fail2ban_install`, `fail2ban_service_jail`.
## Example play
```yaml
- hosts: pve_lxcs
roles:
- role: mortis.kamino.fail2ban
vars:
fail2ban_defaults:
maxretry: 5
bantime: 600
findtime: 600
- hosts: gitea
tasks:
- name: Deploy a service jail
ansible.builtin.include_role:
name: mortis.kamino.fail2ban
tasks_from: service_jail
vars:
fail2ban_service_name: gitea
fail2ban_service_jail: "{{ gitea_fail2ban_jail }}"
fail2ban_service_filter: "{{ gitea_fail2ban_filter }}"
```
## Notes
- Each service owns `jail.d/<name>.local`, so one play cannot overwrite another service's jail. `jail.local` only holds `fail2ban_jails`.
- Changing `jail.local` restarts Fail2Ban, which drops the in-memory ban list. Service jails only trigger a reload.
- `fail2ban-client -t` runs on every invocation of both entry points, not only when a file changed, so a broken file fails every run until fixed. It also runs in check mode.
- `fail2ban_service_jail` and `fail2ban_service_filter` must be passed as a single templated expression so they stay mappings, not strings or lists.
- `no_log` is not used: the role handles no secrets.
+25
View File
@@ -0,0 +1,25 @@
---
fail2ban_package_name: fail2ban
fail2ban_jails:
- name: sshd
enabled: true
port: ssh
filter: sshd
# Read the journal, not /var/log/auth.log: sshd logs to the journal on
# Ubuntu 24.04 and rsyslog's auth.log stays empty. Pinned so detection does
# not depend on the package's default backend. The filter's own journalmatch
# applies.
backend: systemd
maxretry: 3
bantime: "1h"
findtime: "10m"
fail2ban_service:
enabled: true
state: started
fail2ban_defaults:
maxretry: 5
bantime: 600
findtime: 600
+17
View File
@@ -0,0 +1,17 @@
---
- name: Restart Fail2Ban
become: true
ansible.builtin.service:
name: fail2ban
state: restarted
# Service jails only add a jail.d file, so reload instead of restarting the
# daemon (a restart drops the in-memory ban list). state=reloaded starts the
# service if it is not running. The config test runs as a task in
# service_jail.yml, so a broken file fails every run instead of only the one
# that wrote it.
- name: Reload Fail2Ban
become: true
ansible.builtin.systemd:
name: fail2ban
state: reloaded
+99
View File
@@ -0,0 +1,99 @@
---
argument_specs:
main:
short_description: Install and configure Fail2Ban
description:
- >-
Installs fail2ban and python3-systemd, validates C(fail2ban_jails), writes /etc/fail2ban/jail.local, tests the
configuration, ensures the service and checks that every enabled jail is loaded.
options:
fail2ban_package_name:
type: str
default: fail2ban
description:
- Name of the Fail2Ban package.
fail2ban_jails:
type: list
elements: dict
description:
- Jails written to jail.local. The role default is a single C(sshd) jail on the systemd backend.
- >-
Each item needs C(name), C(enabled), C(filter), C(maxretry), C(bantime) and C(findtime), plus one of
C(logpath), C(journalmatch) or C(backend) set to systemd.
- Optional keys are C(port) (default any), C(backend), C(journalmatch) and C(logpath).
fail2ban_service:
type: dict
description:
- Service management. The role default is C(enabled=true), C(state=started). Missing keys fall back to those values.
- Enabled jails are only checked with fail2ban-client when state is started.
options:
enabled:
type: bool
description: Whether the service starts at boot.
state:
type: str
description: Desired systemd state of the service, for example started or stopped.
fail2ban_defaults:
type: dict
description:
- >-
Fallback C(maxretry), C(bantime) and C(findtime). The role default is 5, 600 and 600. Only used by the
service_jail entry point; main-entry jails must set all three (C(tasks/validate.yml) asserts them), so
there the fallback only applies when validation is skipped, for example under C(--tags fail2ban_configure).
options:
maxretry:
type: int
description: Fallback number of failures before a ban.
bantime:
type: raw
description: Fallback ban duration, seconds or a Fail2Ban time string.
findtime:
type: raw
description: Fallback window in which failures are counted, seconds or a Fail2Ban time string.
service_jail:
short_description: Deploy one service jail and filter into jail.d
description:
- Entry point for a service role that owns its jail, used with C(include_role) and C(tasks_from=service_jail).
- >-
Installs Fail2Ban, writes /etc/fail2ban/filter.d/<name>.conf and /etc/fail2ban/jail.d/<name>.local, reloads
Fail2Ban and tests the configuration. It never touches jail.local.
options:
fail2ban_package_name:
type: str
default: fail2ban
description:
- Name of the Fail2Ban package installed by this entry point.
fail2ban_service_name:
type: str
required: true
description:
- Service name, used as the jail section name and the file names under filter.d and jail.d.
fail2ban_service_jail:
type: raw
required: true
description:
- >-
Mapping describing the jail. Must contain C(logpath) or C(journalmatch). Optional keys are C(enabled) (default
true), C(port) (default any), C(filter) (default the service name), C(backend) (default systemd, only used
with journalmatch), C(maxretry), C(bantime) and C(findtime), which fall back to C(fail2ban_defaults).
- Typed raw because callers pass a templated variable, for example C(gitea_fail2ban_jail). It is asserted to be a mapping.
fail2ban_service_filter:
type: raw
required: true
description:
- Mapping with C(failregex) (required) and C(ignoreregex) (optional, default empty).
- Typed raw because callers pass a templated variable. It is asserted to be a mapping.
fail2ban_defaults:
type: dict
description:
- Fallback C(maxretry), C(bantime) and C(findtime), read from the role defaults.
options:
maxretry:
type: int
description: Fallback number of failures before a ban.
bantime:
type: raw
description: Fallback ban duration.
findtime:
type: raw
description: Fallback failure counting window.
+16
View File
@@ -0,0 +1,16 @@
---
galaxy_info:
role_name: fail2ban
namespace: mortis
author: Defame1297
license: GPL-3.0-or-later
description: Install Fail2Ban, manage jail.local and the service, and deploy per-service jails and filters into jail.d.
min_ansible_version: "2.19"
platforms:
- name: Ubuntu
versions:
- noble
galaxy_tags:
- fail2ban
- security
dependencies: []
@@ -0,0 +1,57 @@
---
- name: Converge the base role (jail.local, sshd jail on the systemd backend)
hosts: all
roles:
- role: mortis.kamino.fail2ban
# The entry point service roles use. Two services must not overwrite each other:
# each gets its own jail.d file.
- name: Converge two service jails through the entry point
hosts: all
tasks:
- name: Service jail with a logpath
ansible.builtin.include_role:
name: mortis.kamino.fail2ban
tasks_from: service_jail
vars:
fail2ban_service_name: svc-a
fail2ban_service_jail:
port: "8080"
logpath: /var/log/svc-a.log
maxretry: 4
fail2ban_service_filter:
failregex: "^.*auth failure from <HOST>.*$"
- name: Service jail with a journalmatch
ansible.builtin.include_role:
name: mortis.kamino.fail2ban
tasks_from: service_jail
vars:
fail2ban_service_name: svc-b
fail2ban_service_jail:
port: "9090"
journalmatch: "_SYSTEMD_UNIT=ssh.service"
fail2ban_service_filter:
failregex: "^.*denied for <HOST>.*$"
# An input the entry point must reject. The block proves it is refused (the
# verify step proves no file was left behind); the play still passes, so the
# idempotence run stays clean.
- name: Missing failregex is rejected
block:
- name: Service jail without a failregex
ansible.builtin.include_role:
name: mortis.kamino.fail2ban
tasks_from: service_jail
vars:
fail2ban_service_name: svc-bad
fail2ban_service_jail:
logpath: /var/log/svc-a.log
fail2ban_service_filter: {}
- name: Fail when the invalid input was accepted
ansible.builtin.fail:
msg: service_jail accepted a filter without a failregex
rescue:
- name: The entry point refused the input
ansible.builtin.debug:
msg: Rejected as expected
@@ -0,0 +1,26 @@
---
# Runs on the repository's own runner (label kamino-molecule), in the molecule-ubuntu2404 image
# (MOLECULE_IMAGE, the pin in .gitea/workflows/molecule.yml). No privileged mode: systemd needs a
# writable cgroup and the firewall tools need NET_ADMIN, nothing else.
driver:
name: docker
platforms:
- name: fail2ban-instance
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
capabilities:
- NET_ADMIN
security_opts:
- apparmor=unconfined
provisioner:
name: ansible
verifier:
name: ansible
@@ -0,0 +1,13 @@
---
# The log file a service jail watches must exist, or `fail2ban-client -t` fails.
- name: Prepare
hosts: all
gather_facts: false
tasks:
- name: Create the log file the logpath jail watches
ansible.builtin.file:
path: /var/log/svc-a.log
state: touch
mode: "0644"
access_time: preserve
modification_time: preserve
@@ -0,0 +1,55 @@
---
# What matters: the daemon accepts the whole configuration, loads the base jail and
# both service jails (each from its own jail.d file, #433), the sshd jail does not
# fall back to the empty auth.log, and a rejected input left nothing behind. The
# file contents are the templates' own output and are not restated here.
- name: Verify
hosts: all
gather_facts: false
tasks:
- name: Read jail.local
ansible.builtin.slurp:
src: /etc/fail2ban/jail.local
register: fail2ban_verify_jail_local
- name: The sshd jail reads the journal, not auth.log
ansible.builtin.assert:
that: "'/var/log/auth.log' not in (fail2ban_verify_jail_local.content | b64decode)"
quiet: true
- name: Stat the service jails and the rejected one
ansible.builtin.stat:
path: "{{ item }}"
loop:
- /etc/fail2ban/jail.d/svc-a.local
- /etc/fail2ban/jail.d/svc-b.local
- /etc/fail2ban/jail.d/svc-bad.local
- /etc/fail2ban/filter.d/svc-bad.conf
register: fail2ban_verify_files
- name: Each service has its own file and the rejected input left nothing behind
ansible.builtin.assert:
that:
- fail2ban_verify_files.results[0].stat.exists
- fail2ban_verify_files.results[1].stat.exists
- not fail2ban_verify_files.results[2].stat.exists
- not fail2ban_verify_files.results[3].stat.exists
quiet: true
- name: Test the configuration the daemon will load
ansible.builtin.command: fail2ban-client -t
changed_when: false
- name: Ask the running daemon for its jails
ansible.builtin.command: fail2ban-client status
register: fail2ban_verify_status
changed_when: false
- name: The daemon loaded the base and both service jails
ansible.builtin.assert:
that:
- "'sshd' in fail2ban_verify_status.stdout"
- "'svc-a' in fail2ban_verify_status.stdout"
- "'svc-b' in fail2ban_verify_status.stdout"
- "'svc-bad' not in fail2ban_verify_status.stdout"
quiet: true
+10
View File
@@ -0,0 +1,10 @@
---
- name: Configure Fail2Ban jail.local
become: true
ansible.builtin.template:
src: jail.local.j2
dest: /etc/fail2ban/jail.local
owner: root
group: root
mode: "0600"
notify: Restart Fail2Ban
+9
View File
@@ -0,0 +1,9 @@
---
- name: Install Fail2Ban package
become: true
ansible.builtin.package:
name:
- "{{ fail2ban_package_name }}"
# Required for `backend = systemd` jails (journalmatch), e.g. gitea's.
- python3-systemd
state: present
+16
View File
@@ -0,0 +1,16 @@
---
- name: Install Fail2Ban
ansible.builtin.import_tasks: install.yml
tags: [fail2ban, fail2ban_install]
- name: Validate Fail2Ban jails
ansible.builtin.import_tasks: validate.yml
tags: [fail2ban, fail2ban_validate]
- name: Configure Fail2Ban
ansible.builtin.import_tasks: configure.yml
tags: [fail2ban, fail2ban_configure]
- name: Ensure Fail2Ban service
ansible.builtin.import_tasks: service.yml
tags: [fail2ban, fail2ban_service]
+36
View File
@@ -0,0 +1,36 @@
---
# -t loads every jail, so a jail that cannot start (missing logpath, bad
# backend) fails here. -d only dumps the config and treats those as warnings.
- name: Test Fail2Ban configuration
become: true
ansible.builtin.command: fail2ban-client -t
register: fail2ban_test
failed_when: fail2ban_test.rc != 0
changed_when: false
check_mode: false
- name: Ensure Fail2Ban service is running
become: true
ansible.builtin.systemd:
name: fail2ban
enabled: "{{ fail2ban_service.enabled | default(true) }}"
state: "{{ fail2ban_service.state | default('started') }}"
# Handlers run at the end of the play; flush so the restart happens before the
# jail check below.
- name: Apply pending Fail2Ban handlers
ansible.builtin.meta: flush_handlers
- name: Verify enabled jails are loaded
become: true
ansible.builtin.command: "fail2ban-client status {{ item.name }}"
loop: "{{ fail2ban_jails | selectattr('enabled') }}"
loop_control:
label: "{{ item.name }}"
register: fail2ban_jail_status
until: fail2ban_jail_status.rc == 0
retries: 5
delay: 2
changed_when: false
check_mode: false
when: fail2ban_service.state | default('started') == 'started'
+57
View File
@@ -0,0 +1,57 @@
---
# Entry point for a service role that owns its own jail. Called with
# `include_role: name=mortis.kamino.fail2ban tasks_from=service_jail` and explicit vars; the
# jail lands in jail.d/<name>.local, never in the shared jail.local, so one
# play cannot overwrite another service's jail.
- name: Install Fail2Ban
ansible.builtin.import_tasks: install.yml
tags: [fail2ban, fail2ban_install]
- name: Validate service jail inputs
ansible.builtin.assert:
that:
- fail2ban_service_name is string
- fail2ban_service_jail is mapping
- fail2ban_service_filter is mapping
- fail2ban_service_filter.failregex is defined
- fail2ban_service_jail.logpath is defined or fail2ban_service_jail.journalmatch is defined
fail_msg: >-
fail2ban_service_jail and fail2ban_service_filter must be dicts. Pass the
variable as a single templated expression, not wrapped in a list or
embedded in a string.
tags: [fail2ban, fail2ban_service_jail]
- name: Deploy service filter definition
become: true
ansible.builtin.copy:
dest: "/etc/fail2ban/filter.d/{{ fail2ban_service_name }}.conf"
content: |
[Definition]
failregex = {{ fail2ban_service_filter.failregex }}
ignoreregex = {{ fail2ban_service_filter.ignoreregex | default('') }}
owner: root
group: root
mode: "0644"
notify: Reload Fail2Ban
tags: [fail2ban, fail2ban_service_jail]
- name: Deploy service jail
become: true
ansible.builtin.template:
src: service_jail.local.j2
dest: "/etc/fail2ban/jail.d/{{ fail2ban_service_name }}.local"
owner: root
group: root
mode: "0644"
notify: Reload Fail2Ban
# Read-only, so it also runs in check mode. A failure leaves the broken file on
# disk and fails every run until fixed, instead of only the run that wrote it.
tags: [fail2ban, fail2ban_service_jail]
- name: Test Fail2Ban configuration
become: true
ansible.builtin.command: fail2ban-client -t
changed_when: false
check_mode: false
tags: [fail2ban, fail2ban_service_jail]
+13
View File
@@ -0,0 +1,13 @@
---
- name: Validate Fail2Ban jails
ansible.builtin.assert:
that:
- item.name is defined
- item.enabled is defined
- item.filter is defined
- item.logpath is defined or item.journalmatch is defined or item.backend | default('') == 'systemd'
- item.maxretry is defined
- item.bantime is defined
- item.findtime is defined
fail_msg: "Invalid Fail2Ban jail: {{ item }}"
loop: "{{ fail2ban_jails }}"
+21
View File
@@ -0,0 +1,21 @@
# Managed by Ansible - Fail2Ban jail.local
{% for jail in fail2ban_jails %}
[{{ jail.name }}]
enabled = {{ jail.enabled | default(true) }}
port = {{ jail.port | default('any') }}
filter = {{ jail.filter | default(jail.name) }}
{% if jail.backend is defined or jail.journalmatch is defined %}
backend = {{ jail.backend | default('systemd') }}
{% endif %}
{% if jail.journalmatch is defined %}
journalmatch = {{ jail.journalmatch }}
{% endif %}
{% if (jail.backend | default('systemd' if jail.journalmatch is defined else 'auto')) != 'systemd' %}
logpath = {{ jail.logpath | default('/var/log/auth.log') }}
{% endif %}
maxretry = {{ jail.maxretry | default(fail2ban_defaults.maxretry) }}
bantime = {{ jail.bantime | default(fail2ban_defaults.bantime) }}
findtime = {{ jail.findtime | default(fail2ban_defaults.findtime) }}
{% endfor %}
@@ -0,0 +1,14 @@
# Managed by Ansible - Fail2Ban jail for {{ fail2ban_service_name }}
[{{ fail2ban_service_name }}]
enabled = {{ fail2ban_service_jail.enabled | default(true) | lower }}
port = {{ fail2ban_service_jail.port | default('any') }}
filter = {{ fail2ban_service_jail.filter | default(fail2ban_service_name) }}
{% if fail2ban_service_jail.journalmatch is defined %}
backend = {{ fail2ban_service_jail.backend | default('systemd') }}
journalmatch = {{ fail2ban_service_jail.journalmatch }}
{% else %}
logpath = {{ fail2ban_service_jail.logpath }}
{% endif %}
maxretry = {{ fail2ban_service_jail.maxretry | default(fail2ban_defaults.maxretry) }}
bantime = {{ fail2ban_service_jail.bantime | default(fail2ban_defaults.bantime) }}
findtime = {{ fail2ban_service_jail.findtime | default(fail2ban_defaults.findtime) }}
+60
View File
@@ -0,0 +1,60 @@
# network_interfaces
Renders `/etc/network/interfaces` from a list of manual interfaces and bridges, validates it with `ifreload`, and restores the backup if validation fails. Variables and their types are defined in [`meta/argument_specs.yml`](meta/argument_specs.yml), which is the source of truth.
## Supported platforms
Debian-based hosts using `ifupdown2` (`ifreload`), such as Proxmox hosts. The molecule scenario (`molecule/default/`, CI only) runs on Ubuntu 24.04 without `ifupdown2`: the validate and reload commands are stubs, so it tests the rendered file, the backup, the single reload and the restore after a failing validation. It does not test `ifreload`, so no Debian release or `ifupdown2` version is verified by a test.
## Requirements and run order
- `ifupdown2` must be installed, because the validate and apply commands call `ifreload`.
- Use it by its fully qualified name, `mortis.kamino.network_interfaces`.
- Run it with `serial: 1` and the most important host last, so a bad change is caught on another host first. It rewrites the host's network configuration, so run it before roles that depend on the network.
- Gathered facts are not read. The tasks use `become` where they write.
- `network_interfaces_layout` normally comes from inventory (group_vars or host_vars), so each host can have its own layout.
## Role variables
| Variable | Default | Required | Description |
|---|---|---|---|
| `network_interfaces_layout` | `manual: []`, `bridges: []` | no | `manual` is a list of interface names. `bridges` is a list of mappings with `name`, `method`, `address`, `netmask`, `gateway`, `ports`, `stp`, `fd`, `vlan_aware`, `vlan_ids`. |
| `network_interfaces_file` | `/etc/network/interfaces` | no | File rewritten. |
| `network_interfaces_backup` | `/etc/network/interfaces.bak` | no | Backup path. |
| `network_interfaces_validate_command` | `ifreload -s -a` | no | Validation command. |
| `network_interfaces_apply_command` | `ifreload -a` | no | Reload command, run by the handler. |
The `address` sub-option is typed `raw` in the spec so that an inventory can template it, for example from `ansible_host`.
## Tags
None. The role does not tag its tasks, so only a play-level tag applies.
## Example play
```yaml
- hosts: hypervisors
serial: 1
roles:
- role: mortis.kamino.network_interfaces
vars:
network_interfaces_layout:
manual: [nic0, nic1]
bridges:
- name: vmbr0
method: static
address: 192.0.2.10
netmask: 255.255.255.0
gateway: 192.0.2.1
ports: nic0
vlan_aware: true
```
## Notes
- The template replaces the whole file: any stanza not described by `network_interfaces_layout` is dropped. Interfaces carried by other consumers (for example a bridge that carries a router VM's WAN) must be listed.
- Only a content difference triggers work. Idempotent runs change nothing.
- 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.
- `no_log` is not used: the role handles no secrets.
@@ -0,0 +1,9 @@
---
network_interfaces_layout:
manual: []
bridges: []
network_interfaces_file: /etc/network/interfaces
network_interfaces_backup: /etc/network/interfaces.bak
network_interfaces_validate_command: "ifreload -s -a"
network_interfaces_apply_command: "ifreload -a"
@@ -0,0 +1,5 @@
---
- name: Reload Interfaces
become: true
ansible.builtin.command: "{{ network_interfaces_apply_command }}"
changed_when: true
@@ -0,0 +1,80 @@
---
argument_specs:
main:
short_description: Manage /etc/network/interfaces
description:
- >-
Reads the interfaces file, renders it from C(network_interfaces_layout), and when the content differs backs up the current file, writes the new
one, validates it and reloads. A failed validation restores the backup and fails the play.
- Needs C(ifupdown2), because validation and reload use C(ifreload).
options:
network_interfaces_layout:
type: dict
default: {manual: [], bridges: []}
description:
- >-
Desired network layout. The file is fully replaced with a loopback stanza, one C(iface <name> inet manual) per C(manual) entry and one
stanza per bridge. Both keys are optional when the variable is set.
options:
manual:
type: list
elements: str
description: Interface names configured as C(inet manual), without C(auto).
bridges:
type: list
elements: dict
description: Bridges, rendered in order with C(auto <name>).
options:
name:
type: str
required: true
description: Bridge name, for example C(vmbr0).
method:
type: str
description: Address method. The template default is C(manual). With C(static), C(address) and C(netmask) are read unconditionally.
address:
type: raw
description: >-
IP address, only used when C(method) is C(static). Typed raw so that an inventory can template it, for
example from C(ansible_host).
netmask:
type: str
description: Netmask, only used when C(method) is C(static).
gateway:
type: str
description: Default gateway, only used when C(method) is C(static) and the key is present.
ports:
type: str
description: Value of C(bridge_ports). The template default is C(none).
stp:
type: str
description: Value of C(bridge_stp). The template default is C(off). Quote C("off"), because unquoted YAML turns it into a boolean.
fd:
type: raw
description: Value of C(bridge_fd), written only when C(stp) is not C(off). The template default is 2.
vlan_aware:
type: bool
description: Adds C(bridge_vlan_aware yes) and C(bridge_vids). The template default is false.
vlan_ids:
type: str
description: Value of C(bridge_vids) when C(vlan_aware) is true. The template default is C(2-4094).
network_interfaces_file:
type: path
default: /etc/network/interfaces
description:
- File that is read, compared and rewritten.
network_interfaces_backup:
type: path
default: /etc/network/interfaces.bak
description:
- Where the current file is copied before it is replaced, and restored from when validation fails.
network_interfaces_validate_command:
type: str
default: ifreload -s -a
description:
- Command run after the new file is written, in syntax-check mode. A failure triggers the restore.
network_interfaces_apply_command:
type: str
default: ifreload -a
description:
- Command run by the C(Reload Interfaces) handler, which the role flushes right after validation.
+17
View File
@@ -0,0 +1,17 @@
---
galaxy_info:
role_name: network_interfaces
namespace: mortis
author: Defame1297
license: GPL-3.0-or-later
description: Render /etc/network/interfaces for Proxmox hosts from manual and bridge definitions, validate with ifreload and restore the backup on failure.
min_ansible_version: "2.19"
platforms:
- name: Debian
versions:
- all
galaxy_tags:
- network
- bridge
- proxmox
dependencies: []
@@ -0,0 +1,27 @@
---
# ifupdown2 and its ifreload are not in the image, and a real reload could cut the
# container's own network, so the validate command is `true` and the apply command appends
# to a marker file. The role itself (read, render, compare, back up, write, validate,
# flush handlers) runs unchanged.
- name: Converge the role with a layout of manual interfaces and bridges
hosts: all
gather_facts: false
vars:
network_interfaces_validate_command: /bin/true
network_interfaces_apply_command: '/bin/sh -c "echo reloaded >> /var/tmp/network-interfaces-reload.log"'
network_interfaces_layout:
manual: [eno1]
bridges:
- name: vmbr0
method: static
address: 10.0.0.2
netmask: 255.255.255.0
gateway: 10.0.0.1
ports: eno1
stp: "off"
vlan_aware: true
- name: vmbr1
stp: "on"
fd: 5
roles:
- role: mortis.kamino.network_interfaces
@@ -0,0 +1,26 @@
---
# Runs on the repository's own runner (label kamino-molecule), in the molecule-ubuntu2404 image
# (MOLECULE_IMAGE, the pin in .gitea/workflows/molecule.yml). No privileged mode: systemd needs a
# writable cgroup and the firewall tools need NET_ADMIN, nothing else.
driver:
name: docker
platforms:
- name: network-interfaces-instance
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
capabilities:
- NET_ADMIN
security_opts:
- apparmor=unconfined
provisioner:
name: ansible
verifier:
name: ansible
@@ -0,0 +1,29 @@
---
# The role slurps the interfaces file before it compares, so the file must exist, and the
# image has no /etc/network. Both files get a legacy body that differs from anything the
# template renders, so the converge has a change to make and a backup to take.
- name: Prepare
hosts: all
gather_facts: false
tasks:
- name: Create /etc/network
ansible.builtin.file:
path: /etc/network
state: directory
owner: root
group: root
mode: "0755"
- name: Seed the interfaces files with a legacy body
ansible.builtin.copy:
dest: "{{ item }}"
content: |
# legacy seed
auto lo
iface lo inet loopback
owner: root
group: root
mode: "0644"
loop:
- /etc/network/interfaces
- /etc/network/interfaces.rollback
@@ -0,0 +1,102 @@
---
# The rendered file, the backup of the legacy body and the single reload. The last play is the
# role's lock-out protection: a failing validation must put the previous file back. It
# changes the container, so it lives here and not in converge.yml, where the idempotence
# run would see it change twice. It works on its own copy of the file.
- name: Verify the converged layout
hosts: all
gather_facts: false
tasks:
- name: Read the interfaces file, its backup and the reload marker
ansible.builtin.slurp:
src: "{{ item }}"
loop:
- /etc/network/interfaces
- /etc/network/interfaces.bak
- /var/tmp/network-interfaces-reload.log
register: network_interfaces_verify_files
- name: The file holds the loopback, the manual interface and both bridges
ansible.builtin.assert:
that:
- lines is contains('iface lo inet loopback')
- lines is contains('iface eno1 inet manual')
- lines is contains('auto vmbr0')
- lines is contains('iface vmbr0 inet static')
- lines is contains(' address 10.0.0.2')
- lines is contains(' netmask 255.255.255.0')
- lines is contains(' gateway 10.0.0.1')
- lines is contains(' bridge_ports eno1')
- lines is contains(' bridge_stp off')
- lines is contains(' bridge_vlan_aware yes')
- lines is contains(' bridge_vids 2-4094')
- lines is contains('auto vmbr1')
- lines is contains('iface vmbr1 inet manual')
- lines is contains(' bridge_ports none')
- lines is contains(' bridge_stp on')
- lines is contains(' bridge_fd 5')
- lines | select('search', 'bridge_fd') | list | length == 1
- lines | select('search', 'bridge_vlan_aware') | list | length == 1
- "'legacy seed' not in content"
quiet: true
vars:
content: "{{ network_interfaces_verify_files.results[0].content | b64decode }}"
lines: "{{ content.split('\n') }}"
- name: The backup is the legacy body and the reload ran once
ansible.builtin.assert:
that:
- "'# legacy seed' in (network_interfaces_verify_files.results[1].content | b64decode)"
- "'vmbr0' not in (network_interfaces_verify_files.results[1].content | b64decode)"
- (network_interfaces_verify_files.results[2].content | b64decode).split('\n') | select | list | length == 1
quiet: true
- name: A failing validation restores the previous file
hosts: all
gather_facts: false
vars:
network_interfaces_file: /etc/network/interfaces.rollback
network_interfaces_backup: /etc/network/interfaces.rollback.bak
network_interfaces_validate_command: /bin/false
# A handler notified by the write is still pending when the block is rescued, and it
# runs at the end of the play, so it must not touch the reload marker.
network_interfaces_apply_command: /bin/true
network_interfaces_layout:
manual: [eno1]
bridges:
- name: vmbr9
tasks:
- name: Read the file before
ansible.builtin.slurp:
src: /etc/network/interfaces.rollback
register: network_interfaces_verify_before
- name: Apply the role with a validation that fails
block:
- name: Include the role
ansible.builtin.include_role:
name: mortis.kamino.network_interfaces
- name: Fail when the invalid configuration was accepted
ansible.builtin.fail:
msg: MOLECULE-ACCEPTED
rescue:
- name: The role reverted and refused
ansible.builtin.assert:
that: "'Previous config restored' in ansible_failed_result.msg | default('')"
quiet: true
- name: Read the file and the backup after
ansible.builtin.slurp:
src: "{{ item }}"
loop:
- /etc/network/interfaces.rollback
- /etc/network/interfaces.rollback.bak
register: network_interfaces_verify_after
- name: The previous file is back and the bad one is gone
ansible.builtin.assert:
that:
- network_interfaces_verify_after.results[0].content == network_interfaces_verify_before.content
- network_interfaces_verify_after.results[1].content == network_interfaces_verify_before.content
- "'vmbr9' not in (network_interfaces_verify_after.results[0].content | b64decode)"
quiet: true
+33
View File
@@ -0,0 +1,33 @@
---
- name: Apply network configuration safely
become: true
when: network_interfaces_changed
block:
- name: Backup current interfaces file
ansible.builtin.copy:
src: "{{ network_interfaces_file }}"
dest: "{{ network_interfaces_backup }}"
remote_src: true
owner: root
group: root
mode: "0644"
- name: Write new interfaces configuration
ansible.builtin.copy:
content: "{{ network_interfaces_rendered }}"
dest: "{{ network_interfaces_file }}"
owner: root
group: root
mode: "0644"
notify: Reload Interfaces
- name: Validate network configuration
ansible.builtin.command: "{{ network_interfaces_validate_command }}"
changed_when: false
- name: Trigger network reload
ansible.builtin.meta: flush_handlers
rescue:
- name: Revert interfaces
ansible.builtin.import_tasks: revert.yml
+9
View File
@@ -0,0 +1,9 @@
---
- name: Read current network configuration
ansible.builtin.import_tasks: read.yml
- name: Render desired network configuration
ansible.builtin.import_tasks: render.yml
- name: Apply network configuration if changed
ansible.builtin.import_tasks: apply.yml
+5
View File
@@ -0,0 +1,5 @@
---
- name: Read current interfaces config
ansible.builtin.slurp:
src: "{{ network_interfaces_file }}"
register: network_interfaces_current
@@ -0,0 +1,9 @@
---
- name: Render interfaces template
ansible.builtin.set_fact:
network_interfaces_rendered: "{{ lookup('template', 'interfaces.j2') }}"
- name: Detect interface configuration changes
ansible.builtin.set_fact:
network_interfaces_changed: >-
{{ network_interfaces_rendered != (network_interfaces_current.content | b64decode) }}
+13
View File
@@ -0,0 +1,13 @@
---
- name: Restore previous interfaces configuration
ansible.builtin.copy:
src: "{{ network_interfaces_backup }}"
dest: "{{ network_interfaces_file }}"
remote_src: true
owner: root
group: root
mode: "0644"
- name: Abort due to invalid network configuration
ansible.builtin.fail:
msg: "Invalid network configuration detected. Previous config restored."
@@ -0,0 +1,36 @@
# Managed by Ansible – DO NOT EDIT
# Loopback
auto lo
iface lo inet loopback
# Manual interfaces
{% for iface in network_interfaces_layout.manual | default([]) %}
iface {{ iface }} inet manual
{% endfor %}
# Bridges
{% for br in network_interfaces_layout.bridges | default([]) %}
auto {{ br.name }}
iface {{ br.name }} inet {{ br.method | default('manual') }}
{% if br.method | default('manual') == 'static' %}
address {{ br.address }}
netmask {{ br.netmask }}
{% if br.gateway is defined %}
gateway {{ br.gateway }}
{% endif %}
{% endif %}
{% if br.ports is defined %}
bridge_ports {{ br.ports }}
{% else %}
bridge_ports none
{% endif %}
bridge_stp {{ br.stp | default('off') }}
{% if br.stp | default('off') != 'off' %}
bridge_fd {{ br.fd | default(2) }}
{% endif %}
{% if br.vlan_aware | default(false) %}
bridge_vlan_aware yes
bridge_vids {{ br.vlan_ids | default('2-4094') }}
{% endif %}
{% endfor %}
+56
View File
@@ -0,0 +1,56 @@
# systemd_hardening
Disables and masks risky services, writes a systemd manager hardening drop-in and renders opt-in per-service sandboxing drop-ins. Variables and their types are defined in [`meta/argument_specs.yml`](meta/argument_specs.yml), which is the source of truth.
## Supported platforms
Hosts with systemd and `systemctl list-unit-files`: Ubuntu 24.04 (noble) LXCs, Ubuntu 22.04 (jammy) VMs and Debian 13 (trixie) Proxmox hosts. The role is applied to the three system types in `systemd_hardening_profiles`: `pve` (Proxmox hosts), `ubuntu_lxc` and `ubuntu_vm`. The molecule scenario (`molecule/default/`, CI only) runs the `ubuntu_lxc` profile on Ubuntu 24.04 against stub unit files, because the test image installs none of the services the role disables or masks. It checks the disable and mask results, the manager and service drop-ins (loaded by systemd after the reload) and the refusals; it cannot show that a real `rpcbind` or similar stops. The `pve` and `ubuntu_vm` profiles and Ubuntu 22.04 and Debian 13 are not verified by a test.
## Requirements and run order
- `systemd_hardening_system_type` is required and has no default (the role does not read a global such as `system_type`; map it in the inventory). The role fails if it is undefined or not a key of `systemd_hardening_profiles`.
- Use it by its fully qualified name, `mortis.kamino.systemd_hardening`.
- Run it after your baseline role and before the roles that manage firewalls and jails.
- Needs privilege escalation: tasks use `become`.
## Role variables
Two variables below, `systemd_hardening_disable_services_extra` and `systemd_hardening_disable_services_effective`, are deliberately not in the spec: their defaults index the profile by `systemd_hardening_system_type`, and the spec is templated before the role's assert runs, so an invalid `systemd_hardening_system_type` would otherwise fail with a templating error instead of the role's own message.
| Variable | Default | Required | Description |
|---|---|---|---|
| `systemd_hardening_system_type` | none | yes | Profile key. Every play that includes the role sets it. |
| `systemd_hardening_profiles` | `pve`, `ubuntu_lxc`, `ubuntu_vm` profiles | no | Per type `disable_services_extra`. Overriding replaces all profiles. |
| `systemd_hardening_disable_services` | `rpcbind`, `avahi-daemon`, `cups`, `bluetooth`, `nfs-server` | no | Disabled on every type. |
| `systemd_hardening_disable_services_extra` | profile entry for `systemd_hardening_system_type` | no | Added to the list above. |
| `systemd_hardening_disable_services_effective` | base plus extra | no | Result, do not set. |
| `systemd_hardening_mask_services` | `telnet`, `rsh`, `rlogin`, `xinetd` | no | Masked. |
| `systemd_hardening_services` | `{}` | no | Unit to directive map for drop-ins. |
## Tags
Only `always` (the `systemd_hardening_system_type` assert) works as intended. `disable`, `mask`, `harden-manager` and `dropins` sit on the `include_tasks` lines in `tasks/main.yml`, and tags on a dynamic include select only the include itself: the included tasks are untagged, so they are skipped. `--tags disable` or `--tags mask` therefore runs only the assert and the unit listing, and `--tags harden-manager` or `--tags dropins` runs only the assert. Do not use these tags for selective runs; run the role untagged.
## Example play
```yaml
- name: Harden LXC services
hosts: lxc_guests
vars:
systemd_hardening_system_type: ubuntu_lxc
roles:
- role: mortis.kamino.systemd_hardening
vars:
systemd_hardening_services:
myservice:
ProtectSystem: strict
NoNewPrivileges: true
```
## Notes
- Only units that appear in `systemctl list-unit-files --type=service` are disabled or masked, with or without the `.service` suffix.
- The manager drop-in (`DefaultLimitNOFILE`, `DefaultLimitNPROC`, `DefaultLimitCORE`, and task, memory and CPU accounting) is written verbatim by `tasks/harden_manager.yml` and has no variable.
- Drop-in and manager changes notify `systemd reload`, which runs `daemon-reload`. Handlers are flushed at the end of the role.
- 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.
+53
View File
@@ -0,0 +1,53 @@
---
# Per-systemd_hardening_system_type policy. Overridable from group_vars/host_vars: set
# systemd_hardening_disable_services_extra (replaces the list for every type in that scope), or
# override systemd_hardening_profiles (replaces ALL profiles, so copy the ones you
# keep). Not in vars/ or include_vars: both outrank group_vars and host_vars.
systemd_hardening_profiles:
pve:
disable_services_extra: []
ubuntu_lxc:
# Not present or not meaningful in an LXC
disable_services_extra:
- systemd-journal-remote
ubuntu_vm:
disable_services_extra:
- multipathd
# Default services to disable globally
systemd_hardening_disable_services:
- rpcbind
- avahi-daemon
- cups
- bluetooth
- nfs-server
# Added to the list above for this systemd_hardening_system_type. Lazy (read at use), no set_fact,
# so a group_vars override of the flat name wins.
systemd_hardening_disable_services_extra: "{{ systemd_hardening_profiles[systemd_hardening_system_type].disable_services_extra }}"
# What the role actually disables: base + extra. Read-only result, do not set.
systemd_hardening_disable_services_effective: "{{ systemd_hardening_disable_services + systemd_hardening_disable_services_extra }}"
# High-risk services to mask completely (security policy)
systemd_hardening_mask_services:
- telnet
- rsh
- rlogin
- xinetd
# Per-service hardening overrides (opt-in)
# Map of <unit name without .service> -> {Directive: value}. Values render as:
# booleans -> yes/no, lists -> space-joined, everything else as-is.
# Example:
# systemd_hardening_services:
# myservice:
# ProtectSystem: "strict"
# NoNewPrivileges: true
#
# Do NOT add ssh/sshd here. Sandboxing directives on sshd.service
# (ProtectSystem, PrivateTmp, NoNewPrivileges, ...) are inherited by every
# SSH login session and everything spawned from it, including sudo. That
# makes admin and Ansible sessions see a read-only filesystem / private /tmp
# and can break privilege escalation. Harden sshd via the sshd role instead.
systemd_hardening_services: {}
@@ -0,0 +1,6 @@
---
- name: Reload systemd daemon
become: true
ansible.builtin.systemd:
daemon_reload: true
listen: "systemd reload"
@@ -0,0 +1,53 @@
---
argument_specs:
main:
short_description: Harden systemd for a system type
description:
- >-
Validates C(systemd_hardening_system_type) against C(systemd_hardening_profiles), then disables the unwanted services and masks the high-risk
services that have an installed unit file, writes C(/etc/systemd/system.conf.d/hardening.conf) and renders a drop-in for every
unit in C(systemd_hardening_services).
- Units that are not installed are skipped. Handlers are flushed at the end of the role.
- >-
The role also reads C(systemd_hardening_disable_services_extra) (default is the profile entry for C(systemd_hardening_system_type)) and the
derived C(systemd_hardening_disable_services_effective) (the base list plus the extra list, a result, do not set it). They are
deliberately not listed as options because their defaults index C(systemd_hardening_profiles[systemd_hardening_system_type]) and would fail
argument validation on an invalid C(systemd_hardening_system_type), ahead of the role's own assert. Overriding the extra list replaces it for
every system type in that scope.
options:
systemd_hardening_system_type:
type: str
required: true
description:
- >-
Selects the entry in C(systemd_hardening_profiles). The role default of C(systemd_hardening_disable_services_extra) reads it, and
tasks/main.yml asserts that it is a key of C(systemd_hardening_profiles) (C(pve), C(ubuntu_lxc) or C(ubuntu_vm) by default).
- Not restricted by C(choices) so that the assert keeps its own message.
systemd_hardening_profiles:
type: dict
description:
- >-
Per system type policy. Each profile holds C(disable_services_extra), a list of unit names. The role default has C(pve) (empty),
C(ubuntu_lxc) (C(systemd-journal-remote)) and C(ubuntu_vm) (C(multipathd)).
- Overriding it replaces all profiles, so copy the ones you keep.
systemd_hardening_disable_services:
type: list
elements: str
default: [rpcbind, avahi-daemon, cups, bluetooth, nfs-server]
description:
- Services stopped and disabled on every system type, with or without the C(.service) suffix. Only installed units are touched.
systemd_hardening_mask_services:
type: list
elements: str
default: [telnet, rsh, rlogin, xinetd]
description:
- Services masked and stopped. Only installed units are touched.
systemd_hardening_services:
type: dict
default: {}
description:
- >-
Opt-in drop-ins, a mapping of unit name without C(.service) to a mapping of directive to value. Written to
C(/etc/systemd/system/<unit>.service.d/hardening.conf). Booleans render as yes or no, lists are space-joined, anything else as is.
- Each value must itself be a mapping, otherwise the role fails before writing anything.
- Do not add C(ssh) or C(sshd). Sandboxing directives on sshd.service are inherited by every login session, including sudo.
+21
View File
@@ -0,0 +1,21 @@
---
galaxy_info:
role_name: systemd_hardening
namespace: mortis
author: Defame1297
license: GPL-3.0-or-later
description: Disable and mask risky services per system type, harden the systemd manager and apply opt-in per-service sandboxing drop-ins.
min_ansible_version: "2.19"
platforms:
- name: Ubuntu
versions:
- jammy
- noble
- name: Debian
versions:
- trixie
galaxy_tags:
- systemd
- hardening
- security
dependencies: []
@@ -0,0 +1,102 @@
---
# The production LXC profile with one opt-in drop-in. The stub units come from prepare.yml.
- name: Converge the role with a valid profile
hosts: all
vars:
systemd_hardening_system_type: ubuntu_lxc
systemd_hardening_services:
testsvc:
ProtectSystem: strict
NoNewPrivileges: true
ReadWritePaths: [/var/tmp, /run]
LimitNOFILE: 1024
roles:
- role: mortis.kamino.systemd_hardening
# The plays below are refusals. The missing and unknown system types stop before the role
# changes anything. The malformed drop-in plays fail at dropins.yml, after the disable, mask
# and manager drop-in tasks ran, but those are no-ops after the converge above, 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 run without systemd_hardening_system_type is refused
hosts: all
gather_facts: false
tasks:
- name: Apply the role without a system type
block:
- name: Include the role
ansible.builtin.include_role:
name: mortis.kamino.systemd_hardening
- name: Fail when the missing type was accepted
ansible.builtin.fail:
msg: MOLECULE-ACCEPTED
rescue:
- name: The role refused the run
ansible.builtin.assert:
that: "'missing required arguments' in ansible_failed_result.msg | default('')"
quiet: true
- name: An unknown system type is refused
hosts: all
gather_facts: false
vars:
systemd_hardening_system_type: not_a_type
tasks:
- name: Apply the role with an unknown type
block:
- name: Include the role
ansible.builtin.include_role:
name: mortis.kamino.systemd_hardening
- name: Fail when the unknown type was accepted
ansible.builtin.fail:
msg: MOLECULE-ACCEPTED
rescue:
- name: The profile check stopped the play
ansible.builtin.assert:
that: "'is invalid' in ansible_failed_result.msg | default('')"
quiet: true
- name: A drop-in entry that is not a mapping is refused
hosts: all
gather_facts: false
vars:
systemd_hardening_system_type: ubuntu_lxc
systemd_hardening_services:
testsvc: not-a-mapping
tasks:
- name: Apply the role with a malformed drop-in
block:
- name: Include the role
ansible.builtin.include_role:
name: mortis.kamino.systemd_hardening
- name: Fail when the malformed drop-in was accepted
ansible.builtin.fail:
msg: MOLECULE-ACCEPTED
rescue:
- name: The drop-in validation stopped the play
ansible.builtin.assert:
that: "'must be a mapping' in ansible_failed_result.msg | default('')"
quiet: true
- name: A drop-in list that is not a mapping is refused
hosts: all
gather_facts: false
vars:
systemd_hardening_system_type: ubuntu_lxc
systemd_hardening_services: [testsvc]
tasks:
- name: Apply the role with a list instead of a mapping
block:
- name: Include the role
ansible.builtin.include_role:
name: mortis.kamino.systemd_hardening
- name: Fail when the list was accepted
ansible.builtin.fail:
msg: MOLECULE-ACCEPTED
rescue:
- name: The role refused the run
ansible.builtin.assert:
that:
- "'MOLECULE-ACCEPTED' not in ansible_failed_result.msg | default('')"
- "'systemd_hardening_services' in ansible_failed_result.msg | default('')"
quiet: true
@@ -0,0 +1,26 @@
---
# Runs on the repository's own runner (label kamino-molecule), in the molecule-ubuntu2404 image
# (MOLECULE_IMAGE, the pin in .gitea/workflows/molecule.yml). No privileged mode: systemd needs a
# writable cgroup and the firewall tools need NET_ADMIN, nothing else.
driver:
name: docker
platforms:
- name: systemd-hardening-instance
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
capabilities:
- NET_ADMIN
security_opts:
- apparmor=unconfined
provisioner:
name: ansible
verifier:
name: ansible
@@ -0,0 +1,31 @@
---
# The image installs none of the services the role touches, so the units it acts on are
# stubs in /usr/lib/systemd/system (not /etc: `systemctl mask` refuses to replace a regular
# file there). Nothing is started. rpcbind is enabled so the role has something to
# disable; telnet only needs to exist; testsvc receives the drop-in.
- name: Prepare
hosts: all
gather_facts: false
tasks:
- name: Install the stub unit files
ansible.builtin.copy:
dest: "/usr/lib/systemd/system/{{ item }}.service"
content: |
[Unit]
Description=molecule stub for {{ item }}
[Service]
ExecStart=/bin/sleep 3600
[Install]
WantedBy=multi-user.target
owner: root
group: root
mode: "0644"
loop: [rpcbind, telnet, testsvc]
- name: Enable rpcbind and reload systemd
ansible.builtin.systemd:
name: rpcbind
enabled: true
daemon_reload: true
@@ -0,0 +1,65 @@
---
# What the role is for: the installed risky units are disabled or masked, the manager
# drop-in is in place, and the opt-in drop-in renders and is loaded by systemd. The
# directives restate the converge vars, not the role's whole policy.
- name: Verify
hosts: all
gather_facts: false
tasks:
- name: Ask systemd about the stub units
ansible.builtin.systemd:
name: "{{ item }}.service"
loop: [rpcbind, telnet]
register: systemd_hardening_verify_units
check_mode: true
- name: The disabled unit is disabled and the masked unit is masked
ansible.builtin.assert:
that:
- systemd_hardening_verify_units.results[0].status.UnitFileState == "disabled"
- systemd_hardening_verify_units.results[1].status.UnitFileState == "masked"
quiet: true
- name: Read the manager drop-in
ansible.builtin.slurp:
src: /etc/systemd/system.conf.d/hardening.conf
register: systemd_hardening_verify_manager
- name: The manager drop-in holds the limits
ansible.builtin.assert:
that:
- (systemd_hardening_verify_manager.content | b64decode).split('\n') is contains('[Manager]')
- (systemd_hardening_verify_manager.content | b64decode).split('\n') is contains('DefaultLimitNOFILE=65535')
- (systemd_hardening_verify_manager.content | b64decode).split('\n') is contains('DefaultLimitCORE=0')
quiet: true
- name: Read the service drop-in
ansible.builtin.slurp:
src: /etc/systemd/system/testsvc.service.d/hardening.conf
register: systemd_hardening_verify_dropin
- name: The drop-in renders booleans, lists and plain values
ansible.builtin.assert:
that:
- (systemd_hardening_verify_dropin.content | b64decode).split('\n') | select | list == systemd_hardening_verify_expected
quiet: true
vars:
systemd_hardening_verify_expected:
- "[Service]"
- ProtectSystem=strict
- NoNewPrivileges=yes
- ReadWritePaths=/var/tmp /run
- LimitNOFILE=1024
- name: Ask systemd about the drop-in service
ansible.builtin.systemd:
name: testsvc.service
register: systemd_hardening_verify_testsvc
check_mode: true
- name: The daemon reload made systemd load the drop-in
ansible.builtin.assert:
that:
- systemd_hardening_verify_testsvc.status.NoNewPrivileges == "yes"
- systemd_hardening_verify_testsvc.status.ProtectSystem == "strict"
quiet: true
@@ -0,0 +1,11 @@
---
- name: Disable unwanted services if present
become: true
ansible.builtin.systemd:
name: "{{ item }}"
enabled: false
state: stopped
loop: "{{ systemd_hardening_disable_services_effective }}"
# Only act on installed units; items may be given with or without the
# ".service" suffix.
when: (item | regex_replace('\.service$', '') ~ '.service') in systemd_hardening_installed_units
+41
View File
@@ -0,0 +1,41 @@
---
- name: Apply hardening drop-ins to opted-in services
vars:
# default(..., true) also covers an explicitly empty/null override
systemd_hardening_dropin_map: "{{ systemd_hardening_services | default({}, true) }}"
block:
- name: Validate systemd_hardening_services
ansible.builtin.assert:
that:
- systemd_hardening_dropin_map is mapping
- systemd_hardening_dropin_map.values() | reject('mapping') | list | length == 0
fail_msg: >-
systemd_hardening_services must be a mapping of unit -> mapping of
directives.
quiet: true
- name: Create drop-in directory for service
become: true
ansible.builtin.file:
path: "/etc/systemd/system/{{ systemd_hardening_item.key }}.service.d"
state: directory
owner: root
group: root
mode: "0755"
loop: "{{ systemd_hardening_dropin_map | dict2items }}"
loop_control:
loop_var: systemd_hardening_item
notify: "systemd reload"
- name: Create drop-in configuration
become: true
ansible.builtin.template:
src: dropin.j2
dest: "/etc/systemd/system/{{ systemd_hardening_item.key }}.service.d/hardening.conf"
owner: root
group: root
mode: "0644"
loop: "{{ systemd_hardening_dropin_map | dict2items }}"
loop_control:
loop_var: systemd_hardening_item
notify: "systemd reload"
@@ -0,0 +1,26 @@
---
- name: Ensure system.conf.d directory exists
become: true
ansible.builtin.file:
path: /etc/systemd/system.conf.d
state: directory
owner: root
group: root
mode: "0755"
- name: Harden systemd manager (global settings)
become: true
ansible.builtin.copy:
dest: /etc/systemd/system.conf.d/hardening.conf
content: |
[Manager]
DefaultLimitNOFILE=65535
DefaultLimitNPROC=16384
DefaultLimitCORE=0
DefaultTasksAccounting=yes
DefaultMemoryAccounting=yes
DefaultCPUAccounting=yes
owner: root
group: root
mode: "0644"
notify: "systemd reload"
+57
View File
@@ -0,0 +1,57 @@
---
# Required input with no default: the role does not read a global such as system_type;
# the inventory maps it onto systemd_hardening_system_type.
- name: Require systemd_hardening_system_type
ansible.builtin.assert:
that:
- systemd_hardening_system_type is defined
fail_msg: >-
systemd_hardening_system_type is required and has no default. Set it in
the play or the inventory.
tags: always
- name: Validate systemd_hardening_system_type variable
ansible.builtin.assert:
that:
- systemd_hardening_system_type in systemd_hardening_profiles
fail_msg: >-
systemd_hardening_system_type '{{ systemd_hardening_system_type }}' is invalid.
Must be one of: {{ systemd_hardening_profiles.keys() | list | join(', ') }}.
success_msg: "systemd_hardening_system_type '{{ systemd_hardening_system_type }}' is valid."
tags: always
# Not service_facts: it returns a fact named `services`, which (with
# inject_facts_as_vars) overrides the host_vars `services` list used by
# playbooks/install_services.yml. Only installed unit files are listed, so
# units that are merely referenced (LoadState not-found) are excluded.
- name: List installed service unit files # noqa: command-instead-of-module
become: true
ansible.builtin.command: systemctl list-unit-files --type=service --no-legend --plain
register: systemd_hardening_unit_files
changed_when: false
check_mode: false
tags: [disable, mask]
- name: Set installed service units
ansible.builtin.set_fact:
systemd_hardening_installed_units: "{{ systemd_hardening_unit_files.stdout_lines | map('split') | map('first') | list }}"
tags: [disable, mask]
- name: Disable unwanted services
ansible.builtin.include_tasks: disable_services.yml
tags: disable
- name: Mask high-risk services
ansible.builtin.include_tasks: mask_services.yml
tags: mask
- name: Harden systemd manager globally
ansible.builtin.include_tasks: harden_manager.yml
tags: harden-manager
- name: Apply per-service drop-ins
ansible.builtin.include_tasks: dropins.yml
tags: dropins
- name: Flush handlers early
ansible.builtin.meta: flush_handlers
@@ -0,0 +1,10 @@
---
- name: Mask high-risk services
become: true
ansible.builtin.systemd:
name: "{{ item }}"
masked: true
state: stopped
loop: "{{ systemd_hardening_mask_services }}"
# A unit that isn't installed can't be started, so masking it is unnecessary.
when: (item | regex_replace('\.service$', '') ~ '.service') in systemd_hardening_installed_units
@@ -0,0 +1,19 @@
[Service]
{#
Rendering rules (checked in this order):
- booleans -> yes/no
- real lists -> space-joined (strings are Jinja sequences too, so
they must be excluded explicitly, otherwise
"strict" renders as "s t r i c t")
- strings/numbers/etc -> rendered as-is
systemd_hardening_item.value is validated as a mapping in tasks/dropins.yml before rendering.
#}
{% for k, v in systemd_hardening_item.value.items() %}
{% if v is boolean %}
{{ k }}={{ 'yes' if v else 'no' }}
{% elif v is iterable and v is not string and v is not mapping %}
{{ k }}={{ v | join(' ') }}
{% else %}
{{ k }}={{ v }}
{% endif %}
{% endfor %}
+2 -1
View File
@@ -1,6 +1,7 @@
# SPDX-FileCopyrightText: Defame1297 and contributors
# SPDX-License-Identifier: GPL-3.0-or-later
"""Bump the PATCH version of every image whose inputs changed (ADR 0004, Image distribution).
"""Bump the PATCH version of every image whose inputs changed (ADR 0004, Image distribution, in the
maintainer's environment repository).
python3 scripts/bump_image_versions.py [<base-ref>] (default: origin/main)
+3 -3
View File
@@ -11,7 +11,7 @@ When <head-ref> starts with `renovate/`, the diff of <base-ref>...HEAD may only
* images/<name>/Dockerfile: the tag and digest of FROM lines (the image name stays), and
the `uv==<version>` token of a line that holds one;
* .gitea/workflows/image.yml: the matrix `version:` lines, and the tag and digest of the
job container's `image: ubuntu:...@sha256:...` line (the name stays);
job containers' `job_image: ubuntu:...@sha256:...` lines (the name stays);
* .gitea/workflows/{lint,build,molecule}.yml: the version and digest of a
`git.rkdr.net/mortis/<name>:<version>@sha256:<digest>` pin (the name stays), including
the MOLECULE_IMAGE value.
@@ -51,7 +51,7 @@ VERSION_LINE = re.compile(
r"""^\s*(?:-\s*)?version:\s*["']?(?P<v>[0-9]+\.[0-9]+\.[0-9]+(?:-[0-9A-Za-z.-]+)?)["']?\s*(?:#.*)?$""")
FROM_LINE = re.compile(rf"^(FROM\s+(?:--\S+\s+)*)([^\s:@]+)(?::{TAG})?@sha256:[0-9a-f]{{64}}(\s+AS\s+\S+)?\s*$")
UV_TOKEN = re.compile(r"\buv==[0-9][0-9A-Za-z.+!_-]*")
UBUNTU_LINE = re.compile(rf"^(\s*image:\s*ubuntu)(?::{TAG})?@sha256:[0-9a-f]{{64}}\s*$")
UBUNTU_LINE = re.compile(rf"^(\s*job_image:\s*ubuntu)(?::{TAG})?@sha256:[0-9a-f]{{64}}\s*$")
DOCKERFILE = re.compile(r"images/[^/]+/Dockerfile")
CONSUMERS = {".gitea/workflows/lint.yml", ".gitea/workflows/build.yml", ".gitea/workflows/molecule.yml"}
@@ -117,7 +117,7 @@ def file_problem(path, removed, added):
if DOCKERFILE.fullmatch(path):
return same_shape(removed, added, reduce_dockerfile, "the tag or digest of a FROM line or a `uv==` pin")
if path == civ.MATRIX_FILE:
return same_shape(removed, added, reduce_image_yml, "a matrix `version:` or the ubuntu job container pin")
return same_shape(removed, added, reduce_image_yml, "a matrix `version:` or a `job_image:` ubuntu pin")
if path in CONSUMERS:
return same_shape(removed, added, reduce_pin, "an image pin of the mortis registry")
return "is not a file a bot pull request may change"
+161 -6
View File
@@ -1,12 +1,13 @@
# SPDX-FileCopyrightText: Defame1297 and contributors
# SPDX-License-Identifier: GPL-3.0-or-later
"""Keep image versions and image pins honest (ADR 0004, Image distribution).
"""Keep image versions and image pins honest (ADR 0004, Image distribution, in the
maintainer's environment repository).
python3 scripts/check_image_versions.py pins
python3 scripts/check_image_versions.py bump <base-ref>
The matrix of .gitea/workflows/image.yml is the registry of images: name, version,
build context (subpath) and Dockerfile. A published version tag is never moved (Gitea
build context (subpath), Dockerfile and job container (job_image). A published version tag is never moved (Gitea
cannot make a tag immutable), so an image whose content changes under an unchanged
version is pushed as sha-*/latest only, and a hand-pasted <version>@<new digest> pin
would pair a tag with a digest it does not point to.
@@ -18,6 +19,11 @@ pins No file under .gitea/workflows may mention `git.rkdr.net/defame1297/`: the
workflows must name an image of the matrix, with a well-formed digest and a
version that is not newer than the matrix (a pin lags the matrix between the PR
that bumps the version and the PR that moves the pin; it can never lead it).
Every matrix entry names its job container (`job_image: ubuntu:<release>@sha256:...`), and
that release must equal the release of the `FROM ubuntu:` lines of its Dockerfile: kaniko
runs inside the job container and unpacks the image over it.
Every image's Dockerfile carries the labels its registry page shows (REQUIRED_LABELS) and
links to docs/images/<name>.md, which must exist.
Offline: whether the tag points at the digest is a registry fact, see the
"unverified" note in the PR description.
bump Fails when the diff <base-ref>...HEAD touches an input of an image without a
@@ -48,6 +54,7 @@ import fnmatch
import json
import pathlib
import re
import shlex
import subprocess
import sys
@@ -116,11 +123,11 @@ def _scalar(raw, where):
def matrix_of(text):
"""Return {name: {version, subpath, dockerfile}} from the text of image.yml.
"""Return {name: {version, subpath, dockerfile[, job_image]}} from the text of image.yml.
A purpose-built block-style reader, not a YAML parser: the Renovate image has no PyYAML
and the bump step runs there. It reads the single `include:` list and its entries'
`name`, `version`, `subpath` and `dockerfile`, and fails closed (one-line error) on
`name`, `version`, `subpath`, `dockerfile` and `job_image`, and fails closed (one-line error) on
any other shape, so a file it cannot read is never half-understood."""
lines = text.splitlines()
heads = [n for n, line in enumerate(lines) if _INCLUDE_RE.match(line)]
@@ -172,7 +179,7 @@ def matrix_of(text):
raise CheckError(f"a matrix entry of {MATRIX_FILE} lacks the key '{required}' "
"(name, version and dockerfile are required)")
values = {k: _scalar(v[0], f"{MATRIX_FILE} line {v[1]}") for k, v in keys.items()
if k in ("name", "version", "dockerfile", "subpath")}
if k in ("name", "version", "dockerfile", "subpath", "job_image")}
name = values["name"]
if not name or (keys["name"][0].strip()[:1] not in "\"'" and _NUMBER_RE.match(name)):
raise CheckError(f"{MATRIX_FILE}: matrix.include entry {n}: name must be a non-empty string")
@@ -186,6 +193,11 @@ def matrix_of(text):
f"(quote it in the YAML), got {values[key]!r}")
matrix[name] = {"version": values["version"], "subpath": values.get("subpath", ""),
"dockerfile": values["dockerfile"]}
if "job_image" in values:
if (keys["job_image"][0] or "").strip()[:1] in "\"'":
raise CheckError(f"{MATRIX_FILE}: image '{name}': job_image must be written unquoted "
"(the bot-diff guard and Renovate read the plain form)")
matrix[name]["job_image"] = values["job_image"]
return matrix
@@ -311,6 +323,146 @@ def check_pins(matrix, consumer_texts):
return errors
JOB_IMAGE_RE = re.compile(r"ubuntu:(?P<release>[0-9]+\.[0-9]+)@sha256:[0-9a-f]{64}")
CONTAINER_LINE_RE = re.compile(r"^\s*container:[ \t]*\n\s*image:\s*\$\{\{\s*matrix\.job_image\s*\}\}[ \t]*$", re.MULTILINE)
UBUNTU_NAMES = ("ubuntu", "library/ubuntu", "docker.io/library/ubuntu")
def dockerfile_releases(dockerfile_text):
"""(releases, problems) of a Dockerfile's FROM lines: the `ubuntu:<release>` tag of each external
base, and a message for every FROM this check cannot vouch for. kaniko unpacks every stage over
the job container, so a base that is not Ubuntu, or whose name or tag holds a variable, is a problem.
A reference to an earlier stage (`FROM os AS final`) is skipped."""
releases, problems, stages = [], [], set()
for lineno, line in _instructions(dockerfile_text):
parts = line.split()
if not parts or parts[0].upper() != "FROM":
continue
refs = [p for p in parts[1:] if not p.startswith("--")]
if not refs:
continue
ref = refs[0]
if len(refs) >= 3 and refs[1].upper() == "AS":
alias = refs[2].lower()
else:
alias = None
if ref.lower() in stages:
pass
elif "$" in ref:
problems.append(f"line {lineno}: FROM {ref} holds a variable, so its release cannot be read")
else:
name, unused, tag = ref.split("@")[0].partition(":")
if name in UBUNTU_NAMES:
releases.append(tag)
else:
problems.append(f"line {lineno}: FROM {ref} is not an Ubuntu base")
if alias:
stages.add(alias)
return releases, problems
def file_size(path):
"""Size in bytes of a regular file, or None when there is none."""
p = pathlib.Path(path)
return p.stat().st_size if p.is_file() else None
def check_job_images(matrix, read_file, workflow_text):
"""Errors where an image's job container (`job_image`) is not the Ubuntu release its Dockerfile builds.
kaniko runs inside the job container and unpacks the image's root filesystem over it, so a
24.04 image built in a 26.04 job container corrupts the job (run 2529: GLIBC_2.42 not found).
The release of the job container must equal the release of every `FROM ubuntu:` line."""
errors = []
if not CONTAINER_LINE_RE.search(workflow_text):
errors.append(f"{MATRIX_FILE}: the job container must be `image: ${{{{ matrix.job_image }}}}`")
for name, entry in matrix.items():
job = JOB_IMAGE_RE.fullmatch(entry.get("job_image", ""))
if not job:
errors.append(f"image '{name}': job_image in {MATRIX_FILE} must be ubuntu:<release>@sha256:<digest>")
continue
path = str(pathlib.PurePosixPath(entry["subpath"]) / entry["dockerfile"]) if entry["subpath"] else entry["dockerfile"]
try:
releases, problems = dockerfile_releases(read_file(path))
except OSError as exc:
errors.append(f"image '{name}': cannot read {path}: {exc}")
continue
errors += [f"image '{name}': {path} {problem}" for problem in problems]
if not releases:
errors.append(f"image '{name}': {path} has no `FROM ubuntu:<release>` line")
for release in sorted(set(releases) - {job["release"]}):
errors.append(f"image '{name}': {path} builds on ubuntu:{release} but its job_image is ubuntu:{job['release']}; "
"kaniko unpacks the image over the job container, so the two releases must be equal: edit the "
f"FROM lines of {path} and job_image (tag and digest) in {MATRIX_FILE} in the same pull request")
return errors
REQUIRED_LABELS = ("org.opencontainers.image.title", "org.opencontainers.image.description",
"org.opencontainers.image.source", "org.opencontainers.image.url",
"org.opencontainers.image.documentation", "org.opencontainers.image.licenses",
"org.opencontainers.image.authors", "org.opencontainers.image.base.name", "net.rkdr.mortis.purpose",
"net.rkdr.mortis.contents", "net.rkdr.mortis.usage")
def dockerfile_labels(dockerfile_text):
"""{key: value} of the LABEL instructions of the LAST stage of a Dockerfile (labels of an earlier
stage are not inherited by a stage that starts from another image). The instruction is split like a
shell would split it, so a quoted value may hold spaces and `NAME=value` text."""
labels = {}
for unused, line in _instructions(dockerfile_text):
parts = line.split(None, 1)
if not parts:
continue
if parts[0].upper() == "FROM":
labels = {}
elif parts[0].upper() == "LABEL" and len(parts) == 2:
try:
tokens = shlex.split(parts[1])
except ValueError:
continue # an unbalanced quote: the labels stay missing, which the check reports
for token in tokens:
key, equals, value = token.partition("=")
if equals and key:
labels[key] = value
return labels
def check_image_metadata(matrix, read_file, size_of):
"""Errors where an image lacks the labels its registry page shows, or the document they link to.
size_of(path) is the size in bytes of a file, or None when there is no such file."""
errors = []
for name, entry in matrix.items():
path = str(pathlib.PurePosixPath(entry["subpath"]) / entry["dockerfile"]) if entry["subpath"] else entry["dockerfile"]
try:
text = read_file(path)
except OSError as exc:
errors.append(f"image '{name}': cannot read {path}: {exc}")
continue
labels = dockerfile_labels(text)
missing = [key for key in REQUIRED_LABELS if not labels.get(key, "").strip()]
if missing:
errors.append(f"image '{name}': the last stage of {path} lacks the label(s) {', '.join(missing)}")
quoted = sorted(key for key, value in labels.items() if "'" in value)
if quoted:
errors.append(f"image '{name}': the label(s) {', '.join(quoted)} contain a single quote, which kaniko's "
"LABEL parser rejects (run 2556); reword the text")
doc = f"docs/images/{name}.md"
source = labels.get("org.opencontainers.image.source", "").strip()
link = labels.get("org.opencontainers.image.documentation", "").strip()
if link and link != f"{source}/src/branch/main/{doc}":
errors.append(f"image '{name}': the documentation label must be <source label>/src/branch/main/{doc}")
if not size_of(doc):
errors.append(f"image '{name}': {doc} is missing or empty (the documentation label links to it)")
title = labels.get("org.opencontainers.image.title", "").strip()
if title and title != name:
errors.append(f"image '{name}': the title label is '{title}', expected the image name")
base = labels.get("org.opencontainers.image.base.name", "").strip()
releases, unused = dockerfile_releases(text)
if base and sorted(set(releases)) and base not in {f"ubuntu:{r}" for r in releases}:
errors.append(f"image '{name}': base.name label '{base}' differs from the FROM line(s) of {path}")
return errors
def changed_images(head_matrix, changed, read_head_file):
"""{name: sorted touched inputs} for each image of the matrix whose inputs are in `changed`."""
result = {}
@@ -394,11 +546,14 @@ def changed_paths(base_ref, target="HEAD"):
def run(argv):
if len(argv) >= 2 and argv[1] == "pins" and len(argv) == 2:
matrix = matrix_of(pathlib.Path(MATRIX_FILE).read_text())
image_yml = pathlib.Path(MATRIX_FILE).read_text()
matrix = matrix_of(image_yml)
if not pathlib.Path(REQUIRED_CONSUMER).exists():
raise CheckError(f"{REQUIRED_CONSUMER} is missing: it runs this check and is a required consumer")
texts = {f: pathlib.Path(f).read_text() for f in CONSUMERS if pathlib.Path(f).exists()}
errors = check_pins(matrix, texts)
errors += check_job_images(matrix, lambda p: pathlib.Path(p).read_text(), image_yml)
errors += check_image_metadata(matrix, lambda p: pathlib.Path(p).read_text(), file_size)
workflows = sorted(pathlib.Path(WORKFLOW_DIR).glob("*.y*ml")) if pathlib.Path(WORKFLOW_DIR).is_dir() else []
errors += check_foreign_images({str(f): f.read_text() for f in workflows})
note = " (checked: " + ", ".join(texts) + ")"
+1 -1
View File
@@ -42,7 +42,7 @@ import tarfile
import unicodedata
ALLOWED_TOP = {
"COPYING", "FILES.json", "LICENSES", "MANIFEST.json", "NOTICE", "README.md",
"CHANGELOG.rst", "COPYING", "FILES.json", "LICENSES", "MANIFEST.json", "NOTICE", "README.md",
"REUSE.toml", "changelogs", "docs", "meta", "plugins", "roles", "tests",
}
# Every Collection archive built by ansible-galaxy holds these.
+1
View File
@@ -2,3 +2,4 @@ COPYING no-smart-quotes
LICENSES/EUPL-1.2.txt no-smart-quotes
LICENSES/GPL-3.0-only.txt no-smart-quotes
LICENSES/GPL-3.0-or-later.txt no-smart-quotes
roles/docker/molecule/default/files/build-stub-repo.sh shebang # run by the docker scenario, not by Ansible
+17 -6
View File
@@ -20,7 +20,8 @@ FILES = {
"images/ci/Dockerfile": f"FROM ubuntu:24.04@{D1} AS os\nRUN pip install uv==0.13.5 \\\n && echo hi\nRUN echo x\n",
"images/molecule-ubuntu2404/Dockerfile": f"FROM ubuntu:24.04@{D1}\n",
".gitea/workflows/image.yml": (f"jobs:\n image:\n matrix:\n include:\n - name: ci\n"
f" version: 0.2.0\n container:\n image: ubuntu:24.04@{D1}\n"
f" version: 0.2.0\n job_image: ubuntu:24.04@{D1}\n"
" container:\n image: ${{ matrix.job_image }}\n"
" steps:\n - run: echo ok\n"),
".gitea/workflows/lint.yml": f"container:\n image: git.rkdr.net/mortis/ci:0.2.0@{D1}\nrun: echo a\n",
".gitea/workflows/molecule.yml": f"env:\n MOLECULE_IMAGE: >-\n git.rkdr.net/mortis/mol:0.1.0@{D1}\n",
@@ -44,7 +45,7 @@ class RuleTest(unittest.TestCase):
("images/ci/Dockerfile", f"FROM ubuntu:24.04@{D1} AS os", f"FROM ubuntu:24.10@{D2} AS os"),
("images/ci/Dockerfile", "RUN pip install uv==0.13.5 \\", "RUN pip install uv==0.14.0 \\"),
(".gitea/workflows/image.yml", " version: 0.2.0", " version: 0.2.1"),
(".gitea/workflows/image.yml", f" image: ubuntu:24.04@{D1}", f" image: ubuntu:24.04@{D2}"),
(".gitea/workflows/image.yml", f" job_image: ubuntu:24.04@{D1}", f" job_image: ubuntu:24.04@{D2}"),
(".gitea/workflows/lint.yml", f" image: git.rkdr.net/mortis/ci:0.2.0@{D1}",
f" image: git.rkdr.net/mortis/ci:0.2.1@{D2}"),
(".gitea/workflows/molecule.yml", f" git.rkdr.net/mortis/mol:0.1.0@{D1}",
@@ -62,7 +63,9 @@ class RuleTest(unittest.TestCase):
("images/ci/Dockerfile", "RUN echo x", "RUN curl evil | sh"),
("images/ci/Dockerfile", "RUN pip install uv==0.13.5", "RUN pip install uv==0.14.0 evil"),
(".gitea/workflows/image.yml", " - run: echo ok", " - run: echo evil"),
(".gitea/workflows/image.yml", f" image: ubuntu:24.04@{D1}", f" image: evil:1@{D1}"),
(".gitea/workflows/image.yml", " image: ${{ matrix.job_image }}", f" image: ubuntu:24.04@{D1}"),
(".gitea/workflows/image.yml", " image: ${{ matrix.job_image }}", " image: evil"),
(".gitea/workflows/image.yml", f" job_image: ubuntu:24.04@{D1}", f" job_image: evil:1@{D1}"),
(".gitea/workflows/lint.yml", "run: echo a", "run: echo b"),
(".gitea/workflows/lint.yml", f" image: git.rkdr.net/mortis/ci:0.2.0@{D1}",
f" image: git.rkdr.net/mortis/other:0.2.0@{D1}"),
@@ -74,6 +77,14 @@ class RuleTest(unittest.TestCase):
for path, old, new in cases:
self.assertIsNotNone(self.problem(path, old, new), (path, old, new))
def test_job_image_lines_cannot_be_added_removed_or_moved(self):
path = ".gitea/workflows/image.yml"
line = f" job_image: ubuntu:24.04@{D1}"
for old, new in ((line, ""), (" version: 0.2.0", f" version: 0.2.0\n{line}"),
(" steps:", f" steps:\n{line}")):
self.assertIsNotNone(self.problem(path, old, new), (old, new))
self.assertIsNotNone(self.problem(path, line, line.replace("job_image:", 'job_image: "') + '"'))
def test_tag_charset_is_restricted(self):
bad_tags = ["$(curl${IFS}evil|sh)", "a'b", 'a"b', "a;b", "a`b`", "a$b", "a b"]
for tag in bad_tags:
@@ -81,7 +92,7 @@ class RuleTest(unittest.TestCase):
(".gitea/workflows/lint.yml", f" image: git.rkdr.net/mortis/ci:0.2.0@{D1}",
f" image: git.rkdr.net/mortis/ci:{tag}@{D1}"),
("images/ci/Dockerfile", f"FROM ubuntu:24.04@{D1} AS os", f"FROM ubuntu:{tag}@{D1} AS os"),
(".gitea/workflows/image.yml", f" image: ubuntu:24.04@{D1}", f" image: ubuntu:{tag}@{D1}"),
(".gitea/workflows/image.yml", f" job_image: ubuntu:24.04@{D1}", f" job_image: ubuntu:{tag}@{D1}"),
]
for path, old, new in cases:
self.assertIsNotNone(self.problem(path, old, new), (path, tag))
@@ -91,8 +102,8 @@ class RuleTest(unittest.TestCase):
("images/ci/Dockerfile", f"FROM ubuntu:24.04@{D1} AS os", "FROM ubuntu:latest AS os"),
("images/ci/Dockerfile", f"FROM ubuntu:24.04@{D1} AS os", "FROM ubuntu AS os"),
("images/ci/Dockerfile", "FROM ubuntu:24.04 AS os", f"FROM ubuntu:24.04@{D1} AS os"),
(".gitea/workflows/image.yml", f" image: ubuntu:24.04@{D1}", " image: ubuntu:latest"),
(".gitea/workflows/image.yml", " image: ubuntu:24.04", f" image: ubuntu:24.04@{D1}"),
(".gitea/workflows/image.yml", f" job_image: ubuntu:24.04@{D1}", " job_image: ubuntu:latest"),
(".gitea/workflows/image.yml", " job_image: ubuntu:24.04", f" job_image: ubuntu:24.04@{D1}"),
]
for path, old, new in cases:
self.assertIsNotNone(self.problem(path, old, new), (path, old, new))
+127 -5
View File
@@ -13,6 +13,7 @@ sys.path.insert(0, str(SCRIPTS))
import check_image_versions as civ # noqa: E402
DIGEST = "sha256:" + "a" * 64
JOB = f"ubuntu:24.04@{DIGEST}"
IMAGE_YML = """\
jobs:
image:
@@ -23,12 +24,26 @@ jobs:
version: {mol}
subpath: images/mol
dockerfile: Dockerfile
job_image: """ + JOB + """
- name: ci
version: {ci}
subpath: ""
dockerfile: images/ci/Dockerfile
job_image: """ + JOB + """
container:
image: ${{{{ matrix.job_image }}}}
"""
CI_DOCKERFILE = "FROM x AS b\nCOPY requirements-dev.txt .pre-commit-config.yaml ./\nCOPY --from=b /a /b\n"
CI_DOCKERFILE = f"FROM {JOB} AS b\nCOPY requirements-dev.txt .pre-commit-config.yaml ./\nCOPY --from=b /a /b\n"
def labelled(name, body=""):
"""A Dockerfile text with the labels check_image_metadata requires."""
values = {key: "x" for key in civ.REQUIRED_LABELS}
values["org.opencontainers.image.title"] = name
values["org.opencontainers.image.source"] = "https://example.org"
values["org.opencontainers.image.documentation"] = f"https://example.org/src/branch/main/docs/images/{name}.md"
values["org.opencontainers.image.base.name"] = "ubuntu:24.04"
return (f"FROM {JOB}\nLABEL " + " \\\n ".join(f'{k}="{v}"' for k, v in values.items()) + "\n" + body)
def run(cwd, *cmd):
@@ -210,15 +225,120 @@ class PureTest(unittest.TestCase):
# The reader replaces PyYAML in the Renovate image (which has none); here PyYAML is the oracle.
import yaml
real = (pathlib.Path(__file__).resolve().parents[2] / civ.MATRIX_FILE).read_text()
want = {e["name"]: {"version": e["version"], "subpath": e.get("subpath") or "", "dockerfile": e["dockerfile"]}
want = {e["name"]: {"version": e["version"], "subpath": e.get("subpath") or "", "dockerfile": e["dockerfile"],
"job_image": e["job_image"]}
for e in yaml.safe_load(real)["jobs"]["image"]["strategy"]["matrix"]["include"]}
self.assertEqual(civ.matrix_of(real), want)
self.assertEqual(civ.matrix_of(IMAGE_YML.format(mol="0.1.0", ci="0.2.0")),
{e["name"]: {"version": e["version"], "subpath": e.get("subpath") or "",
"dockerfile": e["dockerfile"]}
"dockerfile": e["dockerfile"], "job_image": e["job_image"]}
for e in yaml.safe_load(IMAGE_YML.format(mol="0.1.0", ci="0.2.0"))
["jobs"]["image"]["strategy"]["matrix"]["include"]})
def test_job_image_must_match_the_dockerfile_release(self):
text = IMAGE_YML.format(mol="0.1.0", ci="0.2.0")
matrix = civ.matrix_of(text)
files = {"images/mol/Dockerfile": f"FROM {JOB}\n",
"images/ci/Dockerfile": f"FROM {JOB} AS os\nFROM os AS build\nFROM os AS final\n"}
def read(path):
return files[path]
self.assertEqual(civ.check_job_images(matrix, read, text), [])
files["images/ci/Dockerfile"] = f"FROM ubuntu:26.04@{DIGEST} AS os\nFROM os AS final\n"
errors = civ.check_job_images(matrix, read, text)
self.assertEqual(len(errors), 1)
self.assertIn("builds on ubuntu:26.04 but its job_image is ubuntu:24.04", errors[0])
files["images/ci/Dockerfile"] = "FROM debian:12\n"
self.assertIn("FROM debian:12 is not an Ubuntu base", civ.check_job_images(matrix, read, text)[0])
files["images/ci/Dockerfile"] = f"FROM {JOB} AS os\n"
self.assertEqual(civ.check_job_images(matrix, read, text.replace("matrix.job_image", "matrix.other")),
[".gitea/workflows/image.yml: the job container must be "
"`image: ${{ matrix.job_image }}`"])
def test_job_image_shape_and_missing_key(self):
text = IMAGE_YML.format(mol="0.1.0", ci="0.2.0")
for bad in (text.replace(f"job_image: {JOB}", "job_image: ubuntu:latest", 1),
text.replace(f" job_image: {JOB}\n", "", 1)):
errors = civ.check_job_images(civ.matrix_of(bad), lambda path: f"FROM {JOB}\n", bad)
self.assertEqual(len(errors), 1, errors)
self.assertIn("job_image in .gitea/workflows/image.yml must be ubuntu:<release>@sha256:<digest>", errors[0])
def test_dockerfile_releases_fail_closed(self):
digest = DIGEST
cases = {
f"FROM --platform=linux/amd64 ubuntu:26.04@{digest} AS a\nFROM a AS b\n": (["26.04"], 0),
f"FROM docker.io/library/ubuntu:24.04@{digest}\n": (["24.04"], 0),
"FROM ubuntu:24.04 AS ubuntu\nFROM ubuntu AS x\n": (["24.04"], 0),
"FROM golang:1.22 AS b\nFROM ubuntu:24.04\n": (["24.04"], 1),
"ARG B=ubuntu:26.04\nFROM ubuntu:24.04 AS a\nFROM ${B} AS b\n": (["24.04"], 1),
"FROM ubuntu:${REL}\n": ([], 1),
"FROM ubuntu:24.04\nRUN <<EOF\necho hi\nEOF\n": (["24.04"], 0),
}
for text, (want_releases, want_problems) in cases.items():
releases, problems = civ.dockerfile_releases(text)
self.assertEqual((releases, len(problems)), (want_releases, want_problems), (text, problems))
def test_container_line_must_sit_under_container(self):
text = IMAGE_YML.format(mol="0.1.0", ci="0.2.0")
lookalike = text.replace(" container:\n image: ${{ matrix.job_image }}\n",
" container:\n image: ubuntu:24.04\n steps:\n - run: |\n"
" image: ${{ matrix.job_image }}\n")
errors = civ.check_job_images(civ.matrix_of(lookalike), lambda path: f"FROM {JOB}\n", lookalike)
self.assertEqual(len(errors), 1, errors)
self.assertIn("the job container must be", errors[0])
def test_quoted_job_image_is_refused(self):
text = IMAGE_YML.format(mol="0.1.0", ci="0.2.0").replace(f"job_image: {JOB}", f'job_image: "{JOB}"', 1)
with self.assertRaises(civ.CheckError):
civ.matrix_of(text)
def test_image_metadata_labels_and_documentation(self):
text = IMAGE_YML.format(mol="0.1.0", ci="0.2.0")
matrix = civ.matrix_of(text)
files = {"images/mol/Dockerfile": labelled("mol"), "images/ci/Dockerfile": labelled("ci")}
sizes = {"docs/images/mol.md": 5, "docs/images/ci.md": 5}
def check():
return civ.check_image_metadata(matrix, lambda path: files[path], sizes.get)
self.assertEqual(check(), [])
files["images/ci/Dockerfile"] = labelled("ci").replace('net.rkdr.mortis.usage="x"', 'net.rkdr.mortis.usage=""')
self.assertIn("lacks the label(s) net.rkdr.mortis.usage", check()[0])
files["images/ci/Dockerfile"] = labelled("ci").replace("docs/images/ci.md", "docs/images/other.md")
self.assertIn("documentation label must be", check()[0])
files["images/ci/Dockerfile"] = labelled("ci").replace("https://example.org/src", "https://evil.example/src")
self.assertIn("documentation label must be", check()[0])
files["images/ci/Dockerfile"] = labelled("renamed")
self.assertTrue(any("expected the image name" in e for e in check()))
files["images/ci/Dockerfile"] = labelled("ci").replace('net.rkdr.mortis.usage="x"', 'net.rkdr.mortis.usage="the distribution\'s tool"')
self.assertIn("contain a single quote", check()[0])
files["images/ci/Dockerfile"] = labelled("ci").replace('base.name="ubuntu:24.04"', 'base.name="ubuntu:22.04"')
self.assertIn("base.name label 'ubuntu:22.04' differs", check()[0])
files["images/ci/Dockerfile"] = labelled("ci")
sizes["docs/images/ci.md"] = 0
self.assertIn("docs/images/ci.md is missing or empty", check()[0])
del sizes["docs/images/ci.md"]
self.assertIn("docs/images/ci.md is missing or empty", check()[0])
del files["images/ci/Dockerfile"]
sizes["docs/images/ci.md"] = 5
with self.assertRaises(KeyError):
check()
def test_dockerfile_labels_parse_like_a_shell(self):
text = ('FROM a AS b\nLABEL builder=1\nFROM c\n'
'LABEL one="x y=z w" two=\'q r\' \\\n three=plain\n'
'LABEL four="PRE_COMMIT_HOME=/opt/pre-commit; done" legacy value\n')
self.assertEqual(civ.dockerfile_labels(text),
{"one": "x y=z w", "two": "q r", "three": "plain", "four": "PRE_COMMIT_HOME=/opt/pre-commit; done"})
self.assertEqual(civ.dockerfile_labels('FROM c\nLABEL a="unbalanced\n'), {})
def test_real_dockerfiles_carry_the_metadata(self):
root = pathlib.Path(__file__).resolve().parents[2]
matrix = civ.matrix_of((root / civ.MATRIX_FILE).read_text())
self.assertEqual(civ.check_image_metadata(matrix, lambda p: (root / p).read_text(),
lambda p: (root / p).stat().st_size if (root / p).is_file() else None), [])
def test_scripts_do_not_import_yaml(self):
# The bump step runs in the Renovate image, whose python3 has no PyYAML (dry run 2453).
for script in ("check_image_versions.py", "bump_image_versions.py"):
@@ -249,8 +369,10 @@ class GitTest(unittest.TestCase):
run(self.repo, "git", "config", "user.email", "[email protected]")
run(self.repo, "git", "config", "user.name", "t")
self.write(".gitea/workflows/image.yml", IMAGE_YML.format(mol="0.1.0", ci="0.2.0"))
self.write("images/ci/Dockerfile", CI_DOCKERFILE)
self.write("images/mol/Dockerfile", "FROM x\n")
self.write("images/ci/Dockerfile", labelled("ci", CI_DOCKERFILE.split("\n", 1)[1]))
self.write("images/mol/Dockerfile", labelled("mol"))
self.write("docs/images/ci.md", "ci\n")
self.write("docs/images/mol.md", "mol\n")
self.write("requirements-dev.txt", "a==1\n")
self.write(".pre-commit-config.yaml", "repos: []\n")
self.commit("base")