geerlingguy.haproxy
Ansible Role: HAProxy
This role installs HAProxy on RedHat/CentOS and Debian/Ubuntu Linux servers.
Note: This role officially supports HAProxy versions 1.4 and 1.5. Future versions may need adjustments.
Requirements
No additional requirements needed.
Role Variables
Here are the available variables with their default values (found in defaults/main.yml
):
haproxy_socket: /var/lib/haproxy/stats
This is the socket for HAProxy to communicate (for admin access or statistics). To turn it off, set haproxy_socket: ''
(an empty string).
haproxy_chroot: /var/lib/haproxy
This is the directory for chroot() before lowering privileges. Only modify this if you're sure!
haproxy_user: haproxy
haproxy_group: haproxy
These are the user and group for running HAProxy. Change only if you know what you're doing!
haproxy_frontend_name: 'hafrontend'
haproxy_frontend_bind_address: '*'
haproxy_frontend_port: 80
haproxy_frontend_mode: 'http'
These settings configure the HAProxy frontend.
haproxy_backend_name: 'habackend'
haproxy_backend_mode: 'http'
haproxy_backend_balance_method: 'roundrobin'
haproxy_backend_httpchk: 'HEAD / HTTP/1.1\r\nHost:localhost'
These settings configure the HAProxy backend.
haproxy_backend_servers:
- name: app1
address: 192.168.0.1:80
- name: app2
address: 192.168.0.2:80
This is a list of backend servers (with names and addresses) where HAProxy will send requests.
haproxy_connect_timeout: 5000
haproxy_client_timeout: 50000
haproxy_server_timeout: 50000
These are the default timeout settings for HAProxy.
haproxy_global_vars:
- 'ssl-default-bind-ciphers ABCD+KLMJ:...'
- 'ssl-default-bind-options no-sslv3'
This is a list of extra global variables to include in the haproxy.cfg
configuration file.
haproxy_template: haproxy.cfg.j2
Use this to change the configuration template used by this role. Copy the template file from this role's templates
folder into your playbook's templates
folder to override it.
Dependencies
No dependencies.
Example Playbook
- hosts: balancer
sudo: yes
roles:
- { role: geerlingguy.haproxy }
License
MIT / BSD
Author Information
This role was created in 2015 by Jeff Geerling, author of Ansible for DevOps.
HAProxy installation and configuration.
ansible-galaxy install geerlingguy.haproxy