Puppet Class: wikilabels::web

Defined in:
modules/wikilabels/manifests/web.pp

Overview

Class: wiklabels::web

Sets up a uwsgi based web server for Wikilabels running python3

Parameters:

  • branch (Any) (defaults to: 'deploy')


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
# File 'modules/wikilabels/manifests/web.pp', line 4

class wikilabels::web (
    $branch = 'deploy',
) {

    $venv_path = '/srv/wikilabels/venv'
    $config_path = '/srv/wikilabels/config'

    # Let's use a virtualenv for maximum flexibility - we can convert
    # this to deb packages in the future if needed.
    # FIXME: Use debian packages for all the packages needing compilation
    ensure_packages(['virtualenv', 'python3-dev', 'libffi-dev',
        'libpq-dev', 'g++', 'libmemcached-dev', 'nodejs', 'zlib1g-dev', 'postgresql-client'])

    file { '/srv':
        ensure => directory,
        owner  => 'root',
        group  => 'root',
        mode   => '0775',
    }

    file { '/srv/wikilabels':
        ensure  => directory,
        owner   => 'www-data',
        group   => 'www-data',
        mode    => '0775',
        recurse => true,
        require => File['/srv'],
    }

    git::clone { 'wikilabels-wikimedia-config':
        ensure    => present,
        origin    => 'https://github.com/wikimedia/wikilabels-wikimedia-config.git',
        directory => $config_path,
        branch    => $branch,
        owner     => 'www-data',
        group     => 'www-data',
        require   => File['/srv/wikilabels'],
    }

    uwsgi::app { 'wikilabels-web':
        settings => {
            uwsgi => {
                plugins     => 'python3,router_redirect',
                'wsgi-file' => "${config_path}/labels_web.py",
                master      => true,
                chdir       => $config_path,
                http-socket => '0.0.0.0:8080',
                venv        => $venv_path,
                processes   => $facts['processorcount'] * 4,
                die-on-term => true,
                harakiri    => 30,
                # lint:ignore:single_quote_string_with_variables
                route-if    => 'equal:${HTTP_X_FORWARDED_PROTO};http redirect-permanent:https://${HTTP_HOST}${REQUEST_URI}',
                # lint:endignore
            }
        },
    }

    file { '/var/log/wikilabels':
        ensure => ensure_directory(present),
        owner  => 'www-data',
        group  => 'www-data',
        mode   => '0664',
    }

    cron { 'wikilabels-remove_expired_tasks':
        ensure  => present,
        command => '/srv/wikilabels/venv/bin/python /srv/wikilabels/config/submodules/wikilabels/utility remove_expired_tasks --config=/srv/wikilabels/config/config/ > /var/log/wikilabels/remove_expired_tasks.log 2>&1',
        user    => 'www-data',
        hour    => 0,
        minute  => 0,
        require => File['/var/log/wikilabels'],
    }

}