Puppet Class: zuul::merger

Defined in:
modules/zuul/manifests/merger.pp

Overview

Class: zuul::merger

Parameters:

  • gearman_server (Any)
  • gerrit_server (Any)
  • gerrit_user (Any)
  • gerrit_ssh_key_file (Any)
  • gerrit_baseurl (Any) (defaults to: 'https://gerrit.wikimedia.org/r')
  • git_dir (Any) (defaults to: '/var/lib/zuul/git')
  • git_email (Any) (defaults to: "zuul-merger@${::hostname}")
  • git_name (Any) (defaults to: 'Wikimedia Zuul Merger')
  • zuul_url (Any) (defaults to: $::fqdn)
  • service_enable (Wmflib::Enable_Service) (defaults to: true)
  • service_ensure (Stdlib::Ensure::Service) (defaults to: 'running')


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
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
# File 'modules/zuul/manifests/merger.pp', line 18

class zuul::merger (
    $gearman_server,
    $gerrit_server,
    $gerrit_user,
    $gerrit_ssh_key_file,
    $gerrit_baseurl = 'https://gerrit.wikimedia.org/r',
    $git_dir        = '/var/lib/zuul/git',
    $git_email      = "zuul-merger@${::hostname}",
    $git_name       = 'Wikimedia Zuul Merger',
    $zuul_url       = $::fqdn,
    Wmflib::Enable_Service  $service_enable     = true,
    Stdlib::Ensure::Service $service_ensure     = 'running',
) {

    require ::zuul

    git::userconfig { '.gitconfig for Zuul merger':
        homedir  => '/var/lib/zuul',
        settings => {
            # Let us override git clone default settings set in the repository
            # $GIT_DIR/config when cloning
            'init'  => {
                'templateDir' => '/var/lib/zuul/git-template-dir',
            },
            'fetch' => {
                # Keep us in sync with Gerrit heads and tags
                #
                # The local branches accumulate and slow down zuul-merger when
                # it resets a repository. It recreates origin branches based on
                # local one which is kind of slow.  Since we don't care about
                # obsolete branches, get them pruned. (T220606).
                'prune'     => 'true',
                # Some repos might well delete tags and some definitely modify
                # them. Although we force fetch (T252310), it is good to keep
                # the state clean.
                'pruneTags' => 'true',
            }
        }
    }

    file { '/var/lib/zuul/git-template-dir':
        ensure => 'directory',
        owner  => 'root',
        group  => 'root',
        mode   => '0555',
    }

    git::config { '/var/lib/zuul/git-template-dir/config':
        settings => {
            'core'  => {
                # No need for reflog which is the default for bare repos
                'logAllRefUpdates' => 'false',
            }
        }
    }

    exec { 'zuul merger recursive mkdir of git_dir':
        command => "/bin/mkdir -p ${git_dir}",
        creates => $git_dir,
    }

    file { $git_dir:
        ensure  => directory,
        owner   => 'zuul',
        require => Exec['zuul merger recursive mkdir of git_dir'],
    }

    file { '/var/lib/zuul/.ssh':
        ensure => 'directory',
        owner  => 'zuul',
        group  => 'zuul',
        mode   => '0700',
    }

    file { '/var/lib/zuul/.ssh/id_rsa':
        ensure    => present,
        owner     => 'zuul',
        group     => 'zuul',
        mode      => '0400',
        content   => secret($gerrit_ssh_key_file),
        show_diff => false,
        require   => [
            User['zuul'],
            File['/var/lib/zuul/.ssh'],
        ],
    }
    file { '/var/lib/zuul/.ssh/id_rsa.pub':
        ensure    => present,
        owner     => 'zuul',
        group     => 'zuul',
        mode      => '0400',
        content   => secret("${gerrit_ssh_key_file}.pub"),
        show_diff => false,
        require   => [
            User['zuul'],
            File['/var/lib/zuul/.ssh'],
        ],
    }

    # Configuration file for the zuul merger
    $zuul_role = 'merger'
    $gearman_server_ip = ipresolve($gearman_server, 4)

    file { '/etc/zuul/zuul-merger.conf':
        owner   => 'root',
        group   => 'root',
        mode    => '0444',
        content => template('zuul/zuul.conf.erb'),
    }

    file { '/etc/default/zuul-merger':
        ensure  => present,
        owner   => 'root',
        group   => 'root',
        mode    => '0444',
        content => template('zuul/zuul-merger.default.erb'),
        notify  => Service['zuul-merger'],
    }

    file { '/etc/zuul/merger-logging.conf':
        ensure => present,
        source => 'puppet:///modules/zuul/merger-logging.conf',
    }

    systemd::service { 'zuul-merger':
        ensure         => 'present',
        content        => systemd_template('zuul-merger'),
        restart        => false,
        subscribe      => File['/etc/zuul/zuul-merger.conf'],
        service_params => {
            enable => $service_enable,
            ensure => $service_ensure,
        },
        require        => [
            File['/etc/default/zuul-merger'],
            File['/etc/zuul/merger-logging.conf'],
            File['/etc/zuul/zuul-merger.conf'],
        ],
    }

    if ($service_enable == 'mask') {
        profile::auto_restarts::service { 'zuul-merger':
            ensure => absent,
        }
    } else {
        profile::auto_restarts::service { 'zuul-merger': }
    }

    systemd::timer::job { 'zuul_repack':
        ensure       => present,
        user         => 'zuul',
        description  => 'Regular jobs for repacking heads and tags of repositories',
        command      => "/usr/bin/find ${git_dir} -maxdepth 3 -type d -name '.git' -exec /usr/bin/git --git-dir='{}' pack-refs --all \\;",
        send_mail    => true,
        send_mail_to => 'releng@lists.wikimedia.org',
        interval     => {'start' => 'OnCalendar', 'interval' => '*-*-* 4:07:00'},
        require      => File[$git_dir],
    }
}