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
14 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), 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.
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.
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. - 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. - 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.
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.txtor.pre-commit-config.yamltakes the slower path that installs the pinned tools. - 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; run 2529 broke a 24.04 build in a 26.04 job container). 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. image.ymltries 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 secretsPACKAGE_PUSH_USERandPACKAGE_PUSH_TOKEN. 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.
- Policy: minor and patch bumps automerge, majors are manual.
ansible-coreminor and major are manual too (a new minor can show new sanity findings), andansible-coreandansible-lintbump in one group. Dockerfile base-image tag and digest bumps (images/*/Dockerfile) stay automergeable within a release: Kamino is the untrusted side and the pin PR's CI exercises the new image. A new Ubuntu release (majorubuntuupdate) is never a bump: it is a deliberate edit. Thejob_imageof each matrix entry inimage.yml(the job container) never automerges: that job holds the registry push credential. kaniko is pinned by layer digests inimage.yml; no Renovate manager reads them, so it is updated by hand (the/kaniko/rule inrenovate.jsonis 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 imageversion:inimage.yml(scripts/bump_image_versions.py [<base-ref>], idempotent, edits only the version line;check_image_versions.py bumpthen passes). The merge builds the image onmain. PR 2 moves the consumers'image:<version>@sha256:<digest>pins to that digest.renovate.jsonruns the script as apostUpgradeTaskscommand of a catch-all rule (matches every package, since only the first upgrade of a branch counts; branch mode, file filterimage.yml; allowed by the one anchored regex inRENOVATE_ALLOWED_COMMANDSofrenovate.yml), so PR 1 carries the bump. PR 2 is Renovate's too: the pin-follow rule forgit.rkdr.net/mortis/*moves theimage:<version>@sha256:<digest>pins oflint.yml,build.ymlandmolecule.ymlto the newest published version and automerges after its own Lint and Build ran in the new image (unverified until the first such PR; a major version stays manual). - Bot-diff gate: the
lintworkflow runsscripts/check_bot_pr_diff.pyon pull requests. A head ref startingrenovate/may only change version lines inrequirements-dev.txt,rev:lines in.pre-commit-config.yaml, FROM tags/digests and theuv==pin inimages/*/Dockerfile, the matrixversion:lines and thejob_image:ubuntu pins inimage.yml, and the image pins inlint.yml,build.ymlandmolecule.yml. Anything else fails,renovate.jsonincluded. 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.ymlbuild_ignore, so the Collection archive and version do not change. A role-visible change needs a changelog fragment and a newgalaxy.ymlversion, and only the operator tags. - No production images:
check_image_versions.py pinsfails when anything under.gitea/workflowsmentionsgit.rkdr.net/defame1297/. - Where Renovate runs:
.gitea/workflows/renovate.yml, a daily cron (03:17 UTC) plusworkflow_dispatch, on thekamino-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 secretRENOVATE_BOT_TOKEN(scopeswrite:repository,write:issue,read:user,read:organization; not an org secret: onlyimage.ymlmay reference those).read:organizationis 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 usergitea-actions, and Gitea answers400 user does not exist(dry run 2445). The bot user must not be able to push tomainor merge past the required checks (branch protection). The job container isrenovate/renovate:<version>-full@sha256:...from Docker Hub (the-fullflavour forpython3), 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 (noRENOVATE_GITHUB_COM_TOKENexists) and may hit rate limits: best effort. - Dry run: Actions > Renovate > Run workflow with
dry_run=true(the default for a manual run; setsRENOVATE_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 (noexternal-host-error, nocould 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 globalhttp.<server>/.extraheader(AUTHORIZATION: bearer <token>, likelint.yml; Renovate does not passGIT_CONFIG_*from its environment to git but does passHOME), 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 requiredLintandBuildnever start, automerge cannot work); (4) that bot PRs are held bymain's required status checks (check the branch protection). Also confirm in the log: Renovate clones blobless with full history, soorigin/mainexists for the script (source-based);python3is in the image (no PyYAML: the scripts the bump step imports use the standard library only, dry run 2453);github.head_refis populated (the gate fails closed on an empty one, viaEVENT_NAME). Safety net: a failing or disallowed post-upgrade command opens the PR WITHOUT the bump plus a redrenovate/artifactsstatus, andcheck_image_versions.py bumpthen fails lint. - The workflow holds the runner's slot: the
kamino-runnerhost has a single slot (the label iskamino-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: credentials for the
git.rkdr.netregistry (hostRules; the tag and digest lookups are anonymous). Thepre-commitmanager 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 extractsscripts/fromorigin/mainand runs the guard from there, so a pull request cannot weaken its own gate (the PR copy runs only whilemainhas 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 anyimage.ymlpush path (images/**,requirements-dev.txt,.pre-commit-config.yaml,.gitea/workflows/image.yml), so it rebuilds nothing.