Puppet Class: psick::gitlab::runner

Defined in:
manifests/gitlab/runner.pp

Overview

This class manages the installation and initialisation of a GitLab CI runner.

Parameters:

  • ensure (String) (defaults to: 'present')

    If to install or remove the GitLab CI runner

  • auto_prereq (Boolean) (defaults to: true)

    If to automatically install all the prerequisites resources needed to install the runner

  • template (Optional[String]) (defaults to: undef)

    The path to the erb template (as used in template()) to use to populate the Runner configuration file. Note that if you use the runners parameter this file is automatically generated during runners registration

  • options (Hash) (defaults to: { })

    An open hash of options you may use in your template

  • runners (Hash) (defaults to: { })

    An hash which is used to create one or more runners instances. It should be an array of hashes which is passed to the define psick::gitlab::runner_register

  • sudo_template (String) (defaults to: 'psick/gitlab/runner/sudo.erb')

    The path to the erb template to use for gitlab runner sudoers file. If undef file is not managed

  • pe_user (Optional[String]) (defaults to: undef)
  • pe_password (Optional[String]) (defaults to: undef)
  • runner_user (Optional[String]) (defaults to: 'gitlab-runner')
  • pe_token_lifetime (Optional[String]) (defaults to: '5y')
  • use_docker (Boolean) (defaults to: false)


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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
# File 'manifests/gitlab/runner.pp', line 17

class psick::gitlab::runner (
  String           $ensure            = 'present',
  Boolean          $auto_prereq       = true,
  Optional[String] $template          = undef,
  Hash             $options           = { },
  Hash             $runners           = { },
  String           $sudo_template     = 'psick/gitlab/runner/sudo.erb',
  Optional[String] $pe_user           = undef,
  Optional[String] $pe_password       = undef,
  Optional[String] $runner_user       = 'gitlab-runner',
  Optional[String] $pe_token_lifetime = '5y',
  Boolean          $use_docker        = false,
) {

  if $use_docker {
    contain ::psick::docker
    # Quick and very dirty
    exec { 'usermod -a -G docker gitlab-runner':
      unless    => 'grep docker /etc/group | grep gitlab-runner',
      subscribe => Class['psick::docker'],
    }
  }
  $options_default = {
  }
  $gitlab_runner_options = $options_default + $options
  ::tp::install { 'gitlab-runner' :
    ensure      => $ensure,
    auto_prereq => $auto_prereq,
  }

  if $template {
    ::tp::conf { 'gitlab-runner':
      ensure       => $ensure,
      template     => $template,
      options_hash => $gitlab_runner_options,
    }
  }

  if $runners != {} {
    $runners.each | $k , $v | {
      psick::gitlab::runner_register { $k:
        * => $v,
      }
    }
  }

  if $sudo_template {
    psick::sudo::directive { 'gitlab-runner':
      template => $sudo_template,
    }
  }

  if $pe_user and $pe_password {
    psick::puppet::access { 'gitlab-runner':
      pe_user     => $pe_user,
      pe_password => $pe_password,
      run_as_user => $runner_user,
      lifetime    => $pe_token_lifetime,
    }
  }
}