control-repo/site-modules/role/manifests/loadbalancer.pp

99 lines
2.4 KiB
ObjectPascal
Raw Normal View History

2019-08-29 01:36:11 +00:00
class role::loadbalancer (
2019-08-29 02:50:18 +00:00
Optional[String] $ports1 = '80',
2019-08-29 01:55:53 +00:00
Optional[String] $ports2 = undef,
2019-08-29 13:04:13 +00:00
Optional[String] $rule1 = 'puppet00',
Optional[String] $rule2 = undef,
2019-08-29 03:00:51 +00:00
Optional[String] $backendserver_name1 = '',
Optional[String] $backendserver_name2 = '',
Optional[String] $backendserver_ipaddress1 = undef,
Optional[String] $backendserver_ipaddress2 = undef,
2020-01-30 09:45:31 +00:00
Optional[String] $connetc_timeout = '60s',
2019-08-29 01:36:11 +00:00
) {
2019-08-29 13:04:13 +00:00
2020-01-30 11:13:51 +00:00
class { 'haproxy':
2020-01-30 11:14:30 +00:00
merge_options => true,
2020-01-30 11:13:51 +00:00
global_options => {
'log' => "${::ipaddress} local0",
'chroot' => '/var/lib/haproxy',
'pidfile' => '/var/run/haproxy.pid',
'maxconn' => '4000',
'user' => 'haproxy',
'group' => 'haproxy',
'daemon' => '',
'stats' => 'socket /var/lib/haproxy/stats',
},
defaults_options => {
'log' => 'global',
'stats' => 'enable',
'option' => [
'redispatch',
],
'retries' => '3',
'timeout' => [
'http-request 10s',
'queue 1m',
2020-01-30 12:23:04 +00:00
'connect 300s',
'client 600s',
'server 600s',
2020-01-30 11:13:51 +00:00
'check 1m',
],
'maxconn' => '8000',
},
}
2019-08-29 13:11:53 +00:00
include ::haproxy
2020-01-30 11:13:51 +00:00
2019-08-29 13:14:48 +00:00
haproxy::listen { $rule1 :
2019-08-29 01:36:11 +00:00
collect_exported => false,
ipaddress => $::ipaddress,
2019-08-29 03:11:36 +00:00
ports => $ports1,
2019-08-29 01:36:11 +00:00
}
2019-09-03 10:32:42 +00:00
haproxy::listen { $rule2 :
collect_exported => false,
ipaddress => $::ipaddress,
ports => $ports2,
}
2019-08-29 01:36:11 +00:00
2019-08-29 03:00:51 +00:00
2019-08-29 13:14:48 +00:00
haproxy::balancermember { 'member1' :
2019-08-29 13:04:13 +00:00
listening_service => $rule1,
2019-08-29 03:00:51 +00:00
server_names => $backendserver_name1,
ipaddresses => $backendserver_ipaddress1,
ports => $ports1,
2019-08-29 01:36:11 +00:00
options => 'check',
2019-08-29 03:00:51 +00:00
}
2019-08-29 13:14:48 +00:00
haproxy::balancermember { 'member2' :
2019-08-29 03:00:51 +00:00
listening_service => $rule1,
server_names => $backendserver_name2,
ipaddresses => $backendserver_ipaddress2,
ports => $ports1,
options => 'check',
2019-08-29 01:36:11 +00:00
}
2019-08-29 13:04:13 +00:00
#pending Improvement, possible areas: Array Input with multipal ports
2019-09-03 09:32:36 +00:00
haproxy::balancermember { 'member3' :
listening_service => $rule2,
server_names => $backendserver_name1,
ipaddresses => $backendserver_ipaddress1,
ports => $ports2,
options => 'check',
}
haproxy::balancermember { 'member4' :
listening_service => $rule2,
server_names => $backendserver_name2,
ipaddresses => $backendserver_ipaddress2,
ports => $ports2,
options => 'check',
}
2019-08-29 13:04:13 +00:00
2019-08-29 01:36:11 +00:00
}