Puppet Class: profile::puppetmaster::frontend
- Defined in:
- modules/profile/manifests/puppetmaster/frontend.pp
Overview
SPDX-License-Identifier: Apache-2.0
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 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 |
# File 'modules/profile/manifests/puppetmaster/frontend.pp', line 19
class profile::puppetmaster::frontend(
# Globals
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'),
Optional[Stdlib::HTTPUrl] $http_proxy = lookup('http_proxy'),
# Class scope
# TODO: we should probably configure theses in P:puppetmaster::common
Hash[String, Puppetmaster::Backends] $servers = lookup('puppetmaster::servers'),
# Locals
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'),
Array[Stdlib::Host] $canary_hosts = lookup('profile::puppetmaster::frontend::canary_hosts'),
Enum['chain', 'leaf', 'none'] $ssl_ca_revocation_check = lookup('profile::puppetmaster::frontend::ssl_ca_revocation_check'),
Optional[String] $extra_auth_rules = lookup('profile::puppetmaster::frontend::extra_auth_rules'),
Optional[String[1]] $mcrouter_ca_secret = lookup('profile::puppetmaster::frontend::mcrouter_ca_secret'),
# Should be defined in the private repo.
Hash[String, Any] $ip_reputation_config = lookup('profile::puppetmaster::frontend::ip_reputation_config'),
Array[String] $ip_reputation_proxies = lookup('profile::puppetmaster::frontend::ip_reputation_proxies'),
) {
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
$ca = $ca_server == $facts['networking']['fqdn']
$sync_ensure = $ca.bool2str('absent', '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': }
# TODO: this was set to let an NRPE check read the files
# now that it's gone, we should check if a more strict
# mode could be used
$signed_cert_path = "${facts['puppet_config']['master']['ssldir']}/ca/signed"
file {$signed_cert_path:
ensure => directory,
owner => 'puppet',
group => 'puppet',
mode => '0644',
recurse => true,
}
}
class { 'puppetmaster::ca_monitoring':
ensure => $ca.bool2str('present', 'absent'),
ca_root => "${facts['puppet_config']['master']['ssldir']}/ca",
}
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,
hiera_config => $profile::puppetmaster::common::hiera_config,
config => $profile::puppetmaster::common::config,
secure_private => $secure_private,
prevent_cherrypicks => $prevent_cherrypicks,
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,
netbox_hiera_enable => $profile::puppetmaster::common::netbox_hiera_enable,
enable_merge_cli => $profile::puppetmaster::common::enable_merge_cli,
}
$workers = $servers[$facts['networking']['fqdn']]
# Main site to respond to
puppetmaster::web_frontend { $web_hostname:
master => $ca_server,
workers => $workers,
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 { $facts['networking']['fqdn']:
master => $ca_server,
workers => $workers,
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':
srange => '$DOMAIN_NETWORKS',
proto => 'tcp',
port => 8140,
}
$puppetmaster_frontend_ferm = join(keys($servers), ' ')
ferm::service { 'ssh_puppet_merge':
proto => 'tcp',
port => '22',
srange => "(@resolve((${servers.keys.join(' ')})))",
}
ferm::service { 'rsync_puppet_frontends':
proto => 'tcp',
port => '873',
srange => "(@resolve((${servers.keys.join(' ')})))",
}
ferm::service { 'puppetmaster-backend':
proto => 'tcp',
port => 8141,
srange => "(@resolve((${servers.keys.join(' ')})))",
}
# Let's download the public cloud IP ranges, save them to etcd.
# This will only upload to conftool on the CA puppetmaster.
class { 'external_clouds_vendors':
ensure => 'present',
user => 'root',
manage_user => false,
conftool => $ca,
outfile => '/var/lib/puppet/volatile/external_cloud_vendors/public_clouds.json',
http_proxy => $http_proxy,
}
# Download the IP reputation data for consumption by
# various parts of the infra.
# It will be set to present if the list of reputation proxies to import isn't empty.
class { 'ip_reputation_vendors':
ensure => $ip_reputation_proxies.empty().bool2str('absent', 'present'),
user => 'root',
manage_user => false,
outfile => '/var/lib/puppet/volatile/ip_reputation_vendors/proxies.json',
proxy_families => $ip_reputation_proxies,
configuration => $ip_reputation_config,
http_proxy => $http_proxy,
}
# Sync swift rings
class { 'profile::swift::fetch_rings':
volatile_dir => '/var/lib/puppet/volatile',
}
}
|