Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Gitlab server cert fix #356

Closed
wants to merge 21 commits into from
Closed
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions defaults/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,8 @@ gitlab_runner_check_interval: 0

# GitLab coordinator URL
gitlab_runner_coordinator_url: https://gitlab.com
# GitLab registration token

# GitLab registration token.
gitlab_runner_registration_token: ""

# Gitlab runner registration token type:
Expand All @@ -37,11 +38,8 @@ gitlab_runner_registration_token_type: "registration-token"

gitlab_runner_sentry_dsn: ""

# GitLab server IP
gitlab_server_ip: ""

# GitLab TLS CA file
tls_ca_file: ""
tls_ca_file: "/etc/pki/ca-trust/source/anchors/gitlab-server.crt"
guenhter marked this conversation as resolved.
Show resolved Hide resolved

# Prometheus Metrics & Monitoring
gitlab_runner_listen_address: ""
Expand Down Expand Up @@ -118,6 +116,8 @@ gitlab_runner_runners:
# The executor used by the runner.
executor: shell
# Set maximum build log size in kilobytes.
# token:
# Set maximum build log size in kilobytes.
output_limit: 4096
# Maximum number of jobs to run concurrently on this specific runner.
# Defaults to 0, simply means don't limit.
Expand Down
29 changes: 22 additions & 7 deletions tasks/register-runner.yml
Original file line number Diff line number Diff line change
@@ -1,13 +1,28 @@
---
- name: Accept gitlab server self signed cert as valid CA
ansible.builtin.shell: >
set -o pipefail
# - name: Accept gitlab server self signed cert as valid CA
# ansible.builtin.shell: >
# set -o pipefail

# openssl s_client -connect {{ gitlab_runner_coordinator_url | regex_replace('https?:\/\/([^\/]+)\/?.*', '\\1') }}:443 -showcerts </dev/null 2>/dev/null |
# sed -e '/-----BEGIN/,/-----END/!d' | tee {{ tls_ca_file }} >/dev/null
# args:
# executable: /usr/bin/bash
# when: force_accept_gitlab_server_self_signed
guenhter marked this conversation as resolved.
Show resolved Hide resolved

openssl s_client -connect {{ gitlab_server_ip }}:443 -showcerts </dev/null 2>/dev/null |
sed -e '/-----BEGIN/,/-----END/!d' | tee {{ tls_ca_file }} >/dev/null
args:
executable: /usr/bin/bash
- name: Accept gitlab server self signed cert as valid CA
when: force_accept_gitlab_server_self_signed
block:
- community.crypto.get_certificate:
host: "{{ gitlab_runner_coordinator_url | regex_replace('https?:\/\/([^\/]+)\/?.*', '\\1') }}"
guenhter marked this conversation as resolved.
Show resolved Hide resolved
port: 443
asn1_base64: true # need to hard code to prevent depreciation warning
register: gitlab_server_cert
- name: Save the GitLab server self signed cert to the default CA path
ansible.builtin.copy:
content: "{{ gitlab_server_cert.cert }}"
dest: "{{ tls_ca_file }}"
guenhter marked this conversation as resolved.
Show resolved Hide resolved
- name: Update CA bundle with self signe cert of the gitlab server
ansible.builtin.import_tasks: update-ca-bundle.yml

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