Files
Kamino/roles/gitea_runner/tasks/validate.yml
T
Defame1297 e91c074373 fix(gitea_runner): address review of the prune count and threshold
Give each new input its own assert message so every refused-input case
matches only its own input, and cover a negative count and a bad disk
check schedule. Fire the pressure prune only above the threshold, as
the inputs describe it. Name the disk check script apart from the
pressure service, prefix the new registers as internal, and keep the
new comments short.

Refs #319

Assisted-by: Claude Code
2026-11-23 18:20:32 +00:00

93 lines
4.2 KiB
YAML

---
# Input checks. Imported first in main.yml with tags: always, so a bad input fails before any
# change, whatever tags the run selects.
- name: Require a plain gitea_runner_version
ansible.builtin.assert:
that:
- gitea_runner_version is string
- gitea_runner_version is match('^[0-9]+\\.[0-9]+\\.[0-9]+$')
fail_msg: >-
gitea_runner_version must be a plain release number such as 6.0.1, with no leading v: it is
used in the download URL and compared with what the binary reports.
quiet: true
# Checks the format only. Together with minting the token first, a malformed scope or a
# failed mint stops the play before a forced re-registration drops .runner.
- name: Require a valid registration scope
ansible.builtin.assert:
that:
- gitea_runner_registration_scope is string
- gitea_runner_registration_scope | length == 0 or gitea_runner_registration_scope is match('^[A-Za-z0-9_.-]+(/[A-Za-z0-9_.-]+)?$')
fail_msg: >-
gitea_runner_registration_scope must be empty (instance-wide), an owner (user or organisation)
or owner/repo, got '{{ gitea_runner_registration_scope }}'.
quiet: true
# The values land in systemd unit files: a newline or % would inject or expand directives.
- name: Validate the Docker prune settings
ansible.builtin.assert:
that:
- gitea_runner_docker_prune_schedule is match('^[A-Za-z0-9 :*,./~-]+$')
- gitea_runner_docker_prune_container_age is match('^[0-9]+[smh]$')
- gitea_runner_docker_prune_image_age is match('^[0-9]+[smh]$')
fail_msg: >-
gitea_runner_docker_prune_schedule must be a plain OnCalendar value (no newline or %),
the two ages a number with s, m or h (e.g. 168h).
quiet: true
when: gitea_runner_docker_prune_enabled | bool
- name: Validate the Docker prune count
ansible.builtin.assert:
that: gitea_runner_docker_prune_keep_per_repository | int >= 0
fail_msg: gitea_runner_docker_prune_keep_per_repository must be 0 (off) or more.
quiet: true
when: gitea_runner_docker_prune_enabled | bool
- name: Validate the Docker prune disk threshold
ansible.builtin.assert:
that:
- gitea_runner_docker_prune_disk_threshold_percent | int >= 0
- gitea_runner_docker_prune_disk_threshold_percent | int <= 99
fail_msg: gitea_runner_docker_prune_disk_threshold_percent must be 0 (off) or 1 to 99.
quiet: true
when: gitea_runner_docker_prune_enabled | bool
# Same character set as the weekly schedule.
- name: Validate the Docker prune disk check schedule
ansible.builtin.assert:
that: gitea_runner_docker_prune_disk_check_schedule is match('^[A-Za-z0-9 :*,./~-]+$')
fail_msg: gitea_runner_docker_prune_disk_check_schedule must be a plain OnCalendar value (no newline or %).
quiet: true
when: gitea_runner_docker_prune_enabled | bool
# A subset of the units Docker accepts for --keep-storage.
- name: Validate the Docker builder keep-storage size
ansible.builtin.assert:
that: gitea_runner_docker_prune_builder_keep_storage is match('^[0-9]+(B|KB|MB|GB|TB)?$')
fail_msg: >-
gitea_runner_docker_prune_builder_keep_storage must be a number with an optional B, KB, MB, GB or TB (e.g. 10GB).
quiet: true
when: gitea_runner_docker_prune_enabled | bool
- name: Require a count for the pressure prune
ansible.builtin.assert:
that: >-
gitea_runner_docker_prune_disk_threshold_percent | int == 0
or gitea_runner_docker_prune_keep_per_repository | int > 0
fail_msg: >-
gitea_runner_docker_prune_disk_threshold_percent needs gitea_runner_docker_prune_keep_per_repository above 0:
the pressure prune removes images by that count.
quiet: true
when: gitea_runner_docker_prune_enabled | bool
- name: Require the collections requirements file for the molecule tooling
ansible.builtin.assert:
that:
- gitea_runner_collections_requirements_file is string
- gitea_runner_collections_requirements_file | length > 0
fail_msg: >-
gitea_runner_molecule_enabled is true, so gitea_runner_collections_requirements_file must name
the collections requirements file on the control host that the molecule install reads.
quiet: true
when: gitea_runner_molecule_enabled | bool