User:Razzi/Set up haproxy on mediawiki-vagrant
Appearance
With the following diff to mediawiki-vagrant:
mediawiki-vagrant $ git diff
diff --git a/puppet/manifests/site.pp b/puppet/manifests/site.pp
index 14a1266f..934d7df9 100644
--- a/puppet/manifests/site.pp
+++ b/puppet/manifests/site.pp
@@ -54,3 +54,5 @@ File {
# Assign classes to nodes via hiera
# See hiera.yaml and hieradata/*.yaml
hiera_include('classes')
+
+class { 'haproxy': }
diff --git a/puppet/modules/haproxy/templates/haproxy.cfg.erb b/puppet/modules/haproxy/templates/haproxy.cfg.erb
index 982748c9..bd5abacf 100644
--- a/puppet/modules/haproxy/templates/haproxy.cfg.erb
+++ b/puppet/modules/haproxy/templates/haproxy.cfg.erb
@@ -17,6 +17,20 @@ defaults
retries 3
option redispatch
maxconn 2000
- contimeout 50000
- clitimeout 500000
- srvtimeout 500000
+ timeout connect 50000
+ timeout client 500000
+ timeout server 500000
+
+listen mariadb-s1
+ bind 0.0.0.0:3311
+ mode tcp
+ option tcplog
+ balance roundrobin
+ # option log-health-checks
+ log /dev/log local0 crit
+ # option tcpka
+ # option mysql-check user haproxy
+ server wmf2676 10.0.2.2:9999 weight 1 check inter 3s fall 20 rise 99999999
+ # server clouddb1017.local 10.0.0.11:3311 check backup
+ # server clouddb1013.local 10.0.0.10:3311 weight 1 check inter 3s fall 20 rise 99999999
+ # server clouddb1017.local 10.0.0.11:3311 check backup
Running vagrant provision sets up haproxy which will listen on 3311.
From the host, start a netcat server:
mediawiki-vagrant $ nc -k -vl 127.0.0.1 9999
From vagrant, connect netcat to haproxy:
vagrant@mediawiki-vagrant:/vagrant/puppet$ nc localhost 3311
If haproxy errors:
haproxy[9115]: proxy mariadb-s1 has no server available!
Ensure the netcat server is running, and restart haproxy:
sudo systemctl restart haproxy