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

66 lines
1.7 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,
2019-08-29 01:36:11 +00:00
) {
2019-08-29 13:04:13 +00:00
2019-08-29 13:11:53 +00:00
include ::haproxy
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
}