Files
ansible-playbooks/gitea-runner.yaml
T

86 lines
2.4 KiB
YAML

---
- name: Gitea Runner setup
hosts: gitea-runners
vars:
username: matt
docker_add_repo: true
docker_users:
- "{{ username }}"
gitea_instance_url: https://gitea.m5p3nc3r.co.uk
gitea_runner_dir: /srv/gitea-runner
# Names of the old GitHub runner containers previously deployed by
# compscidr.github_runner, to be removed from the target.
github_runner_containers:
- amd64-ryzen7-runner
- arm64-ryzen7-runner
roles:
- role: geerlingguy.docker
become: true
tasks:
- name: Remove old GitHub runner containers
become: true
community.docker.docker_container:
name: "{{ item }}"
state: absent
loop: "{{ github_runner_containers }}"
- name: Remove old GitHub runner data volumes
become: true
community.docker.docker_volume:
name: "{{ item }}-runner-data"
state: absent
loop: "{{ github_runner_containers }}"
- name: Remove old GitHub runner image
become: true
community.docker.docker_image:
name: myoung34/github-runner
tag: latest
state: absent
- name: Create gitea runner directory
become: true
ansible.builtin.file:
path: "{{ gitea_runner_dir }}"
state: directory
owner: "{{ username }}"
group: "{{ username }}"
mode: "0755"
- name: Deploy gitea runner compose file
become: true
ansible.builtin.copy:
dest: "{{ gitea_runner_dir }}/docker-compose.yml"
owner: "{{ username }}"
group: "{{ username }}"
mode: "0600"
content: |
services:
runner:
image: docker.io/gitea/runner:5-dind
container_name: gitea-runner
restart: always
privileged: true
environment:
GITEA_INSTANCE_URL: "{{ gitea_instance_url }}"
GITEA_RUNNER_REGISTRATION_TOKEN: "{{ secrets.GITEA_RUNNER_REGISTRATION_TOKEN }}"
GITEA_RUNNER_NAME: "{{ inventory_hostname }}-runner"
volumes:
- ./data:/data
- runner-docker:/var/lib/docker
volumes:
runner-docker:
- name: Start gitea runner with docker compose
become: true
community.docker.docker_compose_v2:
project_src: "{{ gitea_runner_dir }}"
state: present
remove_orphans: true