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)
  • ensure_service (Enum['stopped', 'running', 'masked']) (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
# 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,
    Enum['stopped', 'running', 'masked'] $ensure_service = 'running',
) {

    require ::zuul

    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'
    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',
    }

    if $ensure_service == 'masked' {
        systemd::mask { 'zuul-merge.service':  }
        $real_ensure_service = 'stopped'
    } else {
        $real_ensure_service = $ensure_service
    }

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

    base::service_auto_restart { 'zuul-merger': }

    cron { 'zuul_repack':
        user        => 'zuul',
        hour        => '4',
        minute      => '7',
        command     => "find ${git_dir} -maxdepth 3 -type d -name '.git' -exec git --git-dir='{}' pack-refs --all \\;",
        environment => [
            'PATH=/usr/bin:/bin:/usr/sbin:/sbin',
            'MAILTO="jenkins-bot@wikimedia.org"',
        ],
        require     => File[$git_dir],
    }
}