feat(gitea): add the gitea role #284

Merged
Defame1297 merged 3 commits from feat/gitea-role into main 2026-11-21 22:44:08 +00:00
Owner

Adds gitea, the second wave 2 role and the second caller of the internal _binary_update role. It is copied from the environment repository's local role, with the changes below.

What changed against the source

  • Update path. The downloaded, GPG-verified binary is staged in <gitea_install_dir>/.gitea-staging. The stop, backup, swap, restart, version check and rollback are handed to mortis.kamino._binary_update, the same way traefik does it. The include uses apply tags, so --tags update reaches it. A download or signature failure leaves Gitea running and says so.
  • Behaviour changes that come with _binary_update: the same two as for traefik.
    • The backup is taken whenever a live binary exists.
    • A failure before the stop no longer restarts the service.
  • PID-file step and gitea_pid_file removed. The unit runs gitea web without --pid and has no PIDFile=, so Gitea writes no PID file and systemd reads none.
  • Database-migration warning moved to the gitea_update docs (README and argument_specs). The previous binary may refuse a schema the new one migrated. _binary_update owns the failure message, so the warning can no longer live there.
  • Fresh-install order fixed (a bug carried over from the source). 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 for the local listener (skipped under --check and when there are no keys).
  • REVERSE_PROXY_LIMIT is now gitea_reverse_proxy_limit, default 1. It was hard-coded to 2. A limit above the real number of proxies lets a client forge the address Gitea logs and Fail2Ban bans.
  • Commands take argv. migrate, admin user list and create, and the token mint no longer pass user-supplied values through a command string. They still run through sudo -u.
  • gitea_version is asserted to be a plain X.Y.Z at role start. A leading v used to produce a 404 download URL.
  • Legacy name guard dropped, as in the wave 1 roles. The jwt secret, mailer and e-mail confirmation asserts stay.
  • Environment content removed:
    • issue numbers, decision records, host names, inventory paths and playbooks;
    • the network and proxy layout in app.ini.j2;
    • the Renovate comment on gitea_version (the README and argument_specs recommend pinning it in inventory).
  • Meta and scenario conventions. The meta namespace is mortis. The scenario follows the Kamino conventions and calls the role by FQCN, also in the child ansible-playbook of the mint CI-guard cases. Coverage is unchanged: the mint guard and no-op paths, the four signature cases against local files and throwaway keys, and the remove path with its ufw rules.
  • Docs. Changelog fragment, README Roadmap, the README line on who calls _binary_update, and the CLAUDE.md role list.

No other default changed. DISABLE_REGISTRATION stays hard-coded to true.

Second commit: SelectTest on a fixture tree

  • Why it is needed. gitea is the first role that uses fail2ban. SelectTest in tests/scripts/test_select_molecule_scenarios.py ran select() against the repository itself, so its test_two_roles (which changes fail2ban) now also selected gitea. It then failed with "role without a molecule scenario", because gitea was not in its fixed scenario list.
  • The fix. The selection tests now run on a temporary tree that holds the roles of ALL and no use of one role by another, like UsersTest next to it, which covers the users. The next role to use fail2ban or ufw will not break the test again.

Scrub check

I grepped the diff and the commit messages for:

  • the private domain, and host and group names;
  • hosts/, playbooks/, group_vars and host_vars paths;
  • #NNN references, ADR, and private IPv4 ranges;
  • tunnel and VPN layout words.

The only hits are the role names in the README Roadmap line and author: in meta/main.yml, as in every role.

Verified

  • CI on a197536: Build, Lint and Molecule all pass. The molecule run on the first commit ran only the gitea scenario, which passed (167 tasks ok, none failed). The run on the second commit ran every scenario, because it changes tests/scripts.
  • Commit and push hooks: all passed, including ansible-lint (production profile), yamllint, REUSE, changelog lint, Conventional Commits and ansible-test sanity (pre-push). tests/scripts passes locally (202 tests).
  • Syntax: --syntax-check of converge.yml, verify.yml and ci_guard.yml.
  • Three independent subagent reviews. One compared behaviour with the source; one checked conventions, the scrub and security; one was a final readiness pass.
    • Every blocker and should-fix item they found is fixed: three systemd tasks in verify.yml that the FQCN rewrite had renamed, the fresh-install order, the proxy limit, argv, and the doc mismatches.
    • The final pass returned READY, and its nits are applied.

Not verified

  • The update path against a real Gitea release: as in the source, the scenario does not install Gitea. _binary_update's own scenarios cover the swap and rollback.
  • Version check as root: gitea --version now runs as root inside _binary_update. I expect it to work, because the flag is handled before Gitea's run-user check, but that is not tested.

Left for later (unchanged from the source)

  • gitea_app_dir is 0770 root:git. Tightening it might break Gitea writing its own app.ini.
  • gitea_jwt_secret is asserted in the tasks but not marked required in the argument spec.

After the merge, the release tag is the operator's. A consumer that relied on the old hard-coded value sets gitea_reverse_proxy_limit: 2 to keep it.

🤖 Generated with Claude Code

Adds `gitea`, the second wave 2 role and the second caller of the internal `_binary_update` role. It is copied from the environment repository's local role, with the changes below. ## What changed against the source - **Update path.** The downloaded, GPG-verified binary is staged in `<gitea_install_dir>/.gitea-staging`. The stop, backup, swap, restart, version check and rollback are handed to `mortis.kamino._binary_update`, the same way `traefik` does it. The include uses `apply` tags, so `--tags update` reaches it. A download or signature failure leaves Gitea running and says so. - **Behaviour changes that come with `_binary_update`:** the same two as for `traefik`. - The backup is taken whenever a live binary exists. - A failure before the stop no longer restarts the service. - **PID-file step and `gitea_pid_file` removed.** The unit runs `gitea web` without `--pid` and has no `PIDFile=`, so Gitea writes no PID file and systemd reads none. - **Database-migration warning moved to the `gitea_update` docs (README and argument_specs).** The previous binary may refuse a schema the new one migrated. `_binary_update` owns the failure message, so the warning can no longer live there. - **Fresh-install order fixed (a bug carried over from the source).** 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 for the local listener (skipped under `--check` and when there are no keys). - **`REVERSE_PROXY_LIMIT` is now `gitea_reverse_proxy_limit`, default 1.** It was hard-coded to 2. A limit above the real number of proxies lets a client forge the address Gitea logs and Fail2Ban bans. - **Commands take `argv`.** `migrate`, `admin user list` and `create`, and the token mint no longer pass user-supplied values through a command string. They still run through `sudo -u`. - **`gitea_version` is asserted to be a plain `X.Y.Z`** at role start. A leading `v` used to produce a 404 download URL. - **Legacy name guard dropped,** as in the wave 1 roles. The jwt secret, mailer and e-mail confirmation asserts stay. - **Environment content removed:** - issue numbers, decision records, host names, inventory paths and playbooks; - the network and proxy layout in `app.ini.j2`; - the Renovate comment on `gitea_version` (the README and argument_specs recommend pinning it in inventory). - **Meta and scenario conventions.** The meta namespace is `mortis`. The scenario follows the Kamino conventions and calls the role by FQCN, also in the child `ansible-playbook` of the mint CI-guard cases. Coverage is unchanged: the mint guard and no-op paths, the four signature cases against local files and throwaway keys, and the remove path with its ufw rules. - **Docs.** Changelog fragment, README Roadmap, the README line on who calls `_binary_update`, and the CLAUDE.md role list. No other default changed. `DISABLE_REGISTRATION` stays hard-coded to `true`. ## Second commit: `SelectTest` on a fixture tree - **Why it is needed.** `gitea` is the first role that uses `fail2ban`. `SelectTest` in `tests/scripts/test_select_molecule_scenarios.py` ran `select()` against the repository itself, so its `test_two_roles` (which changes `fail2ban`) now also selected `gitea`. It then failed with "role without a molecule scenario", because `gitea` was not in its fixed scenario list. - **The fix.** The selection tests now run on a temporary tree that holds the roles of `ALL` and no use of one role by another, like `UsersTest` next to it, which covers the users. The next role to use `fail2ban` or `ufw` will not break the test again. ## Scrub check I grepped the diff and the commit messages for: - the private domain, and host and group names; - `hosts/`, `playbooks/`, `group_vars` and `host_vars` paths; - `#NNN` references, `ADR`, and private IPv4 ranges; - tunnel and VPN layout words. The only hits are the role names in the README Roadmap line and `author:` in `meta/main.yml`, as in every role. ## Verified - **CI on `a197536`: Build, Lint and Molecule all pass.** The molecule run on the first commit ran only the `gitea` scenario, which passed (167 tasks ok, none failed). The run on the second commit ran every scenario, because it changes `tests/scripts`. - **Commit and push hooks:** all passed, including ansible-lint (production profile), yamllint, REUSE, changelog lint, Conventional Commits and `ansible-test sanity` (pre-push). `tests/scripts` passes locally (202 tests). - **Syntax:** `--syntax-check` of `converge.yml`, `verify.yml` and `ci_guard.yml`. - **Three independent subagent reviews.** One compared behaviour with the source; one checked conventions, the scrub and security; one was a final readiness pass. - Every blocker and should-fix item they found is fixed: three `systemd` tasks in `verify.yml` that the FQCN rewrite had renamed, the fresh-install order, the proxy limit, `argv`, and the doc mismatches. - The final pass returned READY, and its nits are applied. ## Not verified - **The update path against a real Gitea release:** as in the source, the scenario does not install Gitea. `_binary_update`'s own scenarios cover the swap and rollback. - **Version check as root:** `gitea --version` now runs as root inside `_binary_update`. I expect it to work, because the flag is handled before Gitea's run-user check, but that is not tested. ## Left for later (unchanged from the source) - `gitea_app_dir` is `0770 root:git`. Tightening it might break Gitea writing its own `app.ini`. - `gitea_jwt_secret` is asserted in the tasks but not marked `required` in the argument spec. After the merge, the release tag is the operator's. A consumer that relied on the old hard-coded value sets `gitea_reverse_proxy_limit: 2` to keep it. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
Claude added 1 commit 2026-11-21 21:54:06 +00:00
feat(gitea): add the gitea role
Build / build (pull_request) Successful in 12s
Lint / lint (pull_request) Failing after 43s
Molecule / molecule (pull_request) Successful in 1m20s
f060461152
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
Defame1297 added 1 commit 2026-11-21 21:59:59 +00:00
test(scripts): run SelectTest on a fixture tree
Build / build (pull_request) Successful in 12s
Lint / lint (pull_request) Successful in 44s
Molecule / molecule (pull_request) Successful in 1m21s
a197536ba6
SelectTest called select() against the repository itself, so its expectations
depended on which real roles use which: with gitea using fail2ban, a change to
fail2ban also selects gitea, and test_two_roles failed with "role without a
molecule scenario". The selection tests now run on a temporary tree that holds
the roles of ALL and no use of one role by another, like UsersTest, which
covers the users.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01MmzvM9skAvYcph2c9EiPcm
CODEOWNERS rules requested review from Defame1297 2026-11-21 21:59:59 +00:00
Defame1297 added 1 commit 2026-11-21 22:41:11 +00:00
Merge branch 'main' into feat/gitea-role
Build / build (pull_request) Successful in 12s
Lint / lint (pull_request) Successful in 44s
Molecule / molecule (pull_request) Successful in 1m20s
fef9e16765
Defame1297 approved these changes 2026-11-21 22:41:22 +00:00
Defame1297 scheduled this pull request to auto merge when all checks succeed 2026-11-21 22:41:26 +00:00
Defame1297 merged commit 6925f49280 into main 2026-11-21 22:44:08 +00:00
Defame1297 deleted branch feat/gitea-role 2026-11-21 22:44:08 +00:00
Sign in to join this conversation.
No Reviewers
2 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: Mortis/Kamino#284