ansible-role-gitlab_runner/tasks/main.yml

58 lines
1.4 KiB
YAML
Raw Normal View History

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:
2020-08-09 06:20:33 +00:00
repo: '{{ gitlab_runner_repository }}'
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:
GITLAB_RUNNER_DISABLE_SKEL: 'true'
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
notify: restart gitlab-runner
tags: gitlab-runner
2023-07-07 07:18:18 +00:00
- name: Register runners
2022-04-07 13:20:10 +00:00
gitlab_runner:
2020-08-09 06:20:33 +00:00
name: '{{ item.name }}'
url: '{{ item.url }}'
token: '{{ item.token }}'
executor: '{{ item.executor }}'
2023-07-07 07:18:18 +00:00
options: '{{ item.options | default({}) }}'
state: '{{ item.state | default("present") }}'
2020-08-09 06:20:33 +00:00
loop: '{{ gitlab_runner_runners }}'
loop_control:
label: '{{ item.name }}'
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