Skip to content

Commit 5e89f7c

Browse files
authored
Merge pull request #358 from krousenick/gitlab-server-cert-import-fix
fix for gitlab server cert import on linux systems
2 parents e15ea85 + b0de44b commit 5e89f7c

File tree

6 files changed

+25
-11
lines changed

6 files changed

+25
-11
lines changed

defaults/main.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,8 @@ gitlab_runner_check_interval: 0
3232

3333
# GitLab coordinator URL
3434
gitlab_runner_coordinator_url: https://gitlab.com
35-
# GitLab registration token
35+
36+
# GitLab registration token.
3637
gitlab_runner_registration_token: ""
3738

3839
# Gitlab runner registration token type:
@@ -44,9 +45,6 @@ gitlab_runner_registration_token_type: "registration-token"
4445

4546
gitlab_runner_sentry_dsn: ""
4647

47-
# GitLab server IP
48-
gitlab_server_ip: ""
49-
5048
# GitLab TLS CA file
5149
tls_ca_file: ""
5250

@@ -125,6 +123,8 @@ gitlab_runner_runners:
125123
# The executor used by the runner.
126124
executor: shell
127125
# Set maximum build log size in kilobytes.
126+
# token:
127+
# Set maximum build log size in kilobytes.
128128
output_limit: 4096
129129
# Maximum number of jobs to run concurrently on this specific runner.
130130
# Defaults to 0, simply means don't limit.

requirements.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,4 @@
22
collections:
33
- name: ansible.windows
44
- name: community.docker
5+
- name: community.crypto

tasks/register-runner.yml

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,20 @@
11
---
22
- name: Accept gitlab server self signed cert as valid CA
3-
ansible.builtin.shell: >
4-
set -o pipefail
5-
6-
openssl s_client -connect {{ gitlab_server_ip }}:443 -showcerts </dev/null 2>/dev/null |
7-
sed -e '/-----BEGIN/,/-----END/!d' | tee {{ tls_ca_file }} >/dev/null
8-
args:
9-
executable: /usr/bin/bash
103
when: force_accept_gitlab_server_self_signed
4+
block:
5+
- name: Grab the server cert for "{{ gitlab_runner_coordinator_url }}"
6+
community.crypto.get_certificate:
7+
host: "{{ gitlab_runner.url | default(gitlab_runner_coordinator_url) | regex_replace('https?:\/\/([^\/]+)\/?.*', '\\1') }}"
8+
port: 443
9+
asn1_base64: true # need to hard code to prevent depreciation warning
10+
register: gitlab_server_cert
11+
- name: Save the GitLab server self signed cert to the default CA path
12+
ansible.builtin.copy:
13+
content: "{{ gitlab_server_cert.cert }}"
14+
dest: "{{ tls_ca_file }}"
15+
mode: '0644'
16+
- name: Update CA bundle with self signe cert of the gitlab server
17+
ansible.builtin.import_tasks: update-ca-bundle.yml
1118

1219
- name: Update CA bundle with self signe cert of the gitlab server
1320
ansible.builtin.import_tasks: update-ca-bundle.yml

vars/Archlinux.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,3 +5,5 @@ gitlab_runner_executable: /usr/bin/{{ gitlab_runner_package_name }}
55
gitlab_runner_runtime_owner: gitlab-runner
66
gitlab_runner_runtime_group: gitlab-runner
77
gitlab_runner_restart_state: reloaded
8+
9+
tls_ca_file: /etc/ca-certificates/trust-source/anchors/gitlab-server.crt

vars/Debian.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,3 +5,5 @@ gitlab_runner_executable: /usr/bin/{{ gitlab_runner_package_name }}
55
gitlab_runner_runtime_owner: gitlab-runner
66
gitlab_runner_runtime_group: gitlab-runner
77
gitlab_runner_restart_state: reloaded
8+
9+
tls_ca_file: /usr/share/ca-certificates/gitlab-server.crt

vars/RedHat.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,5 @@ gitlab_runner_executable: /usr/bin/{{ gitlab_runner_package_name }}
44

55
gitlab_runner_runtime_owner: gitlab-runner
66
gitlab_runner_runtime_group: gitlab-runner
7+
8+
tls_ca_file: /etc/pki/ca-trust/source/anchors/gitlab-server.crt

0 commit comments

Comments
 (0)