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:haproxyhosts:alluser:userwithsudoaccesssudo:Truetags:haproxyvars_files:- "vars/main.yml"tasks:# haproxy package for Ubuntu- include:tasks/haproxy-apt.yml# Specific haproxy tasks follow here- name:Copyhaproxylogrotatefileaction:> copy src=files/haproxy.logrotate dest=/etc/logrotate.d/haproxymode=0644owner=rootgroup=root- name:Createhaproxyrsyslogconfigurationaction:> copy src=files/haproxy-rsyslog. [Read More]

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. [Read More]