puppet-prod/site/profiles/manifests/haproxy/server.pp
Ben Vincent 105bf1b09d feat: add puppetboard backend
- add balancemember to puppetboard nodes
- add be_puppetboard to haproxxy
- add puppetboard.main.unkin.net to haproxy altnames
- add puppetboard to backend mapping
- change way backends are registered in haproxy
2024-04-06 04:20:39 +11:00

69 lines
2.0 KiB
Puppet

# configure a haproxy server
class profiles::haproxy::server (
Hash $globals = {},
Hash $defaults = {},
){
# default global/defaults arrays
$global_options = {
'log' => "${facts['networking']['ip']} local0",
'chroot' => '/var/lib/haproxy',
'pidfile' => '/var/run/haproxy.pid',
'maxconn' => '4000',
'user' => 'haproxy',
'group' => 'haproxy',
'daemon' => '',
'stats' => 'socket /var/lib/haproxy/stats',
}
$default_options = {
'log' => 'global',
'stats' => 'enable',
'option' => ['redispatch'],
'retries' => '3',
'timeout' => [
'http-request 10s',
'queue 1m',
'connect 10s',
'client 1m',
'server 1m',
'check 10s',
],
'maxconn' => '8000',
}
# merge the default globals/defaults with those provided as params
$merged_global_options = merge($global_options, $globals)
$merged_default_options = merge($default_options, $defaults)
# manage selinux
include profiles::haproxy::selinux
# create the haproxy service/instance
class { 'haproxy':
global_options => $merged_global_options,
defaults_options => $merged_default_options,
require => Class['profiles::haproxy::selinux']
}
include profiles::haproxy::certlist # manage the certificate list file
include profiles::haproxy::mappings # manage the domain to backend mappings
include profiles::haproxy::ls_stats # default status listener
include profiles::haproxy::fe_http # default http frontend
include profiles::haproxy::fe_https # default https frontend
# for each backend:
$backends = lookup('profiles::haproxy::backends')
$backends.each |$backend, $data| {
# create backend
haproxy::backend { $backend:
* => $data,
}
# collect exported resources
$location_environment = "${facts['country']}-${facts['region']}-${facts['environment']}"
$tag = "${backend}_${location_environment}"
Haproxy::Balancermember <<| tag == $tag |>>
}
}