Add GitLab runner definition

This commit is contained in:
Jordan Holt 2021-12-13 00:56:42 +00:00
parent 408a3d8ce1
commit 1a04dec6cc
Signed by: jordan
GPG Key ID: B8CFFF61F1CCF520
6 changed files with 88 additions and 3 deletions

View File

@ -1,6 +1,6 @@
# Vimium GitLab # Vimium GitLab
Self hosted [GitLab](https://about.gitlab.com/install) instance on Vimium.com. Deployed on Hetzner Cloud in the Helsinki datacentre. Self hosted [GitLab](https://about.gitlab.com/install) instance on Vimium.com. Deployed on Hetzner Cloud in the Nuremberg datacentre.
## Prerequisites ## Prerequisites
Create an API key in the Hetzner Cloud GUI (Project -> Security -> API Tokens) with the name `gitlab`. This may already be accessible via `pass api/hetzner/gitlab`. Create an API key in the Hetzner Cloud GUI (Project -> Security -> API Tokens) with the name `gitlab`. This may already be accessible via `pass api/hetzner/gitlab`.
@ -47,7 +47,7 @@ Content-Type: application/json
{ {
"name": "gitlab-runner-nbg1-1", "name": "gitlab-runner-nbg1-1",
"server_type": "cx21", "server_type": "cpx11",
"location": "nbg1", "location": "nbg1",
"start_after_create": true, "start_after_create": true,
"image": "debian-10", "image": "debian-10",

View File

@ -1,2 +1,5 @@
[primary] [primary]
116.203.134.10 116.203.134.10
[runners]
94.130.27.216

View File

@ -4,3 +4,9 @@
- vars/primary.yml - vars/primary.yml
roles: roles:
- geerlingguy.gitlab - geerlingguy.gitlab
- hosts: runners
vars_files:
- vars/runner.yml
roles:
- runner

View File

@ -0,0 +1,4 @@
- name: restart_docker
service:
name: docker
state: restarted

View File

@ -0,0 +1,64 @@
- name: Install Docker dependencies
apt:
name: [ 'ca-certificates', 'curl', 'gnupg', 'lsb-release' ]
state: latest
update_cache: yes
- name: Add Docker GPG key
apt_key:
url: https://download.docker.com/linux/debian/gpg
state: present
- name: Add Docker repository
apt_repository:
repo: deb https://download.docker.com/linux/debian buster stable
state: present
- name: Install Docker
apt:
name: [ 'docker-ce', 'docker-ce-cli', 'containerd.io' ]
state: latest
update_cache: yes
- name: Start Docker
service:
name: docker
state: started
enabled: yes
- name: Add GitLab repository
shell:
cmd: curl -L https://packages.gitlab.com/install/repositories/runner/gitlab-runner/script.deb.sh | bash
creates: /etc/apt/sources.list.d/runner_gitlab-runner.list
- name: Pin gitlab-runner package
copy:
dest: /etc/apt/preferences.d/pin-gitlab-runner.pref
content: |
Explanation: Prefer GitLab provided packages over the Debian native ones
Package: gitlab-runner
Pin: origin packages.gitlab.com
Pin-Priority: 1001
- name: Install GitLab Runner
apt:
name: gitlab-runner
state: latest
update_cache: yes
- name: Register runner with GitLab
command:
cmd: >
gitlab-runner register
--non-interactive
--url "https://git.vimium.com"
--executor "docker"
--docker-image alpine:latest
--description "docker-runner"
--tag-list "docker,hetzner"
--run-untagged="true"
--locked="false"
--access-level="not_protected"
--registration-token '{{ gitlab_runner_registration_token }}' && touch /etc/gitlab-runner-registered
creates: /etc/gitlab-runner-registered
no_log: true

8
vars/runner.yml Normal file
View File

@ -0,0 +1,8 @@
$ANSIBLE_VAULT;1.1;AES256
34623334623763356262373535326430666662363435376238383234316334336339633237646438
6363396235616462346537623838386130396230633037370a366264303766376234343539363863
61613832663935653439626265626337373133386132663731313336386430363438303334663662
3439363037626136650a386363396538666539383232373137366134336634623930343166626633
65663736393739623133383039663966653964326633313033626563646162663065373130336366
36363531386265383138303462376665373865663662336461626133623762613161303561383063
383364313233633263363236623333656232