Moves the gitea role from the environment repository, the second wave 2 role and the second caller of the internal _binary_update role. Against the source: - The update path stages the downloaded, signature-verified binary in a directory next to the live one and hands the stop, backup, swap, restart, version check and rollback to mortis.kamino._binary_update (include_role with apply tags, so --tags update reaches it). A download or signature failure still leaves the running service untouched and says so; a failure in the swap keeps the rollback message of _binary_update. Its default version regex is the one the source used. - The same two small behaviour changes as for traefik come with _binary_update: the backup is taken whenever a live binary exists, and a failure before the stop no longer restarts the running service. - The update no longer removes a PID file between the stop and the start, and gitea_pid_file is gone: the unit runs `gitea web` without --pid and has no PIDFile=, so Gitea writes no PID file and systemd reads none. - The database-migration warning of the source's rollback message (the previous binary may refuse a migrated schema) moves to the gitea_update docs in the README and the argument_specs, since _binary_update owns the failure message. - The legacy name guard (pre-rename variables of the environment) is dropped, as in the wave 1 roles, and the argument_specs and README no longer mention it. The jwt secret, mailer and e-mail confirmation asserts stay. - Environment references are gone from comments, app.ini.j2, the README and the argument_specs: issue numbers, decision records, host names, inventory paths, playbooks, the network and proxy layout and other roles' copies of the paths. The Renovate comment on gitea_version is dropped; the README and argument_specs recommend pinning the version in inventory. The mint messages no longer name a playbook. - On a fresh host the token assert and the SSH-key upload ran before the unit was written and Gitea started, so a first install could never complete. Both now run after the service check, and the upload first waits (up to 60 s, not under --check) for the local listener; the listener address is resolved once for both. - REVERSE_PROXY_LIMIT, hard-coded to 2, is now gitea_reverse_proxy_limit with default 1: a limit above the real number of proxies lets a client forge the address Gitea logs and Fail2Ban bans. A setup with two proxies sets it to 2. - The gitea commands with user-supplied values (migrate, admin user list and create, and the token mint) take argv instead of a command string; still run through sudo -u. - gitea_version is asserted at role start to be a plain X.Y.Z, with no leading v. - meta namespace mortis; the scenario follows the Kamino conventions (header, test_sequence, no provisioner env) and calls the role by FQCN, also in the child ansible-playbook of the mint CI-guard cases. Coverage is unchanged. No other default changed; DISABLE_REGISTRATION stays hard-coded to true. Changelog fragment, README Roadmap and the CLAUDE.md role list updated. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01MmzvM9skAvYcph2c9EiPcm
15 KiB
CLAUDE.md
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) of reusable,
hardened roles. 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, system_baseline in 1.3.0, ufw in 1.4.0; 1.5.0 adds no role (new system_baseline options); sshd in 1.6.0; user_management in 1.7.0; traefik, with the internal _binary_update, in 1.8.0; gitea in the next release.
Roadmap. The roles still to come, and the ones that will never be extracted, are listed in
the README section "Roadmap". Context: the maintainer's private environment repository (a
production home lab driven by Ansible) holds every role until it moves here; a role moves only
after its tests exist and the environment has been cut over to mortis.kamino.<role> at a
pinned tag. The list is informational, not enforced by any hook. Keep it true by hand: the pull
request that adds a role under roles/ also removes it from the Roadmap list, and when the list
is empty the section goes too. When something looks wrong or missing there, say so to the
operator; the plan itself is theirs (epic #486 in the environment repository, which you cannot
read from here).
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
- Set up once per clone:
scripts/dev-setup.sh(a virtualenv with the pinned tools and git hooks that find them). Thelanguage: systemhooks runreuse,ansible-lintandantsibull-changelogby name, so a hook run without that virtualenv onPATHfails. - Agent skills come from holocron through apm:
apm install(theapmCLI is not one of the pinned tools, anddev-setup.shdoes not run it) deploys them to.claude/skillsand.claude/agents, both gitignored likeapm_modules/.apm.ymlandapm.lock.yamlare the only tracked files. The entries are unpinned on purpose (see the comment inapm.yml);apm install --updatemoves them. They are tooling, sogalaxy.ymlbuild_ignorekeeps them out of the Collection. - Commit with git in a clone, never through the Gitea API. The hooks (REUSE, yamllint,
actionlint, ansible-lint, gitleaks, changelog lint, Conventional Commits) only run in
git commit; an API commit skips them and CI finds the problem after the push. The first hook run builds the Go hook environments and takes minutes: run commits in the background.git pushalso runsansible-test sanityon HEAD (scripts/ansible-test-sanity.sh, the Build job's check, which ruff and the other hooks do not cover); its first run builds virtualenvs and takes minutes. - This repository stands alone. No tracked file, issue or pull request text or comment, release note or job output refers to another repository of the maintainer's, its documents, hosts, network or namespaces, or states host sizing. Every comment states its own reason. When bringing content in from another repository, before committing, search the incoming diff for mentions of the source repository, its documents, hostnames, addresses, account namespaces and sibling paths; rewrite comments so they stand alone; say in the pull request what was searched for. No control holds this rule, and it has no expiry.
- Feature branch and pull request;
mainandv*tags are protected. Never push tomain. Releases are the operator's: annotatedvX.Y.Ztags equal togalaxy.yml's version. - Conventional Commits. A PR says what was verified and what was not.
- There is no local molecule and no container runtime on the control host: do not install one.
Molecule runs in CI, on the repository's own runner (label
kamino-molecule). - Changes that can affect a consumer need a changelog fragment (
changelogs/fragments/). New files are covered byREUSE.toml; third-party-derived content needs its own annotation.
Agent skills
Issue tracker
Issues live in Gitea Issues on mortis/kamino, used through the gitea-issues skill and the Gitea MCP tools. See docs/agents/issue-tracker.md.
Triage labels
The five triage roles map onto the repo's scoped Status/ and Reviewed/ labels. See docs/agents/triage-labels.md.
Domain docs
Single-context: GLOSSARY.md and docs/adr/ at the root, both created lazily. See docs/agents/domain.md.
Workflows (.gitea/workflows/)
- Never
pull_request_target. A forkpull_requestrun gets no secrets and a read-only job token; a same-repo pull request does get the org Actions secrets, so nothing butimage.ymlmay reference them. Pass ref, repo and name values to scripts throughenv:, never interpolate${{ github.* }}into arun:block. - Runner labels are
kamino-dockerandkamino-moleculeonly (.gitea/actionlint.yaml). Use thegithub.*contexts, which Gitea aliases; actionlint does not knowgitea.*. - Lint and Build run in the
ciimage. After the checkout they compare the pin files with the checksums baked into the image: a PR that changesrequirements-dev.txt,requirements-dev.lock,requirements.ymlor.pre-commit-config.yamltakes the slower path that installs the pinned tools and collections. - Molecule runs on every same-repo pull request, Renovate's included (a new image is tested by its own pin
pull request), with no workflow path filter, so that it can be a required check. Fork pull requests are skipped.
What a pull request runs is chosen by
scripts/select_molecule_scenarios.py, run from the base branch's copy (a pull request cannot edit its own rules): only the scenarios of the roles it changes and of the roles that use them (any file namingmortis.kamino.<role>, transitively; a test fails a bare or templated role name in an include, import, playroles:entry or meta dependency), none for a diff of only its IGNORED paths, a failure for a changed role with no scenario, and every scenario for any other file, for every push tomain, for manual dispatch and for the nightly run (04:43 UTC, after Renovate's). A new file outsideroles/<role>/runs everything until it is added to IGNORED, which is right only when no scenario reads it. A new commit cancels the pull request's running Molecule run, and the step first removes containers a cancelled run left; two runs never overlap because the runner has a single slot, so raising its capacity needs a lock or a shared concurrency group. - Every scenario sets
scenario.test_sequenceto molecule's default minus the leadingdestroy(the workflow clears stale containers first, and the molecule state lives in the job's ownANSIBLE_HOME, so a killed run leaves none behind); copy it into a new scenario. - Molecule discovers
extensions/molecule/*/androles/*/molecule/*/. Theimage-smokeandimage-smoke-2604scenarios test the molecule images themselves (24.04 and 26.04); a role scenario that must pass on both takesimage: ${MOLECULE_IMAGE}or${MOLECULE_IMAGE_2604}per platform.
Images (images/)
ci,molecule-ubuntu2404andmolecule-ubuntu2604, built byimage.ymlwith kaniko on push tomain(never on pull requests) and pushed togit.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
ubuntuupdates 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>andlatest; there is nosha-*tag, so one digest belongs to exactly one version. ansible-test sanityignores live intests/sanity/ignore-common.txt; the Build job copies it to the file name of the installed core version in its throwaway worktree (a committedignore-<MAJOR.MINOR>.txtis appended for findings of one version only).- 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 theFROM ubuntu:release of the image's Dockerfile (check_image_versions.py pinsfails otherwise). Moving an image to a new release is one edit: the DockerfileFROM, thejob_imagetag and digest, and the version bump. Digest drift within a release is tolerated. Ajob_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.*plusnet.rkdr.mortis.purpose/contents/usage), the build addsversion,revisionandcreated, and the readme-style text lives indocs/images/<name>.md, which thedocumentationlabel links to.check_image_versions.py pinsfails 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
ciimage deletes the Go toolchains from the hook cache and the unusedlibpython*.soof its three baked interpreters (the/opt/pythonlayer was 99 MB compressed with them, ci 0.2.26 failed to push). The build prints the compressed size of each layer directory; the registry stores about 9% more, so read that line before adding an interpreter or a hook environment. image.ymlis 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 (daily cron and workflow_dispatch) on the
kamino-docker runner, as a Kamino-only bot user: this repository's jobs run only on its own
runners, and no credential from anywhere else is used here. Never reuse another Renovate credential here.
- 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_imageof each matrix entry inimage.ymlnever automerges: that job holds the registry push credential. kaniko is pinned by layer digests inimage.ymland updated by hand.prHourlyLimitis 5 (default 2): anubuntudigest move makes two PRs per release (base image and job container), and two runs in a row spent the whole default limit on them, so the hook and image pin PRs waited. - Two-PR loop for an image input (
requirements-dev.txt,requirements-dev.lock,requirements.yml,.pre-commit-config.yaml,images/**): PR 1 carries the input change plus the PATCH bump of the imageversion:inimage.yml(scripts/bump_image_versions.py [<base-ref>];check_image_versions.py bumpthen passes; Renovate runs it as a post-upgrade task). The merge builds the image onmain. PR 2 moves the consumers' pins to the new digest (Renovate's pin-follow rule for themortis/*images; a major version stays manual). - One Python for the lock, a clone and the ci image:
.python-version(a minor version) is the source.scripts/dev-setup.shandscripts/lock-requirements.shrequire exactly it, theciimage builds/opt/venvfrom its baked copy (ARG PYTHON_VERSIONinimages/ci/Dockerfile), the lock header records it, andcheck_image_versions.py pinsfails when any of them differs. Renovate's-fullcontainer runspip-compileon its own python (RENOVATE_BINARY_SOURCE=global, it ignores the header's version), so that python's minor version must equal.python-version: check it when bumping the image inrenovate.yml. Moving the version is one pull request:.python-version, bothARG PYTHON_VERSIONlines ofimages/ci/Dockerfile, the lock, and the image version bump. - Python tool pins and their lock:
requirements-dev.txtholds the direct pins,requirements-dev.lockis their hashed lock (installed withpip install --require-hashes -r requirements-dev.lock -r requirements-dev.txt; pip refuses an unhashed package and any disagreement between the two). Renovate'spip-compilemanager bumps a pin and regenerates the lock by replaying the lock's header command; a weekly lock-file-maintenance PR moves transitive packages and is never automerged. By hand:scripts/lock-requirements.sh [--upgrade]. The header must hold only options Renovate knows: it refuses--newline=LF("not supported (yet)"), extracts nothing, and proposes no bump, with only a WARN in an otherwise green run. Hook repositories in.pre-commit-config.yamlare pinned by commit SHA with a# frozen: vX.Y.Zcomment. Renovate looks them up withgit ls-remote(packageRuleoverrideDatasource: git-tagsplusRENOVATE_GITHUB_TOKEN_WARN=falseinrenovate.yml), because there is no GitHub token and the defaultgithub-tagslookup is skipped or rate limited. A hook bump is never automerged:git-tagshas no release timestamps, sominimumReleaseAgecannot delay it. After a Renovate config change, test it locally before the merge:renovate --platform=local(same version asrenovate.yml) reads this checkout; a dry run in Actions readsrenovate.jsonfrommain. - Bot-diff gate:
scripts/check_bot_pr_diff.pyruns in the lint workflow, fromorigin/main's copy so a pull request cannot weaken it. Arenovate/head ref may only change version lines (tool pins and their lock entries and hashes, hookrev:lines, Dockerfile FROM tags and digests, matrixversion:lines,job_image:pins, consumer image pins); anything else fails,renovate.jsonincluded. 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.ymlbuild_ignore. A role-visible change needs a changelog fragment and a newgalaxy.ymlversion; only the operator tags. - Denied image namespace:
check_image_versions.py pinsfails when anything under.gitea/workflowsmentions the image namespace this repository's CI must not use (the string is in the script). - 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.