From f5c158000eea623275724bf6ec6f08385716206d Mon Sep 17 00:00:00 2001 From: Arne Teuke Date: Mon, 24 Dec 2018 16:51:00 +0100 Subject: [PATCH] updates template --- manifests/params.pp | 74 ++++++++++++++++++++++++++------------ templates/haproxy_head.erb | 28 ++++++++------- 2 files changed, 67 insertions(+), 35 deletions(-) diff --git a/manifests/params.pp b/manifests/params.pp index 1d409a5..cdec5a5 100644 --- a/manifests/params.pp +++ b/manifests/params.pp @@ -52,40 +52,69 @@ # logging of HTTP request, session state and timers # @param [boolean] hy_use_dontlognull Whether to enable or disable dontlognull # option. true enables, false disables. +# @param [boolean] hy_use_http_server_close Enable or disable HTTP connection +# closing on the server side +# @param [boolean] hy_use_forward_for Enable insertion of the +# X-Forwarded-For header to requests sent to servers. +# @param [boolean] hy_use_redispatch Enable or disable session redistribution +# in case of connection failure. +# @param [string] hy_max_retries Set the number of retries to perform on a +# server after a connection failure. +# @param [string] hy_timeout_http_request Set the maximum allowed time to wait +# for a complete HTTP request. +# @param [string] hy_timeout_queue Set the maximum time to wait in the queue +# for a connection slot to be free. +# @param [string] hy_hy_timeout_connect Set the maximum time to wait for a +# connection attempt to a server to succeed. +# @param [string] hy_timeout_client Set the maximum inactivity time on the +# client side. +# @param [string] hy_timeout_server Set the maximum inactivity time on the +# server side. ############################################################################### class cd_haproxy::params ( -$pkg_ensure = 'latest', -$reqpackages = ['haproxy'], +$pkg_ensure = 'latest', +$reqpackages = ['haproxy'], -$hy_host_fqdn = "proxy.${::domain}", +$hy_host_fqdn = "proxy.${::domain}", # firewall -$hy_manage_fw = true, -$hy_fw_order_no = '50', +$hy_manage_fw = true, +$hy_fw_order_no = '50', # main config -$hy_http_port = '80', -$hy_https_port = '443', -$hy_chroot = '/var/lib/haproxy', -$hy_pid = '/var/run/haproxy.pid', -$hy_maxconn = '4000', -$hy_show_stats = true, -$hy_stats_socket = '/var/lib/haproxy/stats', -$hy_default_mode = 'http', +$hy_http_port = '80', +$hy_https_port = '443', +$hy_chroot = '/var/lib/haproxy', +$hy_pid = '/var/run/haproxy.pid', +$hy_maxconn = '4000', +$hy_show_stats = true, +$hy_stats_socket = '/var/lib/haproxy/stats', +$hy_default_mode = 'http', +$hy_use_http_server_close = true, +$hy_use_forward_for = true, +$hy_use_redispatch = true, +$hy_max_retries = '3', +$hy_timeout_http_request = '10s', +$hy_timeout_queue = '1m', +$hy_timeout_connect = '10s', +$hy_timeout_client = '1m', +$hy_timeout_server = '1m', +$hy_timeout_http_keep_alive = '10s', +$hy_timeout_check = '10s', # user -$hy_user_name = 'haproxy', -$hy_user_comment = 'haproxy user', -$hy_user_home = '/var/lib/haproxy', -$hy_user_shell = '/sbin/nologin', +$hy_user_name = 'haproxy', +$hy_user_comment = 'haproxy user', +$hy_user_home = '/var/lib/haproxy', +$hy_user_shell = '/sbin/nologin', # logging -$hy_log_target = '127.0.0.1', -$hy_log_facility = 'local2', -$hy_log_default = 'global', -$hy_use_httplog = true, -$hy_use_dontlognull = true, +$hy_log_target = '127.0.0.1', +$hy_log_facility = 'local2', +$hy_log_default = 'global', +$hy_use_httplog = true, +$hy_use_dontlognull = true, ) { @@ -99,7 +128,6 @@ $hy_main_dir = '/etc/haproxy' $hy_main_config = "${hy_main_dir}/haproxy.cfg" $hy_config_head_erb = 'cd_haproxy/haproxy_head.erb' - # includes must be last include cd_haproxy::main::config diff --git a/templates/haproxy_head.erb b/templates/haproxy_head.erb index 27a5907..37b0626 100644 --- a/templates/haproxy_head.erb +++ b/templates/haproxy_head.erb @@ -26,18 +26,22 @@ defaults <% end -%> <% if @hy_use_dontlognull == true -%> option dontlognull -<% else -%> - no option dontlognull <% end -%> - option http-server-close +<% if @hy_use_http_server_close == true -%> + option http-server-close +<% end -%> +<% if @hy_use_forward_for == true -%> option forwardfor except 127.0.0.0/8 +<% end -%> +<% if @hy_use_redispatch == true -%> 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 +<% end -%> + retries <%= @hy_max_retries %> + timeout http-request <%= @hy_timeout_http_request %> + timeout queue <%= @hy_timeout_queue %> + timeout connect <%= @hy_timeout_connect %> + timeout client <%= @hy_timeout_client %> + timeout server <%= @hy_timeout_server %> + timeout http-keep-alive <%= @hy_timeout_http_keep_alive %> + timeout check <%= @hy_timeout_check %> + maxconn <%= @hy_maxconn %>