apt_update

haproxy_install 'package' do
  sensitive false
end

haproxy_config_global '' do
  chroot '/var/lib/haproxy'
  daemon true
  maxconn 256
  log '/dev/log local0'
  log_tag 'WARDEN'
  pidfile '/var/run/haproxy.pid'
  stats socket: '/var/lib/haproxy/stats level admin'
  tuning 'bufsize' => '262144'
end

haproxy_config_defaults 'defaults' do
  mode 'http'
  timeout connect: '5000ms',
          client: '5000ms',
          server: '5000ms'
  haproxy_retries 5
end

haproxy_frontend 'tcp-in' do
  mode 'tcp'
  bind '*:25565'
  default_backend 'tcp-servers'
end

haproxy_backend 'tcp-servers' do
  mode 'tcp'
  server ['server2 71.197.230.171:25565 maxconn 32']
end

haproxy_service 'haproxy' do
  action %i(create enable start)
end
