initial commit

This commit is contained in:
Tom
2026-02-11 08:56:31 +01:00
commit 0de4ef20b9
5 changed files with 135 additions and 0 deletions

3
defaults/main.yml Normal file
View File

@@ -0,0 +1,3 @@
---
act_runner_group: act_runner
act_runner_user: act_runner

4
handlers/main.yml Normal file
View File

@@ -0,0 +1,4 @@
---
- name: Systemd_daemon_reload
ansible.builtin.systemd_service:
daemon_reload: true

65
tasks/main.yml Normal file
View File

@@ -0,0 +1,65 @@
---
- name: Create the act_runner group
ansible.builtin.group:
name: "{{ act_runner_group }}"
system: true
- name: Create the gitea user
ansible.builtin.user:
name: "{{ act_runner_user }}"
group: "{{ act_runner_group }}"
home: /home/{{ act_runner_user }}
shell: /bin/bash
password: '*'
system: true
create_home: true
- name: Download the act_runner binary
ansible.builtin.get_url:
url: "{{ act_runner_binary_url }}"
dest: /usr/local/bin/act_runner
checksum: sha256:{{ act_runner_checksum_url }}
- name: Set the permissions of the act_runner binary
ansible.builtin.file:
path: /usr/local/bin/act_runner
owner: root
group: "{{ act_runner_group }}"
mode: '0750'
- name: Add the act_runner user to the docker group
ansible.builtin.user:
name: "{{ act_runner_user }}"
append: true
groups:
- docker
- name: Deploy the act_runner config
ansible.builtin.template:
src: runner.j2
dest: /home/{{ act_runner_user }}/runner.yml
owner: "{{ act_runner_user }}"
group: "{{ act_runner_group }}"
mode: '0640'
- name: Register the runner
ansible.builtin.command:
cmd: act_runner register --no-interactive --instance http://localhost:3000 --token {{ act_runner_registration_token }} --name {{ act_runner_name }} --config /home/{{ act_runner_user }}/runner.yml
creates: /home/{{ act_runner_user }}/.privileged-runner
become_user: "{{ act_runner_user }}"
- name: Deploy the systemd service file
ansible.builtin.template:
src: service.j2
dest: /etc/systemd/system/{{ act_runner_name }}.service
owner: root
group: root
mode: '0644'
notify:
- Systemd_daemon_reload
- name: Enable and start the service
ansible.builtin.systemd_service:
name: "{{ act_runner_name }}.service"
state: started
enabled: true

44
templates/runner.j2 Normal file
View File

@@ -0,0 +1,44 @@
# {{ ansible_managed }}
log:
level: info
runner:
file: {{ act_runner_vars['file'] }}
capacity: 1
envs:
A_TEST_ENV_NAME_1: a_test_env_value_1
A_TEST_ENV_NAME_2: a_test_env_value_2
env_file: .env
timeout: 3h
shutdown_timeout: 0s
insecure: false
fetch_timeout: 5s
fetch_interval: 2s
github_mirror: ''
labels:
{% for label in act_runner_labels %}
- {{ label }}
{% endfor %}
cache:
enabled: true
dir: ""
host: ""
port: 0
external_server: ""
container:
network: ""
privileged: {{ act_runner_vars['privileged'] }}
options:
workdir_parent:
valid_volumes: []
docker_host: ""
force_pull: {{ act_runner_vars['force_pull'] }}
force_rebuild: false
require_docker: false
docker_timeout: 0s
host:
workdir_parent:

19
templates/service.j2 Normal file
View File

@@ -0,0 +1,19 @@
# {{ ansible_managed }}
[Unit]
Description={{ act_runner_name }}
Documentation=https://gitea.com/gitea/act_runner
After=docker.service
After=gitea.service
[Service]
ExecStart=/usr/local/bin/act_runner daemon --config /home/{{ act_runner_user }}/runner.yml
ExecReload=/bin/kill -s HUP $MAINPID
WorkingDirectory=/home/{{ act_runner_user }}/
TimeoutSec=0
RestartSec=10
Restart=always
User={{ act_runner_user }}
[Install]
WantedBy=multi-user.target