A role to set up HAProxy to be used as a load balancer in a high availability and scalability context.
Currently supported platforms are:
- Ubuntu 24.04 LTS
- Ubuntu 22.04 LTS
- Ubuntu 20.04 LTS
- Debian 11 (Bullseye)
- Debian 12 (Bookworm)
This role is tested against the four latest LTS versions of HAProxy. Currently, this results in official support for the HAProxy release series:
3.0
2.8
(not supported on Ubuntu 24.04)2.6
(not supported on Ubuntu 24.04)2.4
(not supported on Debian 12 and Ubuntu 24.04)
Other versions are known to work as well but are not automatically tested.
None.
Specify a list of backends with name and IP address (Port is optional, defaults to 80
):
haproxy_backends:
- backend_name: 'backend_server_1'
backend_ip: '192.168.33.10'
backend_port: '80'
Specify the floating IP address of the frontend:
haproxy_frontend_ip: '192.168.33.100'
Sets number of processors used by HAProxy:
haproxy_nbproc: '1'
Sets number of threads used by HAProxy:
haproxy_nbthread: '2'
Mapping threads to CPU cores:
haproxy_cpumap: 'auto:1/1-2 0-1'
Variable to enable or disable the stats:
haproxy_stats_enable: 'enable'
Variable to hold the stats admin username:
haproxy_stats_admin_user: 'admin'
Variable to hold the stats admin user password:
haproxy_stats_admin_user_password: 'changeme'
Path variable pointing to the location of the HAProxy executable:
haproxy_executable_path: '/usr/sbin/haproxy'
Variable to pin the PPA version to a certain value:
haproxy_ppa_version: 'ppa:vbernat/haproxy-3.0'
Variable to pin the HAProxy version to a certain value:
haproxy_version: '3.0.*'
Variable to specify the HAProxy system user:
haproxy_user: 'haproxy'
Variable to specify the HAProxy system group:
haproxy_group: 'haproxy'
List of HAProxy dependencies to be installed:
haproxy_dependencies:
- 'software-properties-common'
Name of the HAProxy binary:
haproxy_name: 'haproxy'
Provide the path to the HAProxy configuration template:
haproxy_config_template: 'haproxy.cfg.j2'
Give the path to the HAProxy configuration directory:
haproxy_conf_dir: '/etc/haproxy/'
Give the path to the HAProxy configuration file:
haproxy_conf_file_path: "/etc/haproxy/haproxy.cfg"
Give the path to the HAProxy logging socket:
haproxy_log_socket: '/dev/log'
Specify the log level of HAProxy.
Possible values are:
emerg, alert, crit, err, warning, notice, info, debug
.
haproxy_log_level: 'info'
Give the path to the HAProxy socket file:
haproxy_socket: '/run/haproxy/admin.sock'
Whether to create a self-signed SSL certificate:
haproxy_create_self_signed_cert: true
Set country to be used for the SSL certificate:
haproxy_country_name: 'DE'
Set state to be used for the SSL certificate:
haproxy_state_or_province_name: 'Saxony'
Set locality to be used for the SSL certificate:
haproxy_locality_name: 'Dresden'
Set organization to be used for the SSL certificate:
haproxy_organization_name: 'Helmholtz-Zentrum Dresden-Rossendorf (HZDR)'
Set organization unit to be used for the SSL certificate:
haproxy_organizational_unit_name: 'FWCC / Computational Science'
Set email address to be used for the SSL certificate:
haproxy_email_address: 'hifis-help@hzdr.de'
Set common name to be used for the SSL certificate:
haproxy_common_name: 'Helmholtz Association'
Give the path to the HAProxy SSL directory:
haproxy_ssl_certificate_dir: '/etc/haproxy/ssl'
Give the path to the HAProxy Private Key file:
haproxy_ssl_certificate_key_file: "/etc/haproxy/ssl/haproxy.key"
Give the path to the HAProxy Certificate Signing Request file:
haproxy_ssl_certificate_csr_file: '/etc/haproxy/ssl/haproxy.csr'
Give the path to the HAProxy Certificate file:
haproxy_ssl_certificate_crt_file: "/etc/haproxy/ssl/haproxy.crt"
Give the path to the HAProxy PKCS12 file:
haproxy_ssl_certificate_pkcs12_file: "/etc/haproxy/ssl/haproxy.p12"
Give the path to the HAProxy Certificate Chain file:
haproxy_ssl_certificate_chain_file: "/etc/haproxy/ssl/haproxy.pem"
Give the path to the HAProxy Certificate Chain source file on the control node which will be copied to the remote host:
haproxy_ssl_cert_chain_src_file_path: "haproxy.pem"
Note: This variable is mandatory when haproxy_create_self_signed_cert
is
set to false
. The file should be PEM formatted and include at least the
public certificate and the private key.
Give the path to the DH Parameter file:
haproxy_ssl_dhparam_file: "/etc/haproxy/ssl/dhparam.pem"
Size (in bits) of the generated DH-params:
haproxy_ssl_dhparam_size: 4096
None.
Please note: This role is intended for use with, but not limited to, the
hifis.toolkit.keepalived
role.
- hosts: loadbalancers
roles:
- role: hifis.toolkit.haproxy
vars:
haproxy_frontend_ip: '192.168.33.100'
haproxy_backends:
- backend_name: 'backend_server_1'
backend_ip: '192.168.33.10'
backend_port: 80
This role was created by HIFIS Software Services
We would like to thank and give credits to the following contributors of this project: