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
95 lines
3.6 KiB
YAML
95 lines
3.6 KiB
YAML
---
|
|
- name: Require a plain gitea_version
|
|
ansible.builtin.assert:
|
|
that:
|
|
- gitea_version is string
|
|
- gitea_version is match('^[0-9]+\\.[0-9]+\\.[0-9]+$')
|
|
fail_msg: >-
|
|
gitea_version must be a plain release number such as 1.24.6, with no leading v: it is
|
|
used in the download URL and compared with what the binary reports.
|
|
quiet: true
|
|
tags: [gitea, always]
|
|
|
|
- name: Require gitea_jwt_secret
|
|
ansible.builtin.assert:
|
|
that:
|
|
- gitea_jwt_secret is defined
|
|
- gitea_jwt_secret | length > 0
|
|
fail_msg: >-
|
|
gitea_jwt_secret has no role default and must be set and non-empty. Map it from a
|
|
vaulted variable in group_vars or host_vars.
|
|
quiet: true
|
|
tags: [gitea, always]
|
|
|
|
# The values land in app.ini: a newline would inject INI keys, and PASSWD is
|
|
# backtick-quoted so it may hold ; and #, but not a backtick.
|
|
- name: Require the mailer settings when the mailer is enabled
|
|
ansible.builtin.assert:
|
|
that:
|
|
- gitea_mailer_protocol in ['smtp', 'smtps', 'smtp+starttls']
|
|
- gitea_default_email_notifications in ['enabled', 'onmention', 'disabled']
|
|
- gitea_mailer_smtp_addr | default('', true) | string | length > 0
|
|
- gitea_mailer_from | default('', true) | string | length > 0
|
|
- gitea_mailer_user | default('', true) | string | length > 0
|
|
- gitea_mailer_passwd | default('', true) | string | length > 0
|
|
- "'`' not in (gitea_mailer_passwd | string)"
|
|
- >-
|
|
(gitea_mailer_smtp_addr ~ gitea_mailer_from ~ gitea_mailer_user ~ gitea_mailer_passwd ~ gitea_mailer_subject_prefix)
|
|
is not search('[\\r\\n]')
|
|
fail_msg: >-
|
|
gitea_mailer_enabled is true, so gitea_mailer_smtp_addr, gitea_mailer_from, gitea_mailer_user and
|
|
gitea_mailer_passwd (vaulted) must be set and free of newlines, gitea_mailer_passwd must not contain a
|
|
backtick, gitea_mailer_protocol must be smtp, smtps or smtp+starttls, and
|
|
gitea_default_email_notifications must be enabled, onmention or disabled.
|
|
quiet: true
|
|
no_log: true
|
|
when: gitea_mailer_enabled | bool
|
|
tags: [gitea, always]
|
|
|
|
- name: Require the mailer for e-mail confirmation
|
|
ansible.builtin.assert:
|
|
that:
|
|
- gitea_mailer_enabled | bool
|
|
fail_msg: >-
|
|
gitea_register_email_confirm is true but gitea_mailer_enabled is false: Gitea could not send the
|
|
confirmation link. Enable the mailer or turn confirmation off.
|
|
quiet: true
|
|
when: gitea_register_email_confirm | bool
|
|
tags: [gitea, always]
|
|
|
|
- name: Remove Gitea (explicit only)
|
|
ansible.builtin.include_tasks: remove.yml
|
|
when: gitea_remove | default(false) | bool
|
|
tags: [gitea, remove]
|
|
|
|
- name: Include prerequisites
|
|
ansible.builtin.include_tasks: prereqs.yml
|
|
when: not (gitea_remove | default(false) | bool)
|
|
tags: [gitea, prereqs, always]
|
|
|
|
- name: Install Gitea if missing
|
|
ansible.builtin.include_tasks: install.yml
|
|
when:
|
|
- not (gitea_remove | default(false) | bool)
|
|
- not gitea_installed
|
|
tags: [gitea, install]
|
|
|
|
- name: Configure Gitea
|
|
ansible.builtin.include_tasks: configure.yml
|
|
when: not (gitea_remove | default(false) | bool)
|
|
tags: [gitea, configure, health]
|
|
|
|
- name: Ensure Gitea is up-to-date
|
|
ansible.builtin.include_tasks: update.yml
|
|
when:
|
|
- gitea_update | bool
|
|
- not (gitea_remove | default(false) | bool)
|
|
tags: [gitea, update]
|
|
|
|
# A play may run further roles after this one without force_handlers: a later
|
|
# failure would drop the app.ini restart, and the unchanged template would never
|
|
# re-notify it on the next run.
|
|
- name: Flush Gitea handlers
|
|
ansible.builtin.meta: flush_handlers
|
|
tags: [gitea, configure, health]
|