From a867df04a56fc8e55abab8224839554d0e29de97 Mon Sep 17 00:00:00 2001 From: Jake Howard Date: Tue, 1 Jun 2021 19:29:21 +0100 Subject: [PATCH] Add a GitLab runner Woo CI! --- ansible/group_vars/all/pve.yml | 2 ++ ansible/hosts | 1 + ansible/main.yml | 5 +++++ ansible/roles/gitlab_runner/files/config.toml | 19 +++++++++++++++++++ ansible/roles/gitlab_runner/handlers/main.yml | 5 +++++ ansible/roles/gitlab_runner/tasks/main.yml | 18 ++++++++++++++++++ ansible/roles/gitlab_runner/vars/main.yml | 7 +++++++ 7 files changed, 57 insertions(+) create mode 100644 ansible/roles/gitlab_runner/files/config.toml create mode 100644 ansible/roles/gitlab_runner/handlers/main.yml create mode 100644 ansible/roles/gitlab_runner/tasks/main.yml create mode 100644 ansible/roles/gitlab_runner/vars/main.yml diff --git a/ansible/group_vars/all/pve.yml b/ansible/group_vars/all/pve.yml index f5c97a1..05fcffe 100644 --- a/ansible/group_vars/all/pve.yml +++ b/ansible/group_vars/all/pve.yml @@ -17,3 +17,5 @@ pve_hosts: ip: 10.23.1.21 gitlab: ip: 10.23.1.43 + gitlab_runner: + ip: 10.23.1.48 diff --git a/ansible/hosts b/ansible/hosts index 02b73f9..22830e2 100644 --- a/ansible/hosts +++ b/ansible/hosts @@ -11,3 +11,4 @@ forrest qbittorrent restic pve-gitlab +pve-gitlab-runner diff --git a/ansible/main.yml b/ansible/main.yml index 93cb991..9501262 100644 --- a/ansible/main.yml +++ b/ansible/main.yml @@ -28,6 +28,7 @@ - pve-docker - forrest - walker + - pve-gitlab-runner roles: - role: geerlingguy.docker become: true @@ -99,3 +100,7 @@ - hosts: pve-gitlab roles: - gitlab + +- hosts: pve-gitlab-runner + roles: + - gitlab_runner diff --git a/ansible/roles/gitlab_runner/files/config.toml b/ansible/roles/gitlab_runner/files/config.toml new file mode 100644 index 0000000..4439488 --- /dev/null +++ b/ansible/roles/gitlab_runner/files/config.toml @@ -0,0 +1,19 @@ +concurrent = {{ ansible_processor_nproc }} +log_level = "warning" +check_interval = 10 + +[session_server] + session_timeout = 1800 + +[[runners]] + name = "runner" + url = "https://code.theorangeone.net" + token = "{{ gitlab_runner_token }}" + limit = 0 + executor = "docker" + + [runners.docker] + image = "alpine" + privileged = false + disable_cache = false + volumes = ["/cache"] diff --git a/ansible/roles/gitlab_runner/handlers/main.yml b/ansible/roles/gitlab_runner/handlers/main.yml new file mode 100644 index 0000000..a4b720d --- /dev/null +++ b/ansible/roles/gitlab_runner/handlers/main.yml @@ -0,0 +1,5 @@ +- name: restart gitlab-runner + service: + name: gitlab-runner + state: restarted + become: true diff --git a/ansible/roles/gitlab_runner/tasks/main.yml b/ansible/roles/gitlab_runner/tasks/main.yml new file mode 100644 index 0000000..df82f02 --- /dev/null +++ b/ansible/roles/gitlab_runner/tasks/main.yml @@ -0,0 +1,18 @@ +- name: Install runner + package: + name: gitlab-runner + become: true + +- name: Install config + template: + src: files/config.toml + dest: /etc/gitlab-runner/config.toml + mode: "0600" + become: true + notify: restart gitlab-runner + +- name: Enable runner + service: + name: gitlab-runner + enabled: true + become: true diff --git a/ansible/roles/gitlab_runner/vars/main.yml b/ansible/roles/gitlab_runner/vars/main.yml new file mode 100644 index 0000000..83ee4e3 --- /dev/null +++ b/ansible/roles/gitlab_runner/vars/main.yml @@ -0,0 +1,7 @@ +gitlab_runner_token: !vault | + $ANSIBLE_VAULT;1.1;AES256 + 65643664363337623138623538363032646330316263626632353233373832313235353939643465 + 3736633363663137653432306465626331653064303736310a313030646266316230396563313834 + 39366638646238303936633961343030623030633034653133376663656263333034373265313764 + 6637373531373262610a323037316336346339616563373933313436633337656634393535333235 + 36653337383864666137323331636136653338313133316265366337646465313533