Puppet Class: gitlab_runner::config

Defined in:
modules/gitlab_runner/manifests/config.pp

Overview

SPDX-License-Identifier: Apache-2.0

Parameters:

  • concurrent (Integer) (defaults to: 3)
  • docker_image (String) (defaults to: 'docker-registry.wikimedia.org/buster:latest')
  • docker_network (String) (defaults to: 'gitlab-runner')
  • ensure_buildkitd (Wmflib::Ensure) (defaults to: 'present')
  • gitlab_url (Stdlib::HTTPSUrl) (defaults to: 'https://gitlab.wikimedia.org/')
  • runner_name (String) (defaults to: 'GitLab Runner')
  • enable_exporter (Boolean) (defaults to: false)
  • exporter_listen_address (Stdlib::IP::Address) (defaults to: '127.0.0.1')
  • exporter_listen_port (Integer) (defaults to: 9252)
  • check_interval (Integer) (defaults to: 3)
  • session_timeout (Integer) (defaults to: 1800)
  • gitlab_runner_user (String) (defaults to: 'gitlab-runner')


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
55
56
57
58
59
# File 'modules/gitlab_runner/manifests/config.pp', line 2

class gitlab_runner::config (
    Integer             $concurrent              = 3,
    String              $docker_image            = 'docker-registry.wikimedia.org/buster:latest',
    String              $docker_network          = 'gitlab-runner',
    Wmflib::Ensure      $ensure_buildkitd        = 'present',
    Stdlib::HTTPSUrl    $gitlab_url              = 'https://gitlab.wikimedia.org/',
    String              $runner_name             = 'GitLab Runner',
    Boolean             $enable_exporter         = false,
    Stdlib::IP::Address $exporter_listen_address = '127.0.0.1',
    Integer             $exporter_listen_port    = 9252,
    Integer             $check_interval          = 3,
    Integer             $session_timeout         = 1800,
    String              $gitlab_runner_user      = 'gitlab-runner',
) {

    # Setup config template which is used while registering new runners
    file {'/etc/gitlab-runner/config-template.toml':
        owner   => $gitlab_runner_user,
        mode    => '0400',
        content => template('gitlab_runner/config-template.toml.erb'),
        require => Package['gitlab-runner'],
    }

    # config.toml configuration file has different path for non-root users
    $config_path = $gitlab_runner_user ? {
        'root' => '/etc/gitlab-runner',
        default => "/home/${gitlab_runner_user}/.gitlab-runner"
    }

    # Believe it or not, there's no config template or CLI to modifying
    # the global concurrent Runner settings.
    file_line { 'gitlab-runner-config-concurrent':
        path    => "${config_path}/config.toml",
        match   => '^concurrent *=',
        line    => "concurrent = ${concurrent}",
        notify  => Systemd::Service['gitlab-runner'],
        require => Package['gitlab-runner'],
    }

    # Believe it or not, there's no config template or CLI to modifying
    # the global Prometheus listener settings.
    file_line { 'gitlab-runner-config-exporter':
        ensure  => $enable_exporter.bool2str('present','absent'),
        path    => "${config_path}/config.toml",
        line    => "listen_address = \"[${exporter_listen_address}]:${exporter_listen_port}\"",
        notify  => Systemd::Service['gitlab-runner'],
        require => Package['gitlab-runner'],
        after   => "concurrent = ${concurrent}", # make sure changes happen in global section
    }

    systemd::service{ 'gitlab-runner':
        ensure         => 'present',
        content        => template('gitlab_runner/gitlab-runner.service.erb'),
        service_params => {'restart' => 'systemctl restart gitlab-runner'},
        override       => true, #override default unit file for non-root user
        require        => Package['gitlab-runner'],
    }
}