Copied from the maintainer's local role and reworked for the Collection: the binary swap and rollback of an update go through the internal _binary_update role, input checks move to tasks/validate.yml, the removal ends the role, commands take argv, and the molecule tooling needs an explicit collections requirements file. Adds a molecule scenario with stub Docker, runner and release files. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01MmzvM9skAvYcph2c9EiPcm
93 lines
2.5 KiB
YAML
93 lines
2.5 KiB
YAML
---
|
|
- name: Deploy runner config
|
|
become: true
|
|
ansible.builtin.template:
|
|
src: config.yaml.j2
|
|
dest: "{{ gitea_runner_work_dir }}/config.yaml"
|
|
owner: "{{ gitea_runner_user }}"
|
|
group: "{{ gitea_runner_group }}"
|
|
mode: "0644"
|
|
notify: Restart Gitea Runner
|
|
tags: [gitea_runner, configure]
|
|
|
|
- name: Ensure runner workdir ownership
|
|
become: true
|
|
ansible.builtin.file:
|
|
path: "{{ gitea_runner_work_dir }}"
|
|
owner: "{{ gitea_runner_user }}"
|
|
group: "{{ gitea_runner_group }}"
|
|
recurse: true
|
|
tags: [gitea_runner, configure]
|
|
|
|
- name: Check current runner registration file state
|
|
# become: the work dir is 0750 gitea_runner_user, unreadable when ansible_user is another
|
|
# account.
|
|
become: true
|
|
ansible.builtin.stat:
|
|
path: "{{ gitea_runner_work_dir }}/.runner"
|
|
register: gitea_runner_file_state
|
|
tags: [gitea_runner, configure]
|
|
|
|
- name: Restrict runner registration file permissions
|
|
become: true
|
|
ansible.builtin.file:
|
|
path: "{{ gitea_runner_work_dir }}/.runner"
|
|
mode: "0600"
|
|
when: gitea_runner_file_state.stat.exists
|
|
tags: [gitea_runner, configure]
|
|
|
|
- name: Create systemd service
|
|
become: true
|
|
ansible.builtin.copy:
|
|
dest: "{{ gitea_runner_service_unit }}"
|
|
owner: root
|
|
group: root
|
|
mode: "0644"
|
|
content: |
|
|
[Unit]
|
|
Description=Gitea Actions Runner
|
|
After=network.target docker.service
|
|
Requires=docker.service
|
|
|
|
[Service]
|
|
User={{ gitea_runner_user }}
|
|
Group={{ gitea_runner_group }}
|
|
WorkingDirectory={{ gitea_runner_work_dir }}
|
|
ExecStart={{ gitea_runner_install_dir }}/gitea-runner daemon \
|
|
--config {{ gitea_runner_work_dir }}/config.yaml
|
|
Restart=always
|
|
RestartSec=5
|
|
TimeoutStopSec=300
|
|
KillSignal=SIGTERM
|
|
|
|
[Install]
|
|
WantedBy=multi-user.target
|
|
tags: [gitea_runner, configure]
|
|
|
|
- name: Reload systemd
|
|
become: true
|
|
ansible.builtin.systemd:
|
|
daemon_reload: true
|
|
tags: [gitea_runner, configure]
|
|
|
|
- name: Ensure runner is enabled and running
|
|
become: true
|
|
ansible.builtin.systemd:
|
|
name: gitea-runner
|
|
enabled: true
|
|
state: started
|
|
tags: [gitea_runner, configure]
|
|
|
|
- name: Check runner service status
|
|
become: true
|
|
ansible.builtin.systemd:
|
|
name: gitea-runner
|
|
register: gitea_runner_service_status
|
|
tags: [gitea_runner, configure, health]
|
|
|
|
- name: Fail if runner service is not running
|
|
ansible.builtin.fail:
|
|
msg: "Gitea runner service is not running"
|
|
when: gitea_runner_service_status.status.ActiveState != "active"
|
|
tags: [gitea_runner, configure, health]
|