Puppet Class: profile::puppetmaster::frontend

Defined in:
modules/profile/manifests/puppetmaster/frontend.pp

Overview

Parameters:

  • config (Hash) (defaults to: lookup('profile::puppetmaster::frontend::config'))
  • secure_private (Boolean) (defaults to: lookup('profile::puppetmaster::frontend::secure_private'))
  • web_hostname (String) (defaults to: lookup('profile::puppetmaster::frontend::web_hostname'))
  • prevent_cherrypicks (Boolean) (defaults to: lookup('profile::puppetmaster::frontend::prevent_cherrypicks'))
  • ca_server (Stdlib::Host) (defaults to: lookup('puppet_ca_server'))
  • ca_source (Stdlib::Filesource) (defaults to: lookup('puppet_ca_source'))
  • manage_ca_file (Boolean) (defaults to: lookup('manage_puppet_ca_file'))
  • allow_from (Array[String]) (defaults to: lookup('profile::puppetmaster::frontend::allow_from'))
  • extra_auth_rules (String) (defaults to: lookup('profile::puppetmaster::frontend::extra_auth_rules'))
  • monitor_signed_certs (Boolean) (defaults to: lookup('profile::puppetmaster::frontend::monitor_signed_certs'))
  • signed_certs_warning (Integer) (defaults to: lookup('profile::puppetmaster::frontend::signed_certs_warning'))
  • signed_certs_critical (Integer) (defaults to: lookup('profile::puppetmaster::frontend::signed_certs_critical'))
  • canary_hosts (Array[Stdlib::Host]) (defaults to: lookup('profile::puppetmaster::frontend::canary_hosts'))
  • servers (Hash[String, Puppetmaster::Backends]) (defaults to: lookup('puppetmaster::servers'))
  • locale_servers (Hash[Stdlib::Host, Stdlib::Host]) (defaults to: lookup('puppetmaster::locale_servers'))
  • ssl_ca_revocation_check (Enum['chain', 'leaf', 'none']) (defaults to: lookup('profile::puppetmaster::frontend::ssl_ca_revocation_check'))
  • http_proxy (Optional[Stdlib::HTTPUrl]) (defaults to: lookup('http_proxy'))
  • mcrouter_ca_secret (Optional[String[1]]) (defaults to: lookup('profile::puppetmaster::frontend::mcrouter_ca_secret', {'default_value' => undef}))


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
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
# File 'modules/profile/manifests/puppetmaster/frontend.pp', line 3

class profile::puppetmaster::frontend(
    Hash                $config                  = lookup('profile::puppetmaster::frontend::config'),
    Boolean             $secure_private          = lookup('profile::puppetmaster::frontend::secure_private'),
    String              $web_hostname            = lookup('profile::puppetmaster::frontend::web_hostname'),
    Boolean             $prevent_cherrypicks     = lookup('profile::puppetmaster::frontend::prevent_cherrypicks'),
    Stdlib::Host        $ca_server               = lookup('puppet_ca_server'),
    Stdlib::Filesource  $ca_source               = lookup('puppet_ca_source'),
    Boolean             $manage_ca_file          = lookup('manage_puppet_ca_file'),
    Array[String]       $allow_from              = lookup('profile::puppetmaster::frontend::allow_from'),
    String              $extra_auth_rules        = lookup('profile::puppetmaster::frontend::extra_auth_rules'),
    Boolean             $monitor_signed_certs    = lookup('profile::puppetmaster::frontend::monitor_signed_certs'),
    Integer             $signed_certs_warning    = lookup('profile::puppetmaster::frontend::signed_certs_warning'),
    Integer             $signed_certs_critical   = lookup('profile::puppetmaster::frontend::signed_certs_critical'),
    Array[Stdlib::Host] $canary_hosts            = lookup('profile::puppetmaster::frontend::canary_hosts'),
    Hash[String, Puppetmaster::Backends] $servers          = lookup('puppetmaster::servers'),
    Hash[Stdlib::Host, Stdlib::Host]     $locale_servers   = lookup('puppetmaster::locale_servers'),
    Enum['chain', 'leaf', 'none'] $ssl_ca_revocation_check = lookup('profile::puppetmaster::frontend::ssl_ca_revocation_check'),
    Optional[Stdlib::HTTPUrl] $http_proxy        = lookup('http_proxy'),
    Optional[String[1]] $mcrouter_ca_secret      = lookup('profile::puppetmaster::frontend::mcrouter_ca_secret',
                                                          {'default_value' => undef}),
) {
    ensure_packages([
      'libapache2-mod-passenger',
      'age'  # useful file encryption tool, modern gpg replacement
    ])

    backup::set { 'var-lib-puppet-ssl': }
    backup::set { 'var-lib-puppet-volatile': }
    if $manage_ca_file {
        file{[$facts['puppet_config']['master']['localcacert'],
              "${facts['puppet_config']['master']['ssldir']}/ca/ca_crt.pem"]:
            ensure => file,
            owner  => 'puppet',
            group  => 'puppet',
            source => $ca_source,
        }
    }
    # Puppet frontends are git masters at least for their datacenter
    if $ca_server == $::fqdn {
        $ca = true
        $sync_ensure = 'absent'
    } else {
        $ca = false
        $sync_ensure = 'present'
    }

    if $ca {
        # Ensure cergen is present for managing TLS keys and
        # x509 certificates signed by the Puppet CA.
        class { 'cergen': }
        if $mcrouter_ca_secret {
            class { 'cergen::mcrouter_ca':
                ca_secret => $mcrouter_ca_secret,
            }
        }

        # Ship cassandra-ca-manager (precursor of cergen)
        class { 'cassandra::ca_manager': }

        # Ensure nagios can read the signed certs
        $signed_cert_path = "${facts['puppet_config']['master']['ssldir']}/ca/signed"
        file {$signed_cert_path:
            ensure  => directory,
            owner   => 'puppet',
            group   => 'puppet',
            mode    => '0644',
            recurse => true,
        }
        $monitor_ensure = ($monitor_signed_certs and $ca).bool2str('present', 'absent')
        file {'/usr/local/lib/nagios/plugins/nrpe_check_puppetca_expired_certs':
            ensure => $monitor_ensure,
            mode   => '0555',
            source => 'puppet:///modules/profile/puppetmaster/nrpe_check_puppetca_expired_certs.sh',
        }
        nrpe::monitor_service {'puppetca_expired_certs':
            ensure         => $monitor_ensure,
            description    => 'Puppet CA expired certs',
            check_interval => 60,  # minutes
            timeout        => 60,  # seconds
            nrpe_command   => "/usr/local/lib/nagios/plugins/nrpe_check_puppetca_expired_certs ${signed_cert_path} ${signed_certs_warning} ${signed_certs_critical}",
            notes_url      => 'https://wikitech.wikimedia.org/wiki/Puppet#Renew_agent_certificate',
        }
    }

    class { 'httpd':
        remove_default_ports => true,
        modules              => ['proxy', 'proxy_http', 'proxy_balancer',
                                'passenger', 'rewrite', 'lbmethod_byrequests'],
    }

    class { 'puppetmaster::ca_server':
        master => $ca_server
    }

    $common_config = {
        'ca'              => $ca,
        'ca_server'       => $ca_server,
        'stringify_facts' => false,
    }

    $base_config = merge($config, $common_config)

    class { 'profile::puppetmaster::common':
        base_config => $base_config,
    }

    class { 'puppetmaster':
        bind_address        => '*',
        server_type         => 'frontend',
        is_git_master       => true,
        config              => $profile::puppetmaster::common::config,
        secure_private      => $secure_private,
        prevent_cherrypicks => $prevent_cherrypicks,
        allow_from          => $allow_from,
        extra_auth_rules    => $extra_auth_rules,
        ca_server           => $ca_server,
        ssl_verify_depth    => $profile::puppetmaster::common::ssl_verify_depth,
        servers             => $servers,
        upload_facts        => $ca, # We only want to upload from one place
        http_proxy          => $http_proxy,
    }

    $workers = $servers[$facts['fqdn']]
    $locale_server = $locale_servers[$facts['fqdn']]
    # Main site to respond to
    puppetmaster::web_frontend { $web_hostname:
        master                  => $ca_server,
        workers                 => $workers,
        locale_server           => $locale_server,
        bind_address            => $::puppetmaster::bind_address,
        priority                => 40,
        ssl_ca_revocation_check => $ssl_ca_revocation_check,
        canary_hosts            => $canary_hosts,
        ssl_verify_depth        => $profile::puppetmaster::common::ssl_verify_depth,
    }

    # On all the puppetmasters, we should respond
    # to the FQDN too, in case we point them explicitly
    puppetmaster::web_frontend { $::fqdn:
        master                  => $ca_server,
        workers                 => $workers,
        locale_server           => $locale_server,
        bind_address            => $::puppetmaster::bind_address,
        priority                => 50,
        ssl_ca_revocation_check => $ssl_ca_revocation_check,
        canary_hosts            => $canary_hosts,
        ssl_verify_depth        => $profile::puppetmaster::common::ssl_verify_depth,
    }

    # Run the rsync servers on all puppetmaster frontends, and activate
    # timer jobs syncing from the master
    class { 'puppetmaster::rsync':
        server      => $ca_server,
        sync_ensure => $sync_ensure,
        frontends   => keys($servers),
    }

    ferm::service { 'puppetmaster-frontend':
        proto => 'tcp',
        port  => 8140,
    }

    $puppetmaster_frontend_ferm = join(keys($servers), ' ')
    ferm::service { 'ssh_puppet_merge':
        proto  => 'tcp',
        port   => '22',
        srange => "(@resolve((${puppetmaster_frontend_ferm})) @resolve((${puppetmaster_frontend_ferm}), AAAA))"
    }

    ferm::service { 'rsync_puppet_frontends':
        proto  => 'tcp',
        port   => '873',
        srange => "(@resolve((${puppetmaster_frontend_ferm})) @resolve((${puppetmaster_frontend_ferm}), AAAA))"
    }
    ferm::service { 'puppetmaster-backend':
        proto  => 'tcp',
        port   => 8141,
        srange => "(@resolve((${puppetmaster_frontend_ferm})) @resolve((${puppetmaster_frontend_ferm}), AAAA))"
    }
}