2020-08-09 06:20:33 +00:00
|
|
|
---
|
2023-07-07 07:18:18 +00:00
|
|
|
- name: Add gpg key
|
2022-04-07 13:15:48 +00:00
|
|
|
ansible.builtin.apt_key:
|
2020-08-09 06:20:33 +00:00
|
|
|
url: https://packages.gitlab.com/runner/gitlab-runner/gpgkey
|
|
|
|
tags: gitlab-runner
|
|
|
|
|
2023-07-07 07:18:18 +00:00
|
|
|
- name: Add repository
|
2022-04-07 13:15:48 +00:00
|
|
|
ansible.builtin.apt_repository:
|
2023-07-07 07:26:22 +00:00
|
|
|
repo: "{{ gitlab_runner_repository }}"
|
2020-08-09 06:20:33 +00:00
|
|
|
tags: gitlab-runner
|
|
|
|
|
2023-07-07 07:18:18 +00:00
|
|
|
- name: Install package
|
2022-04-07 13:15:48 +00:00
|
|
|
ansible.builtin.package:
|
|
|
|
name:
|
|
|
|
- gitlab-runner
|
2020-08-09 06:20:33 +00:00
|
|
|
environment:
|
2023-07-07 07:26:22 +00:00
|
|
|
GITLAB_RUNNER_DISABLE_SKEL: "true"
|
2020-08-09 06:20:33 +00:00
|
|
|
tags: gitlab-runner
|
|
|
|
|
2023-07-07 07:18:18 +00:00
|
|
|
- name: Create system directory
|
2022-05-10 08:40:42 +00:00
|
|
|
ansible.builtin.file:
|
|
|
|
path: /etc/systemd/system/gitlab-runner.service.d
|
|
|
|
owner: root
|
|
|
|
group: root
|
|
|
|
mode: 0755
|
|
|
|
state: directory
|
|
|
|
tags: gitlab-runner
|
|
|
|
|
2023-07-07 07:18:18 +00:00
|
|
|
- name: Add environment variables
|
2022-05-10 08:40:42 +00:00
|
|
|
ansible.builtin.template:
|
|
|
|
src: environment.conf.j2
|
|
|
|
dest: /etc/systemd/system/gitlab-runner.service.d/ansible.conf
|
|
|
|
owner: root
|
|
|
|
group: root
|
|
|
|
mode: 0644
|
2023-07-07 07:26:22 +00:00
|
|
|
notify: Restart gitlab-runner
|
2022-05-10 08:40:42 +00:00
|
|
|
tags: gitlab-runner
|
|
|
|
|
2023-07-07 07:18:18 +00:00
|
|
|
- name: Register runners
|
2022-04-07 13:20:10 +00:00
|
|
|
gitlab_runner:
|
2023-07-07 07:26:22 +00:00
|
|
|
name: "{{ item.name }}"
|
|
|
|
url: "{{ item.url }}"
|
|
|
|
token: "{{ item.token }}"
|
|
|
|
executor: "{{ item.executor }}"
|
|
|
|
options: "{{ item.options | default({}) }}"
|
|
|
|
state: "{{ item.state | default('present') }}"
|
|
|
|
loop: "{{ gitlab_runner_runners }}"
|
2020-08-09 06:20:33 +00:00
|
|
|
loop_control:
|
2023-07-07 07:26:22 +00:00
|
|
|
label: "{{ item.name }}"
|
2020-08-09 06:20:33 +00:00
|
|
|
tags: gitlab-runner
|
|
|
|
|
2023-07-07 07:18:18 +00:00
|
|
|
- name: Enable and start service
|
2022-04-07 13:15:48 +00:00
|
|
|
ansible.builtin.service:
|
2020-08-09 06:20:33 +00:00
|
|
|
name: gitlab-runner
|
|
|
|
state: started
|
|
|
|
enabled: true
|
|
|
|
tags: gitlab-runner
|