: install act_runner for gitea

This commit is contained in:
VC
2025-02-28 15:39:53 +01:00
parent 482371b498
commit e889260e12
10 changed files with 134 additions and 0 deletions

View File

@@ -2,6 +2,7 @@
web_hostname: web_hostname:
- host: giteu.be - host: giteu.be
type: gitea
gitea_pg_password: !vault | gitea_pg_password: !vault |
$ANSIBLE_VAULT;1.1;AES256 $ANSIBLE_VAULT;1.1;AES256

View File

@@ -99,6 +99,10 @@ giteaservers:
hosts: hosts:
git1.dmz.mateu.be: git1.dmz.mateu.be:
actrunnerservers:
hosts:
git1.dmz.mateu.be:
mastodonservers: mastodonservers:
hosts: hosts:
masto1.dmz.mateu.be: masto1.dmz.mateu.be:

View File

@@ -5,3 +5,10 @@
diff: true diff: true
roles: roles:
- gitea - gitea
- name: Install act_runner
hosts: actrunnerservers
diff: true
roles:
- docker
- act_runner

View File

@@ -0,0 +1,8 @@
---
- name: Restart Act_Runner
ansible.builtin.systemd:
name: act_runner
state: restarted
enabled: true
daemon_reload: true

View File

@@ -0,0 +1,40 @@
---
- name: Create act_runner user
ansible.builtin.user:
name: "{{ act_runner_user }}"
state: present
system: true
create_home: true
home: "{{ act_runner_home }}"
groups:
- docker
- name: Download act_runner executable
ansible.builtin.get_url:
url: "{{ act_runner_url }}"
dest: "{{ act_runner_bin }}"
owner: root
group: root
mode: "0o755"
force: true
notify:
- Restart Act_Runner
- name: Put systemd service file
ansible.builtin.template:
src: "act_runner.service.j2"
dest: "/etc/systemd/system/act_runner.service"
owner: root
group: root
mode: "0o755"
notify:
- Restart Act_Runner
- name: Register act_runner
become: true
become_user: "{{ act_runner_user }}"
ansible.builtin.command:
cmd: "{{ act_runner_bin }} register --no-interactive --instance https://giteu.be --token {{ _gitea_runner_token.stdout }}"
chdir: "{{ act_runner_home }}"
creates: "{{ act_runner_home }}/.runner"

View File

@@ -0,0 +1,16 @@
[Unit]
Description=Gitea Actions runner
Documentation=https://gitea.com/gitea/act_runner
After=docker.service
[Service]
ExecStart={{ act_runner_bin }} daemon
ExecReload=/bin/kill -s HUP $MAINPID
WorkingDirectory={{ act_runner_home }}
TimeoutSec=0
RestartSec=10
Restart=always
User={{ act_runner_user }}
[Install]
WantedBy=multi-user.target

View File

@@ -0,0 +1,7 @@
---
act_runner_version: "0.2.11"
act_runner_url: "https://gitea.com/gitea/act_runner/releases/download/v{{ act_runner_version }}/act_runner-{{ act_runner_version }}-linux-amd64"
act_runner_home: "/var/lib/act_runner"
act_runner_bin: "/usr/local/bin/act_runner"
act_runner_user: "act_runner"

View File

@@ -0,0 +1,39 @@
---
- name: Install prerequired packages
ansible.builtin.package:
name: fuse-overlayfs
state: present
update_cache: true
- name: Download gpg key
ansible.builtin.get_url:
url: "{{ docker_key_url }}"
dest: "{{ docker_key_path }}"
owner: root
group: root
mode: "0o644"
- name: Set docker source repo
ansible.builtin.copy:
content: "deb [arch=amd64 signed-by={{ docker_key_path }}] https://download.docker.com/linux/debian {{ ansible_distribution_release }} stable"
dest: /etc/apt/sources.list.d/docker.list
mode: "0o644"
- name: Install docker packages
ansible.builtin.package:
name:
- docker-ce
- docker-ce-cli
- containerd.io
- docker-buildx-plugin
- docker-compose-plugin
state: present
update_cache: true
- name: Ensure docker is started
ansible.builtin.systemd:
name: docker
state: started
enabled: true
daemon_reload: true

View File

@@ -0,0 +1,4 @@
---
docker_key_url: "https://download.docker.com/linux/debian/gpg"
docker_key_path: "/etc/apt/keyrings/docker.asc"

View File

@@ -76,3 +76,11 @@
mode: "0o640" mode: "0o640"
notify: notify:
- Restart Gitea - Restart Gitea
- name: Retrieve Gitea Act Runner Token
become: true
become_user: git
ansible.builtin.command:
cmd: "gitea --config {{ gitea_etc_path }}/app.ini actions generate-runner-token"
register: _gitea_runner_token
changed_when: false