Puppet Class: profile::puppetserver::pontoon

Defined in:
modules/profile/manifests/puppetserver/pontoon.pp

Overview

Parameters:

  • git_basedir (Stdlib::Unixpath) (defaults to: lookup('profile::puppetserver::git::basedir'))
  • code_dir (Stdlib::Unixpath) (defaults to: lookup('profile::puppetserver::code_dir'))
  • pki_enabled (Boolean) (defaults to: lookup('profile::puppetserver::pontoon::pki_enabled', {'default_value' => false}))
  • zk_enabled (Boolean) (defaults to: lookup('profile::puppetserver::pontoon::zk_enabled', {'default_value' => false}))
  • extra_mounts (Hash[String, Stdlib::Unixpath]) (defaults to: lookup('profile::puppetserver::extra_mounts'))


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
155
156
157
158
159
160
161
162
163
164
# File 'modules/profile/manifests/puppetserver/pontoon.pp', line 4

class profile::puppetserver::pontoon (
    Stdlib::Unixpath               $git_basedir  = lookup('profile::puppetserver::git::basedir'),
    Stdlib::Unixpath               $code_dir     = lookup('profile::puppetserver::code_dir'),
    Boolean                        $pki_enabled  = lookup('profile::puppetserver::pontoon::pki_enabled', {'default_value' => false}),
    Boolean                        $zk_enabled   = lookup('profile::puppetserver::pontoon::zk_enabled', {'default_value' => false}),
    Hash[String, Stdlib::Unixpath] $extra_mounts = lookup('profile::puppetserver::extra_mounts'),
) {
    class { 'pontoon::enc': }

    file { ['/etc/pontoon', '/var/lib/pontoon']:
        ensure => directory,
        owner  => 'root',
        group  => 'root',
        mode   => '0555',
    }

    file { '/etc/pontoon/hiera':
        ensure => directory,
        owner  => 'puppet',
        group  => 'puppet',
        mode   => '0755',
    }

    # XXX refactor to use profile::puppetserver::git instead
    ['operations/puppet', 'labs/private'].each |$repo| {
        wmflib::dir::mkdir_p("${git_basedir}/${repo}", {
            owner  => 'puppet',
            group  => 'puppet',
        })

        # Cloning from bootstrap repos takes precedence over gerrit
        $origin = find_file("/tmp/bootstrap/git/${$repo.basename}/.git/config") ? {
            undef   => undef,
            default => "/tmp/bootstrap/git/${$repo.basename}",
        }

        git::clone { $repo:
            directory => "${git_basedir}/${repo}",
            owner     => 'puppet',
            mode      => '0755',
            origin    => $origin,
        }
    }

    file { "${code_dir}/environments/production":
        ensure  => link,
        target  => "${git_basedir}/operations/puppet",
        require => File["${code_dir}/environments"],
    }

    file { '/etc/puppet/private':
        ensure => link,
        target => "${git_basedir}/labs/private",
    }

    $puppetdb_hosts = pontoon::hosts_for_role('puppetdb')
    $puppetdb_ok_file='/var/lib/pontoon/puppetdb-ok'

    file { '/usr/local/bin/probe-puppetdb':
        ensure => present,
        source => 'puppet:///modules/pontoon/bootstrap/probe-puppetdb.sh',
        owner  => 'root',
        group  => 'root',
        mode   => '0555',
    }

    if $puppetdb_hosts == undef {
        # Do not enable puppetdb
        $puppetdb_urls = []

        file { $puppetdb_ok_file:
            ensure => absent,
        }
    } else {
        # Wait for puppetdb to be ready before enabling server support.
        #
        # Probing and waiting is necessary to resolve a bootstrap race between server and db:
        # 1. puppetdb settings (puppetdb.yaml) are enabled in Pontoon for the first time
        # 2. the puppetdb host has not yet completed its bootstrap/initialization
        # 3. puppet runs on the server host and enables puppetdb
        #
        # At this point the server has enabled a non-functional puppetdb and all future puppet runs will
        # fail (including puppet runs that might be needed by puppetdb to finish bootstrapping,
        # thus requiring manual intervention to break the race)
        #
        # Therefore enable puppetdb only when we're reasonably sure the server won't self-sabotage.
        $candidate_urls = $puppetdb_hosts.map |$h| { "https://${h}:8443" }
        $probes = join($candidate_urls, ' ')
        exec { 'probe puppetdb':
            command => "/usr/local/bin/probe-puppetdb ${puppetdb_ok_file} ${probes}",
            creates => $puppetdb_ok_file,
        }

        # Successful probing, enable puppetdb
        $puppetdb_urls = find_file($puppetdb_ok_file) ? {
            undef   => [],
            default => $candidate_urls,
        }
    }

    class { 'profile::puppetserver':
        ca_allow_san  => true,
        ca_name       => 'pontoon',
        puppetdb_urls => $puppetdb_urls,
    }

    class { 'puppetmaster::gitsync':
        base_dir => $git_basedir,
        git_user => 'puppet',
    }

    class { 'pontoon::geoip':
        base_dir => "${extra_mounts['volatile']}/GeoIP"
    }

    # Co-locate a root PKI when requested.
    # Obtaining certs requires a separate role::pki::multirootca host.
    if $pki_enabled and pontoon::hosts_for_role('pki::multirootca') != undef {
        include profile::pki::client
        include profile::pki::root_ca
        # lint:ignore:wmf_styleguide
        $intermediates = lookup('profile::pki::root_ca::intermediates', {'default_value' => []})
        $rsa_intermediates = lookup('profile::pki::root_ca::rsa_intermediates', {'default_value' => []})
        $root_ca_name = lookup('profile::pki::root_ca::common_name', {'default_value' => ''})
        # lint:endignore

        class { 'pontoon::pki_root':
            intermediates => $intermediates + $rsa_intermediates,
            root_ca_name  => $root_ca_name,
            volatile      => $extra_mounts['volatile'],
        }
    }

    if $zk_enabled {
        include profile::zookeeper::server
        include profile::zookeeper::firewall
    }

    # For users to setup their 'git push'-able repos
    file { '/usr/local/bin/pontoon-setup-repo':
        ensure => present,
        source => 'puppet:///modules/pontoon/bootstrap/pontoon-setup-repo.sh',
        owner  => 'root',
        group  => 'root',
        mode   => '0555',
    }

    # XXX refactor to use profile::puppetserver::git instead
    git::clone { 'netbox-hiera':
        ensure    => present,
        origin    => 'https://netbox-exports.wikimedia.org/netbox-hiera',
        owner     => 'puppet',
        mode      => '0755',
        directory => "${git_basedir}/netbox-hiera",
    }

    file { '/etc/puppet/netbox':
        ensure => link,
        target => "${git_basedir}/netbox-hiera",
    }
}