Puppet Class: profile::httpbb

Defined in:
modules/profile/manifests/httpbb.pp

Overview

Parameters:

  • plain_basicauth_credentials (Optional[Hash[String, Hash[String, String]]]) (defaults to: lookup('profile::httpbb::basicauth_credentials', {default_value => undef}))
  • hourly_tests (Hash[String, Array[String]]) (defaults to: lookup('profile::httpbb::hourly_tests', {default_value => {}}))


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
# File 'modules/profile/manifests/httpbb.pp', line 18

class profile::httpbb (
    Optional[Hash[String, Hash[String, String]]] $plain_basicauth_credentials = lookup('profile::httpbb::basicauth_credentials', {default_value => undef}),
    Hash[String, Array[String]] $hourly_tests = lookup('profile::httpbb::hourly_tests', {default_value => {}})
){
    class {'::httpbb':}

    # Walk over the credentials hash and turn "user: password" into "user: base64(...)"
    # leaving the structure intact.
    if $plain_basicauth_credentials {
        $basicauth_credentials = $plain_basicauth_credentials.map |$k, $v| {
            {
                $k=> $v.map |$user, $password| {
                    {$user => "Basic ${base64('encode', "${user}:${password}", 'strict') }"}
                }.reduce({}) |$m, $v| {
                    $m.merge($v)
                }
            }
        }.reduce({}) |$mem, $val| {
            $mem.merge($val)
        }
    } else {
        $basicauth_credentials = undef
    }

    file {
        [
            '/srv/deployment/httpbb-tests/appserver',
            '/srv/deployment/httpbb-tests/miscweb',
            '/srv/deployment/httpbb-tests/people',
            '/srv/deployment/httpbb-tests/releases',
            '/srv/deployment/httpbb-tests/noc',
            '/srv/deployment/httpbb-tests/doc',
            '/srv/deployment/httpbb-tests/parse',
            '/srv/deployment/httpbb-tests/thumbor',
            '/srv/deployment/httpbb-tests/docker-registry',
            '/srv/deployment/httpbb-tests/ores',
            '/srv/deployment/httpbb-tests/query_service',
            '/srv/deployment/httpbb-tests/jobrunner'
        ]:
            ensure => directory,
            purge  => true
    }

    httpbb::test_suite {'appserver/test_foundation.yaml':
        source => 'puppet:///modules/profile/httpbb/appserver/test_foundation.yaml'
    }
    httpbb::test_suite {'appserver/test_main.yaml':
        source => 'puppet:///modules/profile/httpbb/appserver/test_main.yaml'
    }
    httpbb::test_suite {'appserver/test_redirects.yaml':
        source => 'puppet:///modules/profile/httpbb/appserver/test_redirects.yaml'
    }
    httpbb::test_suite {'appserver/test_remnant.yaml':
        source => 'puppet:///modules/profile/httpbb/appserver/test_remnant.yaml'
    }
    httpbb::test_suite {'appserver/test_secure.yaml':
        source => 'puppet:///modules/profile/httpbb/appserver/test_secure.yaml'
    }
    httpbb::test_suite {'appserver/test_wikimania_wikimedia.yaml':
        source => 'puppet:///modules/profile/httpbb/appserver/test_wikimania_wikimedia.yaml'
    }
    httpbb::test_suite {'appserver/test_wwwportals.yaml':
        source => 'puppet:///modules/profile/httpbb/appserver/test_wwwportals.yaml'
    }
    httpbb::test_suite {'miscweb/test_miscweb.yaml':
        source => 'puppet:///modules/profile/httpbb/miscweb/test_miscweb.yaml'
    }
    httpbb::test_suite {'miscweb/test_miscweb-k8s.yaml':
        source => 'puppet:///modules/profile/httpbb/miscweb-k8s/test_miscweb-k8s.yaml'
    }
    httpbb::test_suite {'people/test_people.yaml':
        source => 'puppet:///modules/profile/httpbb/people/test_people.yaml'
    }
    httpbb::test_suite {'releases/test_releases.yaml':
        source => 'puppet:///modules/profile/httpbb/releases/test_releases.yaml'
    }
    httpbb::test_suite {'noc/test_noc.yaml':
        source => 'puppet:///modules/profile/httpbb/noc/test_noc.yaml'
    }
    httpbb::test_suite {'doc/test_doc.yaml':
        source => 'puppet:///modules/profile/httpbb/doc/test_doc.yaml'
    }
    httpbb::test_suite {'parse/test_parse.yaml':
        source => 'puppet:///modules/profile/httpbb/parse/test_parse.yaml'
    }
    httpbb::test_suite {'thumbor/test_thumbor.yaml':
        source => 'puppet:///modules/profile/httpbb/thumbor/test_thumbor.yaml'
    }
    httpbb::test_suite {'ores/test_ores.yaml':
        source => 'puppet:///modules/profile/httpbb/ores/test_ores.yaml'
    }
    httpbb::test_suite {'query_service/test_wdqs.yaml':
        source => 'puppet:///modules/profile/httpbb/query_service/test_wdqs.yaml'
    }
    httpbb::test_suite {'jobrunner/test_endpoint.yaml':
        source => 'puppet:///modules/profile/httpbb/jobrunner/test_endpoint.yaml'
    }

    if $basicauth_credentials and $basicauth_credentials['docker-registry'] {
        httpbb::test_suite {'docker-registry/test_docker-registry.yaml':
            content => template('profile/httpbb/docker-registry/test_docker-registry.yaml.erb'),
            mode    => '0400',
        }
    }

    $hourly_tests.each |String $test_dir, Array[String] $hosts| {
        $joined_hosts = join($hosts, ',')
        $ensure = $hosts ? {
            []      => absent,
            default => present
        }
        systemd::timer::job { "httpbb_hourly_${test_dir}":
            ensure             => $ensure,
            description        => "Run httpbb ${test_dir}/ tests hourly on ${joined_hosts}",
            command            => "/bin/sh -c '/usr/bin/httpbb /srv/deployment/httpbb-tests/${test_dir}/*.yaml --hosts ${joined_hosts}'",
            interval           => {
                'start'    => 'OnUnitActiveSec',
                'interval' => '1 hour',
            },
            # This doesn't really need access to anything in www-data, but it definitely doesn't need root.
            user               => 'www-data',
            monitoring_enabled => true,
        }
    }
}