Puppet Class: profile::gitlab

Defined in:
modules/profile/manifests/gitlab.pp

Overview

Parameters:

  • active_host (Stdlib::Fqdn) (defaults to: lookup('profile::gitlab::active_host'))
  • passive_host (Stdlib::Fqdn) (defaults to: lookup('profile::gitlab::passive_host'))
  • enable_backup_sync (Boolean) (defaults to: lookup('profile::gitlab::enable_backup_sync'))
  • service_ip_v4 (Stdlib::IP::Address::V4) (defaults to: lookup('profile::gitlab::service_ip_v4'))
  • service_ip_v6 (Stdlib::IP::Address::V6) (defaults to: lookup('profile::gitlab::service_ip_v6'))
  • service_name (Stdlib::Host) (defaults to: lookup('profile::gitlab::service_name'))
  • backup_dir_data (Stdlib::Unixpath) (defaults to: lookup('profile::gitlab::backup_dir_data'))
  • backup_dir_config (Stdlib::Unixpath) (defaults to: lookup('profile::gitlab::backup_dir_config'))
  • monitoring_whitelist (Array[Stdlib::IP::Address]) (defaults to: lookup('profile::gitlab::monitoring_whitelist'))
  • cas_label (String) (defaults to: lookup('profile::gitlab::cas_label'))
  • cas_url (Stdlib::Httpurl) (defaults to: lookup('profile::gitlab::cas_url'))
  • cas_auto_create_users (Boolean) (defaults to: lookup('profile::gitlab::cas_auto_create_users'))
  • csp_enabled (Boolean) (defaults to: lookup('profile::gitlab::csp_enabled', {default_value => false}))
  • csp_report_only (Boolean) (defaults to: lookup('profile::gitlab::csp_enabled', {default_value => false}))
  • backup_keep_time (Integer[1]) (defaults to: lookup('profile::gitlab::backup_keep_time'))
  • smtp_enabled (Boolean) (defaults to: lookup('profile::gitlab::smtp_enabled'))
  • exporters (Hash[Gitlab::Exporters,Gitlab::Exporter]) (defaults to: lookup('profile::gitlab::exporters', {default_value => []}))
  • cert_path (Stdlib::Unixpath) (defaults to: lookup('profile::gitlab::cert_path'))
  • key_path (Stdlib::Unixpath) (defaults to: lookup('profile::gitlab::key_path'))
  • enable_restore (Boolean) (defaults to: lookup('profile::gitlab::enable_restore', {default_value => false}))


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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
# File 'modules/profile/manifests/gitlab.pp', line 1

class profile::gitlab(
    Stdlib::Fqdn $active_host = lookup('profile::gitlab::active_host'),
    Stdlib::Fqdn $passive_host = lookup('profile::gitlab::passive_host'),
    Boolean $enable_backup_sync = lookup('profile::gitlab::enable_backup_sync'),
    Stdlib::IP::Address::V4 $service_ip_v4 = lookup('profile::gitlab::service_ip_v4'),
    Stdlib::IP::Address::V6 $service_ip_v6 = lookup('profile::gitlab::service_ip_v6'),
    Stdlib::Host $service_name = lookup('profile::gitlab::service_name'),
    Stdlib::Unixpath $backup_dir_data = lookup('profile::gitlab::backup_dir_data'),
    Stdlib::Unixpath $backup_dir_config = lookup('profile::gitlab::backup_dir_config'),
    Array[Stdlib::IP::Address] $monitoring_whitelist  = lookup('profile::gitlab::monitoring_whitelist'),
    String $cas_label = lookup('profile::gitlab::cas_label'),
    Stdlib::Httpurl $cas_url = lookup('profile::gitlab::cas_url'),
    Boolean $cas_auto_create_users = lookup('profile::gitlab::cas_auto_create_users'),
    Boolean $csp_enabled = lookup('profile::gitlab::csp_enabled', {default_value => false}),
    Boolean $csp_report_only = lookup('profile::gitlab::csp_enabled', {default_value => false}),
    Integer[1] $backup_keep_time = lookup('profile::gitlab::backup_keep_time'),
    Boolean  $smtp_enabled = lookup('profile::gitlab::smtp_enabled'),
    Hash[Gitlab::Exporters,Gitlab::Exporter] $exporters = lookup('profile::gitlab::exporters', {default_value => []}),
    Stdlib::Unixpath $cert_path = lookup('profile::gitlab::cert_path'),
    Stdlib::Unixpath $key_path = lookup('profile::gitlab::key_path'),
    Boolean $enable_restore = lookup('profile::gitlab::enable_restore', {default_value => false}),
){

    $acme_chief_cert = 'gitlab'

    # TODO move backup logic from profile to module
    if $active_host == $facts['fqdn'] {
        # Bacula backups, also see profile::backup::filesets (T274463)
        backup::set { 'gitlab':
            jobdefaults => 'Daily-production',  # full backups every day
        }
    }

    exec {'Reload nginx':
      command     => '/usr/bin/gitlab-ctl hup nginx',
      refreshonly => true,
    }

    # Certificates will be available under:
    # /etc/acmecerts/<%= @acme_chief_cert %>/live/
    acme_chief::cert { $acme_chief_cert:
        puppet_rsc => Exec['Reload nginx'],
    }

    # add a service IP to the NIC - T276148
    interface::alias { 'gitlab service IP':
        ipv4 => $service_ip_v4,
        ipv6 => $service_ip_v6,
    }

    # open ports in firewall - T276144

    # world -> service IP, HTTP
    ferm::service { 'gitlab-http-public':
        proto  => 'tcp',
        port   => 80,
        drange => "(${service_ip_v4} ${service_ip_v6})",
    }

    # world -> service IP, HTTPS
    ferm::service { 'gitlab-https-public':
        proto  => 'tcp',
        port   => 443,
        drange => "(${service_ip_v4} ${service_ip_v6})",
    }

    # world -> service IP, SSH
    ferm::service { 'gitlab-ssh-public':
        proto  => 'tcp',
        port   => 22,
        drange => "(${service_ip_v4} ${service_ip_v6})",
    }

    # JSON Logs
    rsyslog::input::file { 'gitlab-gitaly-json':
      path => '/var/log/gitlab/gitaly/current',
    }

    rsyslog::input::file { 'gitlab-rails-production-json':
      path => '/var/log/gitlab/gitlab-rails/production_json.log',
    }

    rsyslog::input::file { 'gitlab-rails-api-json':
      path => '/var/log/gitlab/gitlab-rails/api_json.log',
    }

    rsyslog::input::file { 'gitlab-rails-application-json':
      path => '/var/log/gitlab/gitlab-rails/application_json.log',
    }

    rsyslog::input::file { 'gitlab-rails-exceptions-json':
      path => '/var/log/gitlab/gitlab-rails/exceptions_json.log',
    }

    rsyslog::input::file { 'gitlab-workhorse-json':
      path => '/var/log/gitlab/gitlab-workhorse/current',
    }

    rsyslog::input::file { 'gitlab-sidekiq-json':
      path => '/var/log/gitlab/sidekiq/current',
    }

    # @cee Json Logs
    rsyslog::input::file { 'gitlab-nginx-access-cee':
      path => '/var/log/gitlab/nginx/gitlab_access.log',
    }

    # Plain logs
    rsyslog::input::file { 'gitlab-nginx-error-plain':
      path => '/var/log/gitlab/nginx/gitlab_error.log',
    }

    rsyslog::input::file { 'gitlab-redis-plain':
      path => '/var/log/gitlab/redis/current',
    }

    # TODO T274462
    # rsyslog::input::file { 'gitlab-postgres':
    #   path => '/var/log/gitlab/postgresql/current',
    # }

    # T285867 sync active and passive GitLab server backups

    # rsync server is needed on passive server only
    $ensure_rsyncd = $active_host ? {
        $facts['fqdn'] => 'stopped',
        default        => 'running'
    }

    class { 'rsync::server':
        ensure_service => $ensure_rsyncd
    }

    class { 'gitlab::rsync':
        active_host  => $active_host,
        passive_host => $passive_host,
        ensure       => $enable_backup_sync.bool2str('present','absent')
    }

    class { 'gitlab':
        backup_dir             => $backup_dir_data,
        exporters              => $exporters,
        monitoring_whitelist   => $monitoring_whitelist,
        cas_label              => $cas_label,
        cas_url                => $cas_url,
        cas_auto_create_users  => $cas_auto_create_users,
        csp_enabled            => $csp_enabled,
        csp_report_only        => $csp_report_only,
        backup_keep_time       => $backup_keep_time,
        smtp_enabled           => $smtp_enabled,
        enable_backup          => $active_host == $facts['fqdn'], # enable backups on active GitLab server
        listen_addresses       => [$service_ip_v4, $service_ip_v6],
        install_restore_script => $active_host != $facts['fqdn'], # install restore script on passive GitLab server
        enable_restore         => $enable_restore,
        cert_path              => $cert_path,
        key_path               => $key_path,
        gitlab_domain          => $service_name,
    }
}