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
348 lines
16 KiB
YAML
348 lines
16 KiB
YAML
---
|
|
argument_specs:
|
|
main:
|
|
short_description: Install, configure, update or remove Gitea as a systemd binary
|
|
description:
|
|
- >-
|
|
Optionally removes Gitea (C(gitea_remove)), installs packages and the C(gitea) system user, downloads and
|
|
GPG-verifies the pinned binary on first install, renders C(app.ini), runs C(gitea migrate), creates the admin
|
|
user, writes the systemd unit, passes its firewall rules to the C(mortis.kamino.ufw) role
|
|
(C(tasks_from=service_rules)), deploys the Fail2Ban jail through the C(mortis.kamino.fail2ban) role
|
|
(C(tasks_from=service_jail)) and starts the service. Then it asserts that C(gitea_api_token) is defined (it is
|
|
minted by the C(mint) entry point, never by this one), waits for the local listener and adds C(gitea_ssh_keys)
|
|
to the admin user. Optionally updates the binary (C(gitea_update)) with rollback.
|
|
- >-
|
|
Also reads C(gitea_domain), C(gitea_admin_user), C(gitea_admin_email), C(gitea_admin_password),
|
|
C(gitea_secret_key), C(gitea_internal_token), C(gitea_jwt_secret), C(gitea_ssh_keys), and C(gitea_api_token),
|
|
none of which has a role default. The calling inventory supplies them, the secrets from vaulted variables.
|
|
options:
|
|
gitea_domain:
|
|
type: str
|
|
required: true
|
|
description:
|
|
- >-
|
|
Public host name. Rendered into C(DOMAIN) and C(ROOT_URL) (C(https://<domain>/)) in C(app.ini). No role
|
|
default exists. Supplied by inventory.
|
|
gitea_admin_user:
|
|
type: raw
|
|
required: true
|
|
description:
|
|
- >-
|
|
Username of the admin user created with C(gitea admin user create), and of the account that receives the
|
|
SSH keys and the access token. No role default exists. Supplied by inventory.
|
|
gitea_admin_email:
|
|
type: raw
|
|
required: true
|
|
no_log: true
|
|
description:
|
|
- E-mail address of the admin user. No role default exists. Map it from a vaulted variable.
|
|
gitea_admin_password:
|
|
type: raw
|
|
required: true
|
|
no_log: true
|
|
description:
|
|
- >-
|
|
Password of the admin user, only evaluated when that user does not exist yet. Gitea accepts it only through
|
|
C(--password), so it appears in the argument list of the create command while that runs. No role default
|
|
exists. Map it from a vaulted variable.
|
|
gitea_secret_key:
|
|
type: raw
|
|
required: true
|
|
no_log: true
|
|
description:
|
|
- Written to C(SECRET_KEY) in C(app.ini). No role default exists. Map it from a vaulted variable.
|
|
gitea_internal_token:
|
|
type: raw
|
|
required: true
|
|
no_log: true
|
|
description:
|
|
- Written to C(INTERNAL_TOKEN) in C(app.ini). No role default exists. Map it from a vaulted variable.
|
|
gitea_jwt_secret:
|
|
type: raw
|
|
no_log: true
|
|
description:
|
|
- >-
|
|
Written to C(JWT_SECRET) in the C([oauth2]) section of C(app.ini). No role
|
|
default exists. Map it from a vaulted variable.
|
|
- >-
|
|
Required and asserted non-empty at role start by the tasks (not by this spec), before the remove path,
|
|
so C(gitea_remove=true) needs it defined too.
|
|
gitea_ssh_keys:
|
|
type: raw
|
|
required: true
|
|
description:
|
|
- >-
|
|
List of public key strings added to the admin user through the API. A key that Gitea already holds is
|
|
skipped. No role default exists. Supplied by inventory.
|
|
gitea_api_token:
|
|
type: raw
|
|
no_log: true
|
|
description:
|
|
- >-
|
|
Admin access token used for the SSH key API calls. Asserted defined before the first task that uses it. It
|
|
is created by the C(mint) entry point and persisted by the calling play, after which inventory defines it
|
|
from a vaulted variable. No role default exists.
|
|
gitea_update:
|
|
type: bool
|
|
default: false
|
|
description:
|
|
- >-
|
|
When true the update tasks run after configuration. The installed version is compared with
|
|
C(gitea_version) and only a difference triggers a signature-verified download into a staging directory
|
|
next to the live binary, before anything is stopped. Then follow stop, backup, swap,
|
|
restart and a version check by the internal C(mortis.kamino._binary_update) role, with rollback to the
|
|
backup binary on failure.
|
|
- >-
|
|
The rollback restores the binary only, never the database. Gitea migrates its database when the new
|
|
version starts, so after a failure past that point the previous binary may refuse the newer schema and
|
|
not come back up. Back up the database before an update across releases; if that happens, restore it or
|
|
move forward to C(gitea_version).
|
|
gitea_remove:
|
|
type: bool
|
|
default: false
|
|
description:
|
|
- >-
|
|
When true the service is stopped and disabled, the unit file and the binary are removed, and the
|
|
C(ansible-ufw[gitea:...]) firewall rules are deleted (ufw must be active on the host, or that last task
|
|
fails). Prerequisites, install, configure and update are skipped for this run.
|
|
gitea_remove_data:
|
|
type: bool
|
|
default: false
|
|
description:
|
|
- >-
|
|
Only read while C(gitea_remove) is true. When true C(gitea_app_dir), every directory in C(gitea_data_dirs)
|
|
and the C(gitea_user) account are deleted.
|
|
gitea_version:
|
|
type: str
|
|
description:
|
|
- >-
|
|
Gitea release to install, for example C(28.1.0). The role default is a pinned version, see
|
|
C(defaults/main.yml); pin it in inventory to move it independently of Collection releases.
|
|
- >-
|
|
Asserted at role start to be C(X.Y.Z) digits only, with no leading C(v): it is used in the download URL
|
|
and compared with the version the binary reports.
|
|
gitea_download_url:
|
|
type: raw
|
|
description:
|
|
- >-
|
|
URL of the release binary. The role default is a Jinja expression built from C(gitea_version) that points
|
|
at dl.gitea.com for linux amd64.
|
|
gitea_signature_url:
|
|
type: raw
|
|
description:
|
|
- URL of the detached GPG signature. The role default is C(gitea_download_url) with C(.asc) appended.
|
|
gitea_gpg_key_id:
|
|
type: str
|
|
default: "7C9E68152594688862D62AF62D9AE806EC1592E2"
|
|
description:
|
|
- >-
|
|
Fingerprint of the primary key that signs the release (a signature by one of its subkeys counts). The
|
|
check runs in a throwaway keyring holding only what C(gitea_gpg_key_url) served, and fails unless that
|
|
includes this key and every signature in the file is good and made by it; a signature by an expired or
|
|
revoked key fails too.
|
|
gitea_gpg_key_url:
|
|
type: raw
|
|
description:
|
|
- >-
|
|
URL of the release key, fetched on every download. The role default is the keys.openpgp.org lookup of
|
|
C(gitea_gpg_key_id).
|
|
gitea_user:
|
|
type: str
|
|
default: git
|
|
description:
|
|
- >-
|
|
System user that runs the service and owns the data directories. Another role that runs the C(gitea)
|
|
CLI on this host needs the same value.
|
|
gitea_group:
|
|
type: str
|
|
default: git
|
|
description:
|
|
- Group of the service and of C(app.ini).
|
|
gitea_home:
|
|
type: path
|
|
default: /home/git
|
|
description:
|
|
- Home directory of C(gitea_user).
|
|
gitea_install_dir:
|
|
type: path
|
|
default: /usr/local/bin
|
|
description:
|
|
- >-
|
|
Directory that holds the C(gitea) binary. Another role that runs the C(gitea) CLI on this host needs
|
|
the same value.
|
|
gitea_app_dir:
|
|
type: path
|
|
default: /etc/gitea
|
|
description:
|
|
- >-
|
|
Directory that holds C(app.ini). Another role that runs the C(gitea) CLI on this host needs the same value.
|
|
gitea_data_dirs:
|
|
type: list
|
|
elements: str
|
|
description:
|
|
- >-
|
|
Data directories, created in this order. The index matters: item 0 is C(WORK_PATH), the unit working
|
|
directory and the location of C(gitea.db); item 2 holds the repositories. The role default is
|
|
C(/var/lib/gitea), C(/var/lib/gitea/custom), C(/var/lib/gitea/data) and C(/var/lib/gitea/log).
|
|
gitea_service_unit:
|
|
type: path
|
|
default: /etc/systemd/system/gitea.service
|
|
description:
|
|
- Path of the systemd unit file.
|
|
gitea_http_port:
|
|
type: int
|
|
default: 3000
|
|
description:
|
|
- >-
|
|
TCP port of the Gitea listener. Rendered as C(HTTP_PORT), used in the admin key API URL and in the
|
|
default C(gitea_ufw_service_rules).
|
|
gitea_http_addr:
|
|
type: str
|
|
default: 127.0.0.1
|
|
description:
|
|
- >-
|
|
Address of the Gitea listener. Rendered as C(HTTP_ADDR) and used as the host of the admin key API URL (a wildcard address is replaced
|
|
by loopback, an IPv6 address is bracketed). It does not change the default ufw rules, which stay pinned to loopback.
|
|
gitea_reverse_proxy_limit:
|
|
type: int
|
|
default: 1
|
|
description:
|
|
- >-
|
|
C(REVERSE_PROXY_LIMIT) in C([security]) of C(app.ini): the number of trusted proxy hops in
|
|
C(X-Forwarded-For). The trusted proxies are loopback only. Set it to the real number of proxies in front of
|
|
Gitea; a higher value lets a client forge the address Gitea logs, and so the address Fail2Ban bans.
|
|
gitea_bash_completion_path:
|
|
type: path
|
|
default: /usr/share/bash-completion/completions/gitea
|
|
description:
|
|
- Destination of the generated bash completion script.
|
|
gitea_fail2ban_jail:
|
|
type: dict
|
|
description:
|
|
- >-
|
|
Jail mapping passed as C(fail2ban_service_jail) to the C(mortis.kamino.fail2ban) role. The role default enables a jail
|
|
on ports http and https, filter C(gitea), C(journalmatch) C(_SYSTEMD_UNIT=gitea.service), 5 retries, a 1h
|
|
ban and a 10m window. Overriding replaces the whole mapping.
|
|
gitea_fail2ban_filter:
|
|
type: dict
|
|
description:
|
|
- >-
|
|
Filter mapping passed as C(fail2ban_service_filter) to the C(mortis.kamino.fail2ban) role. The role default has a
|
|
C(failregex) that matches failed authentication attempts and captures the host. Overriding replaces the
|
|
whole mapping.
|
|
gitea_ufw_service_rules:
|
|
type: raw
|
|
description:
|
|
- >-
|
|
Rules the role passes to the C(mortis.kamino.ufw) role as C(ufw_service_rules), owner C(gitea) (entry point
|
|
C(service_rules)). The role default allows C(gitea_http_port) from 127.0.0.1 and ::1 and denies it from
|
|
everywhere else, in that order. Same item schema as C(ufw_service_rules).
|
|
gitea_mailer_enabled:
|
|
type: bool
|
|
default: false
|
|
description:
|
|
- >-
|
|
When true C(app.ini) gets a C([mailer]) section and C(ENABLE_NOTIFY_MAIL = true), and the role asserts at
|
|
start that C(gitea_mailer_smtp_addr), C(gitea_mailer_from), C(gitea_mailer_user) and C(gitea_mailer_passwd)
|
|
are set. When false no C([mailer]) section is rendered and the other C(gitea_mailer_*) variables are not read.
|
|
gitea_mailer_protocol:
|
|
type: str
|
|
default: smtp+starttls
|
|
choices: [smtp, smtps, smtp+starttls]
|
|
description:
|
|
- C(PROTOCOL) of C([mailer]). C(smtp+starttls) for submission on port 587, C(smtps) for implicit TLS on 465.
|
|
gitea_mailer_smtp_addr:
|
|
type: str
|
|
default: ""
|
|
description:
|
|
- C(SMTP_ADDR) of C([mailer]), the SMTP server host name.
|
|
gitea_mailer_smtp_port:
|
|
type: int
|
|
default: 587
|
|
description:
|
|
- C(SMTP_PORT) of C([mailer]).
|
|
gitea_mailer_from:
|
|
type: raw
|
|
default: ""
|
|
description:
|
|
- >-
|
|
C(FROM) of C([mailer]), the sender address, optionally with a display name (C(Gitea <[email protected]>)).
|
|
Providers that authenticate per address only accept the address that belongs to C(gitea_mailer_user).
|
|
gitea_mailer_user:
|
|
type: raw
|
|
default: ""
|
|
no_log: true
|
|
description:
|
|
- C(USER) of C([mailer]), the SMTP login, usually the sender address. Supplied by a vaulted variable.
|
|
gitea_mailer_passwd:
|
|
type: raw
|
|
default: ""
|
|
no_log: true
|
|
description:
|
|
- >-
|
|
C(PASSWD) of C([mailer]), written backtick-quoted, so it may hold C(;) and C(#) but not a backtick. Supplied
|
|
by a vaulted variable. With a provider that issues per-address SMTP tokens, this is that token, not the account password.
|
|
gitea_mailer_subject_prefix:
|
|
type: str
|
|
default: ""
|
|
description:
|
|
- C(SUBJECT_PREFIX) of C([mailer]); omitted when empty.
|
|
gitea_register_email_confirm:
|
|
type: bool
|
|
default: false
|
|
description:
|
|
- >-
|
|
C(REGISTER_EMAIL_CONFIRM) of C([service]): a new account and a newly added e-mail address stay inactive
|
|
until the link mailed to it is followed. Requires C(gitea_mailer_enabled), asserted at role start.
|
|
Accounts created by the admin CLI (the role's admin user) are not affected.
|
|
gitea_default_email_notifications:
|
|
type: str
|
|
default: enabled
|
|
choices: [enabled, onmention, disabled]
|
|
description:
|
|
- >-
|
|
C(DEFAULT_EMAIL_NOTIFICATIONS) of C([admin]), the notification mail setting a new user starts with; each user
|
|
can change their own. Rendered only while C(gitea_mailer_enabled) is true.
|
|
mint:
|
|
short_description: Mint the Gitea admin API token (opt-in, operator only)
|
|
description:
|
|
- >-
|
|
Opt-in entry point (C(tasks_from=mint)), run by hand from an operator play, never from CI. Requires C(gitea_mint_confirm=true)
|
|
and refuses to run when C(GITHUB_ACTIONS), C(GITEA_ACTIONS) or C(CI) is set. Does nothing but report when
|
|
C(gitea_api_token) is already defined and non-empty. Otherwise it runs C(gitea admin user generate-access-token) (name
|
|
C(ansible-provisioning), scope C(all)) and registers the token as the C(no_log) fact C(gitea_minted_api_token).
|
|
The fact is not cacheable, is never printed and is only defined when a token was created. The role writes no
|
|
vault file; persisting the value (for example vault-encrypted into inventory as C(gitea_api_token)) is the
|
|
calling play's job. Gitea shows the token once.
|
|
options:
|
|
gitea_mint_confirm:
|
|
type: bool
|
|
default: false
|
|
description:
|
|
- Must be true, otherwise the entry point fails. Pass it as C(-e gitea_mint_confirm=true).
|
|
gitea_api_token:
|
|
type: raw
|
|
no_log: true
|
|
description:
|
|
- When defined and non-empty nothing is minted; undefined, null and the empty string all count as missing.
|
|
gitea_admin_user:
|
|
type: raw
|
|
required: true
|
|
description:
|
|
- Account the token is created for.
|
|
gitea_user:
|
|
type: str
|
|
default: git
|
|
description:
|
|
- System user that runs the C(gitea) CLI through sudo.
|
|
gitea_install_dir:
|
|
type: path
|
|
default: /usr/local/bin
|
|
description:
|
|
- Directory that holds the C(gitea) binary.
|
|
gitea_app_dir:
|
|
type: path
|
|
default: /etc/gitea
|
|
description:
|
|
- Directory that holds C(app.ini), passed to the CLI as C(--config).
|