146 lines
7.0 KiB
YAML
146 lines
7.0 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"
|
|
- "'GITEA-ACTIONS-TASK' in prune_service.content | b64decode"
|
|
- "(gitea_runner_cleanup_script_path ~ ' --tier routine') in prune_service.content | b64decode"
|
|
fail_msg: "Prune service template is missing expected directives"
|
|
|
|
- name: Read rendered cleanup script
|
|
ansible.builtin.slurp:
|
|
src: "{{ gitea_runner_cleanup_script_path }}"
|
|
register: cleanup_script
|
|
|
|
- name: Assert cleanup script honors leases and tiers
|
|
ansible.builtin.assert:
|
|
that:
|
|
- "'org.oblachno.lease-until' in cleanup_script.content | b64decode"
|
|
- "'lease_active' in cleanup_script.content | b64decode"
|
|
- "'GITEA-ACTIONS-TASK' in cleanup_script.content | b64decode"
|
|
- "'runner-images/' in cleanup_script.content | b64decode"
|
|
- "'docker image inspect' in cleanup_script.content | b64decode"
|
|
- "'label!=' in cleanup_script.content | b64decode"
|
|
- "'docker system prune' not in cleanup_script.content | b64decode"
|
|
- "'critical)' in cleanup_script.content | b64decode"
|
|
fail_msg: "Cleanup script template is missing expected content"
|
|
|
|
- name: Read rendered runner config
|
|
ansible.builtin.slurp:
|
|
src: "{{ gitea_runner_config_dir }}/config.yaml"
|
|
register: runner_config
|
|
|
|
- name: Assert runner config declares capacity
|
|
ansible.builtin.assert:
|
|
that:
|
|
- "('capacity: ' ~ gitea_runner_capacity) in runner_config.content | b64decode"
|
|
fail_msg: "Runner config is missing capacity declaration"
|
|
|
|
- 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"
|
|
- "'timeout 10 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 rm -f' in healthcheck_script.content | b64decode"
|
|
- "'GITEA-ACTIONS-TASK' in healthcheck_script.content | b64decode"
|
|
- "'--tier critical' in healthcheck_script.content | b64decode"
|
|
- "'--tier pressure' in healthcheck_script.content | b64decode"
|
|
- "'disk-admission-block' in healthcheck_script.content | b64decode"
|
|
- "'systemctl --user stop gitea-runner.service' in healthcheck_script.content | b64decode"
|
|
- "'docker system prune' not in healthcheck_script.content | b64decode"
|
|
- "'status=removing' in healthcheck_script.content | b64decode"
|
|
- "'status=stopping' in healthcheck_script.content | b64decode"
|
|
- "gitea_runner_healthcheck_disk_threshold | string in healthcheck_script.content | b64decode"
|
|
- "gitea_runner_healthcheck_disk_critical | string in healthcheck_script.content | b64decode"
|
|
fail_msg: "Healthcheck script template is missing expected content"
|