How To Create an Ansible Playbook to Configure HAProxy

This is the continuation for Setup a simple HAproxy config It explains how to create an Ansible playbook to automate the haproxy configuration. If you’d like to find out more about Ansible you can read up on it on their website: http://www.ansible.com --- # Set up and configure an HaProxy server (Ubuntu flavor) - name: haproxy hosts: all user: userwithsudoaccess sudo: True tags: haproxy vars_files: - "vars/main.yml" tasks: # haproxy package for Ubuntu - include: tasks/haproxy-apt. []

Setup a Simple HAProxy Config

Here’s simple haproxy configuration to get you started, you probably want to stick this under /etc/haproxy/haproxy.cfg global log 127.0.0.1 local0 log 127.0.0.1 local1 notice maxconn 4096 user haproxy group haproxy daemon defaults log global mode http option httplog option dontlognull retries 3 option redispatch maxconn 4096 contimeout 5000 clitimeout 50000 srvtimeout 50000 stats enable stats auth admin:password stats uri /monitor stats refresh 5s option httpchk GET /status retries 5 option redispatch errorfile 503 /etc/haproxy/errors/503. []