forked from bitlair/ansible
Add git-ci role
This commit is contained in:
parent
bc8e27f9a6
commit
45d29d1280
6 changed files with 86 additions and 0 deletions
10
git-ci.yaml
Normal file
10
git-ci.yaml
Normal file
|
@ -0,0 +1,10 @@
|
|||
---
|
||||
- hosts: git-ci
|
||||
roles:
|
||||
- common
|
||||
- common-bitlair
|
||||
- git-ci
|
||||
vars:
|
||||
root_access:
|
||||
- ak
|
||||
- polyfloyd
|
|
@ -17,6 +17,9 @@ all:
|
|||
git:
|
||||
hosts:
|
||||
git.bitlair.nl:
|
||||
git-ci:
|
||||
hosts:
|
||||
2a02:166b:92:1337:5054:ff:fee8:31cd:
|
||||
pad:
|
||||
hosts:
|
||||
pad.bitlair.nl:
|
||||
|
|
2
roles/git-ci/defaults/main.yaml
Normal file
2
roles/git-ci/defaults/main.yaml
Normal file
|
@ -0,0 +1,2 @@
|
|||
runner_wd: /var/lib/forgejo-runner
|
||||
runner_version: 3.4.1
|
7
roles/git-ci/handlers/main.yaml
Normal file
7
roles/git-ci/handlers/main.yaml
Normal file
|
@ -0,0 +1,7 @@
|
|||
---
|
||||
- import_tasks: ../../common/handlers/main.yaml
|
||||
|
||||
- name: restart forgejo-runner
|
||||
systemd:
|
||||
name: forgejo-runner
|
||||
state: restarted
|
50
roles/git-ci/tasks/main.yaml
Normal file
50
roles/git-ci/tasks/main.yaml
Normal file
|
@ -0,0 +1,50 @@
|
|||
---
|
||||
- tags: forgejo_runner
|
||||
block:
|
||||
- name: Install dependencies
|
||||
apt:
|
||||
name: docker.io
|
||||
|
||||
- name: Download forgejo-runner
|
||||
get_url:
|
||||
url: "https://code.forgejo.org/forgejo/runner/releases/download/v{{ runner_version }}/forgejo-runner-{{ runner_version }}-linux-amd64"
|
||||
dest: /usr/local/bin/forgejo-runner
|
||||
mode: 0755
|
||||
notify: restart forgejo-runner
|
||||
|
||||
- name: Create runner dir
|
||||
file:
|
||||
state: directory
|
||||
path: "{{ runner_wd }}"
|
||||
owner: root
|
||||
group: root
|
||||
mode: 0755
|
||||
|
||||
- name: Register runner
|
||||
command: "forgejo-runner register --no-interactive --instance={{ forgejo_url }} --token={{ forgejo_runner_token }}"
|
||||
args:
|
||||
chdir: "{{ runner_wd }}"
|
||||
creates: "{{ runner_wd }}/.runner"
|
||||
|
||||
- name: Install service file
|
||||
template:
|
||||
src: forgejo-runner.service
|
||||
dest: /etc/systemd/system/forgejo-runner.service
|
||||
owner: root
|
||||
group: root
|
||||
mode: 0644
|
||||
notify: restart forgejo-runner
|
||||
|
||||
- name: Enable service
|
||||
systemd:
|
||||
name: forgejo-runner
|
||||
enabled: yes
|
||||
daemon_reload: true
|
||||
|
||||
- name: Start service
|
||||
systemd:
|
||||
name: forgejo-runner
|
||||
state: started
|
||||
daemon_reload: true
|
||||
|
||||
- meta: flush_handlers
|
14
roles/git-ci/templates/forgejo-runner.service
Normal file
14
roles/git-ci/templates/forgejo-runner.service
Normal file
|
@ -0,0 +1,14 @@
|
|||
# {{ ansible_managed }}
|
||||
|
||||
[Unit]
|
||||
Description=Forgejo Runner
|
||||
After=network.target
|
||||
|
||||
[Service]
|
||||
ExecStart=/usr/local/bin/forgejo-runner daemon
|
||||
WorkingDirectory={{ runner_wd }}
|
||||
Restart=on-failure
|
||||
RestartSec=10s
|
||||
|
||||
[Install]
|
||||
WantedBy=multi-user.target
|
Loading…
Add table
Reference in a new issue