Files
grm/ansible/roles/gitea-runner/molecule/template-content/verify.yml
T
Emil Simeonov 129cfe3c79
CI / lint (push) Has been cancelled
CI / unit-tests (push) Has been cancelled
CI / molecule-tests (push) Has been cancelled
GRM-20: fix molecule idempotence with mode-specific systemd templates
2026-06-19 14:12:58 +02:00

86 lines
3.4 KiB
YAML

---
- name: Verify
hosts: all
become: true
pre_tasks:
- name: Load role defaults
ansible.builtin.include_vars:
dir: "{{ lookup('env', 'MOLECULE_PROJECT_DIRECTORY') }}/defaults"
tasks:
- name: Check Docker mode systemd template exists
ansible.builtin.stat:
path: "/etc/systemd/system/gitea-runner-docker@.service"
register: docker_template_stat
- name: Assert Docker mode systemd template exists
ansible.builtin.assert:
that:
- docker_template_stat.stat.exists
fail_msg: "Docker systemd template is missing"
- name: Read rendered Docker systemd template
ansible.builtin.slurp:
src: "/etc/systemd/system/gitea-runner-docker@.service"
register: docker_template
- name: Assert Docker mode template contains expected directives
ansible.builtin.assert:
that:
- "'Type=oneshot' in docker_template.content | b64decode"
- "'RemainAfterExit=yes' in docker_template.content | b64decode"
- "'Requires=docker.service' in docker_template.content | b64decode"
- "'docker run -d' in docker_template.content | b64decode"
- "'ExecStop=/usr/bin/docker stop' in docker_template.content | b64decode"
- "'Restart=on-failure' in docker_template.content | b64decode"
fail_msg: "Docker systemd template is missing expected directives"
- name: Check Binary mode systemd template exists
ansible.builtin.stat:
path: "/etc/systemd/system/gitea-runner-binary@.service"
register: binary_template_stat
- name: Assert Binary mode systemd template exists
ansible.builtin.assert:
that:
- binary_template_stat.stat.exists
fail_msg: "Binary systemd template is missing"
- name: Read rendered Binary systemd template
ansible.builtin.slurp:
src: "/etc/systemd/system/gitea-runner-binary@.service"
register: binary_template
- name: Assert Binary mode template contains expected directives
ansible.builtin.assert:
that:
- "'Type=simple' in binary_template.content | b64decode"
- "'ExecStart={{ gitea_runner_binary_path }}' in binary_template.content | b64decode"
- "'Restart=on-failure' in binary_template.content | b64decode"
fail_msg: "Binary systemd template is missing expected directives"
- name: Read rendered prune service template
ansible.builtin.slurp:
src: "/etc/systemd/system/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"
- "'label=gitea-runner=true' in prune_service.content | b64decode"
fail_msg: "Prune service template is missing expected directives"
- name: Read rendered prune timer template
ansible.builtin.slurp:
src: "/etc/systemd/system/docker-prune.timer"
register: prune_timer
- name: Assert prune timer contains expected directives
ansible.builtin.assert:
that:
- "'OnCalendar=daily' in prune_timer.content | b64decode"
- "'Persistent=true' in prune_timer.content | b64decode"
fail_msg: "Prune timer template is missing expected directives"