Skip to content

Instantly share code, notes, and snippets.

@stackdump
Created June 30, 2017 15:15
Show Gist options
  • Save stackdump/aa23031df3efce38bf73735648bde2b3 to your computer and use it in GitHub Desktop.
Save stackdump/aa23031df3efce38bf73735648bde2b3 to your computer and use it in GitHub Desktop.
haproxy template for ansible
global
log 127.0.0.1 local2
stats socket /etc/haproxy/haproxy.stat mode 777 level admin
chroot /var/lib/haproxy
pidfile /var/run/haproxy.pid
maxconn 4000
user root
group root
daemon
# turn on stats unix socket
stats socket /var/lib/haproxy/stats level admin
defaults
mode {{ mode }}
log global
option tcplog
option dontlognull
option http-server-close
option redispatch
retries 3
timeout http-request 10s
timeout queue 1m
timeout connect 10s
timeout client 1m
timeout server 1m
timeout http-keep-alive 10s
timeout check 10s
maxconn 3000
frontend admin
bind *:8080
mode http
stats admin if TRUE
stats uri /haproxy?stats
stats enable
stats realm Haproxy\ Statistics
stats auth admin:admin
stats refresh 5s
backend cloudifycluster
{% for host in groups.proxy %}
listen {{ daemonname }} 0.0.0.0:{{ listenport }}
{% endfor %}
balance {{ balance }}
{% for host in groups.managers %}
server {{ host }} {{ hostvars[host]['ansible_default_ipv4'].address }}:{{ httpd_port }}
{% endfor %}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment