Files
grm/ansible/roles/gitea_runner/molecule/template-content/verify.yml
T
Emil Simeonov 7215a59412
CI / validate (pull_request) Failing after 18s
CI / molecule-tests (1) (pull_request) Skipped
CI / molecule-tests (2) (pull_request) Skipped
CI / molecule-tests (3) (pull_request) Skipped
CI / molecule-tests (4) (pull_request) Skipped
CI / molecule-tests (5) (pull_request) Skipped
CI / molecule-tests (6) (pull_request) Skipped
CI / auto-merge (pull_request) Skipped
fix: healthcheck prune keeps tagged runner images
The healthcheck script used 'docker image prune -af' which removes ALL
unused images including tagged ones like ci-full:latest. When disk usage
hit 85%, the healthcheck would delete the ci-full image, causing the next
CI run to fail with 'No such image'.

Fix: use 'docker image prune -f' (dangling only) and 'docker system prune -f'
(without -a) to preserve tagged images. Also fix 'docker volume prune -f'
(without -a) for consistency.
2026-08-04 14:09:47 +02:00

119 lines
5.5 KiB
YAML

---
- name: Verify
hosts: all
become: true
vars:
gitea_runner_name: "template-test-runner"
pre_tasks:
- name: Load role defaults
ansible.builtin.include_vars:
dir: "{{ lookup('env', 'MOLECULE_PROJECT_DIRECTORY') }}/defaults"
tasks:
- name: Check systemd user service exists
ansible.builtin.stat:
path: "{{ gitea_runner_home }}/.config/systemd/user/gitea-runner.service"
register: service_stat
- name: Assert user service exists
ansible.builtin.assert:
that:
- service_stat.stat.exists
fail_msg: "Systemd user service is missing"
- name: Read rendered user service template
ansible.builtin.slurp:
src: "{{ gitea_runner_home }}/.config/systemd/user/gitea-runner.service"
register: service_template
- name: Assert user service template contains expected directives
ansible.builtin.assert:
that:
- "'Type=simple' in service_template.content | b64decode"
- "'ExecStart={{ gitea_runner_binary_path }}' in service_template.content | b64decode"
- "'Restart=always' in service_template.content | b64decode"
- "'Requires=docker.service' in service_template.content | b64decode"
- "'PartOf=docker.service' in service_template.content | b64decode"
- "'StartLimitBurst=10' in service_template.content | b64decode"
- "'DOCKER_HOST=unix:///run/user' in service_template.content | b64decode"
- "'XDG_RUNTIME_DIR=/run/user' in service_template.content | b64decode"
fail_msg: "User service template is missing expected directives"
- name: Read rendered prune service template
ansible.builtin.slurp:
src: "{{ gitea_runner_home }}/.config/systemd/user/docker-prune.service"
register: prune_service
- name: Assert prune service contains expected directives
ansible.builtin.assert:
that:
- "'Type=oneshot' in prune_service.content | b64decode"
- "'docker system prune' in prune_service.content | b64decode"
- "'docker volume prune' in prune_service.content | b64decode"
fail_msg: "Prune service template is missing expected directives"
- name: Read rendered prune timer template
ansible.builtin.slurp:
src: "{{ gitea_runner_home }}/.config/systemd/user/docker-prune.timer"
register: prune_timer
- name: Assert prune timer contains expected directives
ansible.builtin.assert:
that:
- "'OnCalendar={{ gitea_runner_prune_schedule }}' in prune_timer.content | b64decode"
- "'Persistent=true' in prune_timer.content | b64decode"
fail_msg: "Prune timer template is missing expected directives"
- name: Read rendered healthcheck service template
ansible.builtin.slurp:
src: "{{ gitea_runner_home }}/.config/systemd/user/runner-healthcheck.service"
register: healthcheck_service
- name: Assert healthcheck service contains expected directives
ansible.builtin.assert:
that:
- "'Type=oneshot' in healthcheck_service.content | b64decode"
- "'ExecStart={{ gitea_runner_healthcheck_script_path }}' in healthcheck_service.content | b64decode"
- "'DOCKER_HOST=unix:///run/user/' in healthcheck_service.content | b64decode"
- "'XDG_RUNTIME_DIR=/run/user/' in healthcheck_service.content | b64decode"
fail_msg: "Healthcheck service template is missing expected directives"
- name: Read rendered healthcheck timer template
ansible.builtin.slurp:
src: "{{ gitea_runner_home }}/.config/systemd/user/runner-healthcheck.timer"
register: healthcheck_timer
- name: Assert healthcheck timer contains expected directives
ansible.builtin.assert:
that:
- "'OnBootSec={{ gitea_runner_healthcheck_boot_delay }}' in healthcheck_timer.content | b64decode"
- "'OnUnitActiveSec={{ gitea_runner_healthcheck_interval }}' in healthcheck_timer.content | b64decode"
- "'Persistent=true' in healthcheck_timer.content | b64decode"
fail_msg: "Healthcheck timer template is missing expected directives"
- name: Read rendered healthcheck script
ansible.builtin.slurp:
src: "{{ gitea_runner_healthcheck_script_path }}"
register: healthcheck_script
- name: Assert healthcheck script contains expected content
ansible.builtin.assert:
that:
- "'docker info' in healthcheck_script.content | b64decode"
- "'systemctl --user restart docker.service' in healthcheck_script.content | b64decode"
- "'systemctl --user restart gitea-runner.service' in healthcheck_script.content | b64decode"
- "'docker system prune' in healthcheck_script.content | b64decode"
- "gitea_runner_healthcheck_disk_threshold | string in healthcheck_script.content | b64decode"
fail_msg: "Healthcheck script template is missing expected content"
- name: Assert healthcheck script does NOT use aggressive prune (-af)
ansible.builtin.assert:
that:
- "'prune -af' not in healthcheck_script.content | b64decode"
- "'image prune -af' not in healthcheck_script.content | b64decode"
- "'system prune -af' not in healthcheck_script.content | b64decode"
- "'volume prune -af' not in healthcheck_script.content | b64decode"
fail_msg: >-
Healthcheck script uses 'prune -af' which removes ALL images
(including tagged runner images like ci-full). Use 'prune -f'
(dangling only) to preserve tagged images.