-
Notifications
You must be signed in to change notification settings - Fork 1
/
main.yml
54 lines (49 loc) · 1.96 KB
/
main.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
# based on official docs
# https://docs.gitlab.com/runner/install/linux-manually.html
# https://docs.gitlab.com/runner/register/index.html
- name: Add gitlab-runner user
user:
name: gitlab-runner
state: present
shell: /bin/bash
groups: docker
createhome: yes
comment: "Gitlab Runner node"
# salted gitlab_runner_user_pwd with `mkpasswd --method=sha-512`
password: '$6$Vwnnb1h.oCcWSdb$xfVs707VVgVLNHE2CQ022uhfUcFWP5HcQJxqnJMVroW69HjTcpMWu7LtS7Rrt7dEsROtdsUpVzJQkHEq6gSNu0'
- name: download gitlab-runner package
get_url:
url: https://gitlab-runner-downloads.s3.amazonaws.com/{{gitlab_runner_version}}/binaries/gitlab-runner-linux-amd64
dest: /tmp/gitlab-runner-linux-amd64-{{gitlab_runner_version}}
owner: gitlab-runner
- name: uninstall existing gitlab-runner service
shell: |
set +e
/usr/local/bin/gitlab-runner unregister --name {{gitlab_ci_runner_name}}
/usr/local/bin/gitlab-runner stop
/usr/local/bin/gitlab-runner uninstall
/usr/local/bin/gitlab-runner status
set -e
rm /usr/local/bin/gitlab-runner
args:
removes: /usr/local/bin/gitlab-runner
- name: install gitlab-runner service
shell: |
set -e
cp /tmp/gitlab-runner-linux-amd64-{{gitlab_runner_version}} /usr/local/bin/gitlab-runner
chmod +x /usr/local/bin/gitlab-runner
/usr/local/bin/gitlab-runner install --user=gitlab-runner --working-directory=/home/gitlab-runner
args:
creates: /usr/local/bin/gitlab-runner
- name: start gitlab-runner service
command: gitlab-runner start
- name: register shell executor gitlab-runner {{gitlab_ci_runner_name}} into gitlab CI {{gitlab_ci_url}}
command: |
/usr/local/bin/gitlab-runner register --non-interactive \
--name {{gitlab_ci_runner_name}} \
--url {{gitlab_ci_url}} \
--registration-token {{gitlab_shared_runners_registration_token}} \
--env "NEXUS_LOGIN=backbone-builder" \
--env "NEXUS_PASSWORD=backbone-pwd" \
--limit 1 \
--executor=shell