Puppet Class: extdist

Defined in:
modules/extdist/manifests/init.pp

Overview

Class: role::extdist

This class sets up a tarball generator for the Extension Distributor extension enabled on mediawiki.org.

Parameters:

  • base_dir (Any) (defaults to: '/srv')
  • log_dir (Any) (defaults to: '/var/log/')


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
# File 'modules/extdist/manifests/init.pp', line 6

class extdist(
    $base_dir = '/srv',
    $log_dir = '/var/log/'
){
    $dist_dir     = "${base_dir}/dist"
    $clone_dir    = "${base_dir}/extdist"
    $src_path     = "${base_dir}/src"
    $composer_dir = "${base_dir}/composer"
    $pid_folder   = '/run/extdist'

    $ext_settings = {
        'API_URL'   => 'https://www.mediawiki.org/w/api.php',
        'GIT_URL'   => 'https://gerrit-replica.wikimedia.org/r/mediawiki/extensions/%s',
        'DIST_PATH' => "${dist_dir}/extensions",
        'LOG_FILE'  => "${log_dir}/extdist",
        'SRC_PATH'  => $src_path,
        'PID_FILE'  => "${pid_folder}/pid.lock",
        'COMPOSER'  => "${composer_dir}/vendor/bin/composer",
    }

    $skin_settings = {
        'API_URL'   => 'https://www.mediawiki.org/w/api.php',
        'DIST_PATH' => "${dist_dir}/skins",
        'GIT_URL'   => 'https://gerrit-replica.wikimedia.org/r/mediawiki/skins/%s',
        'LOG_FILE'  => "${log_dir}/skindist",
        'SRC_PATH'  => $src_path,
        'PID_FILE'  => "${pid_folder}/skinpid.lock",
        'COMPOSER'  => "${composer_dir}/vendor/bin/composer",
    }

    user { 'extdist':
        ensure => present,
        system => true,
    }

    file { '/home/extdist':
        ensure  => directory,
        owner   => 'extdist',
        require => User['extdist'],
    }

    file { [$dist_dir, $clone_dir, $src_path,
            $pid_folder, $composer_dir, $log_dir]:
        ensure => directory,
        owner  => 'extdist',
        group  => 'www-data',
        mode   => '0755',
    }

    git::clone {'labs/tools/extdist':
        ensure    => latest,
        directory => $clone_dir,
        branch    => 'master',
        require   => [File[$clone_dir], User['extdist']],
        owner     => 'extdist',
        group     => 'extdist',
    }

    require_package('python3-requests', 'php-cli', 'unzip' )

    git::clone { 'integration/composer':
        ensure             => latest,
        directory          => $composer_dir,
        branch             => 'master',
        require            => [File[$composer_dir], User['extdist'], Package['php-cli']],
        recurse_submodules => true,
        owner              => 'extdist',
        group              => 'extdist',
    }

    file { '/etc/extdist.conf':
        ensure  => present,
        content => ordered_json($ext_settings),
        owner   => 'extdist',
        require => User['extdist'],
    }

    file { '/etc/skindist.conf':
        ensure  => present,
        content => ordered_json($skin_settings),
        owner   => 'extdist',
        require => User['extdist'],
    }

    cron { 'extdist-generate-tarballs':
        command => "/usr/bin/python3 ${clone_dir}/nightly.py --all",
        user    => 'extdist',
        minute  => '0',
        hour    => '*',
        require => [
            Git::Clone['labs/tools/extdist'],
            User['extdist'],
            File['/etc/extdist.conf'],
        ],
    }

    cron { 'skindist-generate-tarballs':
        command => "/usr/bin/python3 ${clone_dir}/nightly.py --all --skins",
        user    => 'extdist',
        minute  => '30',
        hour    => '*',
        require => [
            Git::Clone['labs/tools/extdist'],
            User['extdist'],
            File['/etc/skindist.conf'],
        ],
    }

    nginx::site { 'extdist':
        content => template('extdist/extdist.nginx.erb'),
    }
}