- add haproxy server class - add haproxy profile to role - add hiera data for region specific haproxy - add selinux configuration - add certlist management - add default http and https frontends - add default stats listener
61 lines
1.8 KiB
Puppet
61 lines
1.8 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
|
|
|
|
$backends = lookup('haproxy::backend').keys
|
|
$backends.each |$backend| {
|
|
$location_environment = "${facts['country']}-${facts['region']}-${facts['environment']}"
|
|
$tag = "${location_environment}_${backend}"
|
|
Haproxy::Balancermember <<| tag == $tag |>>
|
|
}
|
|
}
|