Puppet Class: profile::toolforge::proxy

Defined in:
modules/profile/manifests/toolforge/proxy.pp

Overview

Parameters:

  • proxies (Array[String]) (defaults to: lookup('profile::toolforge::proxies', {default_value => ['tools-proxy-03']}))
  • active_proxy (String) (defaults to: lookup('profile::toolforge::active_proxy_host', {default_value => 'tools-proxy-03'}))
  • web_domain (Stdlib::Fqdn) (defaults to: lookup('profile::toolforge::web_domain', {default_value => 'tools.wmflabs.org'}))
  • do_https (Boolean) (defaults to: lookup('profile::toolforge::proxy::do_https', {default_value => true}))
  • prometheus (Array[Stdlib::Fqdn]) (defaults to: lookup('prometheus_nodes', {default_value => ['localhost']}))
  • statsd (String) (defaults to: lookup('statsd', {default_value => 'localhost:8125'}))
  • k8s_vip_fqdn (Stdlib::Fqdn) (defaults to: lookup('profile::toolforge::k8s::apiserver_fqdn',{default_value => 'k8s.tools.eqiad1.wikimedia.cloud'}))
  • k8s_vip_port (Stdlib::Port) (defaults to: lookup('profile::toolforge::k8s::ingress_port', {default_value => 30000}))


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
# File 'modules/profile/manifests/toolforge/proxy.pp', line 1

class profile::toolforge::proxy (
    Array[String]       $proxies      = lookup('profile::toolforge::proxies',           {default_value => ['tools-proxy-03']}),
    String              $active_proxy = lookup('profile::toolforge::active_proxy_host', {default_value => 'tools-proxy-03'}),
    Stdlib::Fqdn        $web_domain   = lookup('profile::toolforge::web_domain',        {default_value => 'tools.wmflabs.org'}),
    Boolean             $do_https     = lookup('profile::toolforge::proxy::do_https',   {default_value => true}),
    Array[Stdlib::Fqdn] $prometheus   = lookup('prometheus_nodes',                      {default_value => ['localhost']}),
    String              $statsd       = lookup('statsd',                                {default_value => 'localhost:8125'}),
    Stdlib::Fqdn        $k8s_vip_fqdn = lookup('profile::toolforge::k8s::apiserver_fqdn',{default_value => 'k8s.tools.eqiad1.wikimedia.cloud'}),
    Stdlib::Port        $k8s_vip_port = lookup('profile::toolforge::k8s::ingress_port', {default_value => 30000}),
) {
    class { '::redis::client::python': }

    # toolsbeta support: running without SSL
    if $do_https {
        $ssl_cert_name = 'toolforge'
        acme_chief::cert { $ssl_cert_name:
            puppet_rsc => Exec['nginx-reload'],
        }
    } else {
        $ssl_cert_name = undef
    }

    if $::hostname != $active_proxy {
        $redis_replication = {
            "${::hostname}" => $active_proxy,
        }
    } else {
        $redis_replication = undef
    }

    class { '::dynamicproxy':
        ssl_settings         => ssl_ciphersuite('nginx', 'compat'),
        luahandler           => 'urlproxy',
        ssl_certificate_name => $ssl_cert_name,
        k8s_vip_fqdn         => $k8s_vip_fqdn,
        k8s_vip_fqdn_port    => $k8s_vip_port,
        redis_replication    => $redis_replication,
        error_config         => {
            title       => 'Wikimedia Toolforge Error',
            logo        => '/.error/toolforge-logo.png',
            logo_2x     => '/.error/toolforge-logo-2x.png',
            logo_alt    => 'Wikimedia Toolforge',
            logo_height => 120,
            logo_width  => 120,
            logo_link   => 'https://wikitech.wikimedia.org/wiki/Portal:Toolforge',
            favicon     => '/.error/favicon.ico',
        },
        banned_description   => 'You have been banned from accessing Toolforge. Please see <a href="https://wikitech.wikimedia.org/wiki/Help:Toolforge/Banned">Help:Toolforge/Banned</a> for more information on why and on how to resolve this.',
        web_domain           => $web_domain,
        https_upgrade        => $do_https,
        use_acme_chief       => true,
    }

    $proxy_nodes = join($proxies, ' ')

    # Open up redis to all proxies!
    ferm::service { 'redis-replication':
        proto  => 'tcp',
        port   => '6379',
        srange => "@resolve((${proxy_nodes}))",
    }

    file { '/usr/local/sbin/proxylistener':
        ensure  => file,
        owner   => 'root',
        group   => 'root',
        mode    => '0555',
        source  => 'puppet:///modules/profile/toolforge/proxylistener.py',
        # Is provided by the dynamicproxy class.
        require => Class['::redis::client::python'],
    }

    systemd::service { 'proxylistener':
        ensure  => present,
        content => systemd_template('toolforge/proxylistener'),
        require => File['/usr/local/sbin/proxylistener'],
    }

    ferm::service { 'proxylistener-port':
        proto  => 'tcp',
        port   => '8282',
        srange => '$LABS_NETWORKS',
        desc   => 'Proxylistener port, open to just CloudVPS',
    }

    file { '/var/www/error/favicon.ico':
        ensure  => file,
        source  => 'puppet:///modules/profile/toolforge/favicon.ico',
        require => File['/var/www/error'],
    }

    file { '/var/www/error/toolforge-logo.png':
        ensure  => file,
        source  => 'puppet:///modules/profile/toolforge/toolforge-logo.png',
        require => [File['/var/www/error']],
    }

    file { '/var/www/error/toolforge-logo-2x.png':
        ensure  => file,
        source  => 'puppet:///modules/profile/toolforge/toolforge-logo-2x.png',
        require => [File['/var/www/error']],
    }

    require_package('goaccess')  # webserver statistics, T121233

    $graphite_metric_prefix = "${::labsproject}.reqstats"

    file { '/usr/local/lib/python2.7/dist-packages/toolsweblogster.py':
        source => 'puppet:///modules/profile/toolforge/toolsweblogster.py',
        owner  => 'root',
        group  => 'root',
        mode   => '0555',
    }

    logster::job { 'proxy-requests':
        minute          => '*/1',
        parser          => 'toolsweblogster.UrlFirstSegmentLogster', # Nothing more specific yet
        logfile         => '/var/log/nginx/access.log',
        logster_options => "-o statsd --statsd-host=${statsd} --metric-prefix=${graphite_metric_prefix}.",
        require         => File['/usr/local/lib/python2.7/dist-packages/toolsweblogster.py'],
    }

    ferm::service { 'proxymanager':
        proto  => 'tcp',
        port   => '8081',
        desc   => 'Proxymanager service for CloudVPS instances',
        srange => '$LABS_NETWORKS',
    }

    ferm::service{ 'http':
        proto => 'tcp',
        port  => '80',
        desc  => 'HTTP webserver for the entire world',
    }

    if $do_https {
        ferm::service { 'https':
            proto => 'tcp',
            port  => '443',
            desc  => 'HTTPS webserver for the entire world',
        }
    }

    # prometheus nginx metrics
    class { 'prometheus::nginx_exporter': }

    $prometheus_hosts = join($prometheus, ' ')
    ferm::service { 'prometheus_nginx_exporter':
        proto  => 'tcp',
        port   => '9113', # this is the default
        desc   => 'prometheus nginx exporter',
        srange => "@resolve((${prometheus_hosts}))",
    }
}