78 lines
2 KiB
YAML
78 lines
2 KiB
YAML
|
---
|
||
|
- name: install dependency
|
||
|
ansible.builtin.package:
|
||
|
name:
|
||
|
- docker.io
|
||
|
tags: forgejo-runner
|
||
|
|
||
|
- name: Create group
|
||
|
ansible.builtin.group:
|
||
|
name: forgejo-runner
|
||
|
tags: forgejo-runner
|
||
|
|
||
|
- name: Create user
|
||
|
ansible.builtin.user:
|
||
|
name: forgejo-runner
|
||
|
group: forgejo-runner
|
||
|
groups: docker
|
||
|
shell: /bin/nologin
|
||
|
home: /opt/forgejo-runner
|
||
|
tags: forgejo-runner
|
||
|
|
||
|
- name: Download binary
|
||
|
ansible.builtin.get_url:
|
||
|
url: >-
|
||
|
https://code.forgejo.org/forgejo/runner/releases/download/v{{ forgejo_runner_version
|
||
|
}}/forgejo-runner-{{ forgejo_runner_version
|
||
|
}}-linux-{{ forgejo_runner_arch }}
|
||
|
dest: /usr/local/bin/forgejo-runner
|
||
|
owner: root
|
||
|
group: root
|
||
|
mode: "0755"
|
||
|
checksum: "{{ forgejo_runner_binary_checksum }}"
|
||
|
tags: forgejo-runner
|
||
|
|
||
|
- name: Copy config
|
||
|
ansible.builtin.copy:
|
||
|
content: "{{ forgejo_runner_full_config | to_nice_yaml }}"
|
||
|
dest: /etc/forgejo-runner.yml
|
||
|
owner: root
|
||
|
group: root
|
||
|
mode: "0644"
|
||
|
notify: Restart forgejo-runner
|
||
|
tags: forgejo-runner
|
||
|
|
||
|
- name: Check if register file exists
|
||
|
ansible.builtin.stat:
|
||
|
path: /opt/forgejo-runner/.runner
|
||
|
register: st
|
||
|
tags: forgejo-runner
|
||
|
|
||
|
- name: Register the runner
|
||
|
ansible.builtin.command: >-
|
||
|
forgejo-runner register --no-interactive
|
||
|
--token {{ forgejo_runner_instance_token }} --name {{ forgejo_runner_name }}
|
||
|
--instance {{ forgejo_runner_instance_url }} --config /etc/forgejo-runner.yml
|
||
|
become: true
|
||
|
become_user: forgejo-runner
|
||
|
when: not st.stat.exists # noqa no-changed-when
|
||
|
tags: forgejo-runner
|
||
|
|
||
|
- name: Copy systemd unit
|
||
|
ansible.builtin.template:
|
||
|
src: forgejo-runner.service.j2
|
||
|
dest: /lib/systemd/system/forgejo-runner.service
|
||
|
owner: root
|
||
|
group: root
|
||
|
mode: "0644"
|
||
|
notify: Restart forgejo-runner
|
||
|
tags: forgejo-runner
|
||
|
|
||
|
- name: Enable and start service
|
||
|
ansible.builtin.service:
|
||
|
name: forgejo-runner
|
||
|
state: started
|
||
|
enabled: true
|
||
|
daemon_reload: true
|
||
|
tags: forgejo-runner
|