diff --git a/manifests/haproxy.pp b/manifests/haproxy.pp index 75bf71339..d1ba72177 100644 --- a/manifests/haproxy.pp +++ b/manifests/haproxy.pp @@ -49,6 +49,11 @@ # The IPv4, IPv6 or filesystem socket path of the syslog server. # Defaults to '/dev/log' # +# [*activate_httplog*] +# Globally activate "httplog" option (in defaults section) +# In case the listener is NOT set to "http" mode, HAProxy will fallback to "tcplog". +# Defaults to false +# # [*haproxy_globals_override*] # HAProxy global option we can append to the default base set in this class. # If you enter an already existing key, it will override the default. @@ -587,6 +592,7 @@ class tripleo::haproxy ( $haproxy_listen_bind_param = [ 'transparent' ], $haproxy_member_options = [ 'check', 'inter 2000', 'rise 2', 'fall 5' ], $haproxy_log_address = '/dev/log', + $activate_httplog = false, $haproxy_globals_override = {}, $haproxy_daemon = true, $haproxy_socket_access_level = 'user', @@ -836,16 +842,23 @@ class tripleo::haproxy ( $haproxy_daemonize = {} } + $haproxy_defaults_options = { + 'mode' => 'tcp', + 'log' => 'global', + 'retries' => '3', + 'timeout' => $haproxy_default_timeout, + 'maxconn' => $haproxy_default_maxconn, + } + if $activate_httplog { + $httplog = {'option' => 'httplog'} + } else { + $httplog = {} + } + class { '::haproxy': service_manage => $haproxy_service_manage, global_options => merge($haproxy_global_options, $haproxy_daemonize, $haproxy_globals_override), - defaults_options => { - 'mode' => 'tcp', - 'log' => 'global', - 'retries' => '3', - 'timeout' => $haproxy_default_timeout, - 'maxconn' => $haproxy_default_maxconn, - }, + defaults_options => merge($haproxy_defaults_options, $httplog), } diff --git a/releasenotes/notes/haproxy-logging-13b333a7e9d9558e.yaml b/releasenotes/notes/haproxy-logging-13b333a7e9d9558e.yaml new file mode 100644 index 000000000..c0b4aee3a --- /dev/null +++ b/releasenotes/notes/haproxy-logging-13b333a7e9d9558e.yaml @@ -0,0 +1,10 @@ +--- +features: + - | + Added new parameter to tripleo::haproxy: activate_httplog + This allows to activate the HTTP full logs in HAProxy. + +fixes: + - Fixes `bug 1733801 + `__ so we can activate + haproxy logs. diff --git a/spec/classes/tripleo_haproxy_spec.rb b/spec/classes/tripleo_haproxy_spec.rb index 966729ae6..4e924ad53 100644 --- a/spec/classes/tripleo_haproxy_spec.rb +++ b/spec/classes/tripleo_haproxy_spec.rb @@ -100,6 +100,53 @@ describe 'tripleo::haproxy' do end end + describe "default Defaults for haproxy" do + it 'should NOT activate httplog' do + is_expected.to contain_class('haproxy').with( + :defaults_options => { + "mode"=>"tcp", + "log"=>"global", + "retries"=>"3", + "timeout"=> [ + "http-request 10s", + "queue 2m", + "connect 10s", + "client 2m", + "server 2m", + "check 10s", + ], + "maxconn"=>4096, + } + ) + end + end + + describe "activate httplog" do + before :each do + params.merge!({ + :activate_httplog => true, + }) + end + it 'should activate httplog' do + is_expected.to contain_class('haproxy').with( + :defaults_options => { + "mode"=>"tcp", + "log"=>"global", + "retries"=>"3", + "timeout"=> [ + "http-request 10s", + "queue 2m", + "connect 10s", + "client 2m", + "server 2m", + "check 10s", + ], + "maxconn"=>4096, + "option"=>"httplog", + } + ) + end + end end on_supported_os.each do |os, facts| @@ -112,4 +159,4 @@ describe 'tripleo::haproxy' do end end -end \ No newline at end of file +end