--- - 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]