From 63910baa1fc4d49bb3f8fb51aa998796aacc35c9 Mon Sep 17 00:00:00 2001 From: Andy Botting Date: Tue, 12 May 2020 03:43:39 +0000 Subject: [PATCH] Add Apache WSGI logging parameters for pipe/syslog Add parameters for advanced logging configurations in Apache to support piped logging and support for syslog (via mod_syslog available in Apache >= 2.5.0) Change-Id: Ia908c4c68c661a9ada6b1d408a40fefe3c6348b3 --- manifests/wsgi/apache.pp | 24 ++++++ ...pd-logs-piped-syslog-794d78fd3dfea4ac.yaml | 6 ++ spec/classes/cinder_wsgi_apache_spec.rb | 75 +++++++++++++++++-- 3 files changed, 99 insertions(+), 6 deletions(-) create mode 100644 releasenotes/notes/httpd-logs-piped-syslog-794d78fd3dfea4ac.yaml diff --git a/manifests/wsgi/apache.pp b/manifests/wsgi/apache.pp index 5f73b05e..83092232 100644 --- a/manifests/wsgi/apache.pp +++ b/manifests/wsgi/apache.pp @@ -70,6 +70,14 @@ # The log file name for the virtualhost. # Optional. Defaults to false. # +# [*access_log_pipe*] +# Specifies a pipe where Apache sends access logs for the virtualhost. +# Optional. Defaults to false. +# +# [*access_log_syslog*] +# Sends the virtualhost access log messages to syslog. +# Optional. Defaults to false. +# # [*access_log_format*] # The log format for the virtualhost. # Optional. Defaults to false. @@ -78,6 +86,14 @@ # The error log file name for the virtualhost. # Optional. Defaults to undef. # +# [*error_log_pipe*] +# Specifies a pipe where Apache sends error logs for the virtualhost. +# Optional. Defaults to undef. +# +# [*error_log_syslog*] +# Sends the virtualhost error log messages to syslog. +# Optional. Defaults to undef. +# # [*custom_wsgi_process_options*] # (optional) gives you the opportunity to add custom process options or to # overwrite the default options for the WSGI main process. @@ -114,8 +130,12 @@ class cinder::wsgi::apache ( $threads = 1, $priority = '10', $access_log_file = false, + $access_log_pipe = false, + $access_log_syslog = false, $access_log_format = false, $error_log_file = undef, + $error_log_pipe = undef, + $error_log_syslog = undef, $custom_wsgi_process_options = {}, ) { @@ -153,8 +173,12 @@ class cinder::wsgi::apache ( wsgi_script_source => $::cinder::params::cinder_wsgi_script_source, custom_wsgi_process_options => $custom_wsgi_process_options, access_log_file => $access_log_file, + access_log_pipe => $access_log_pipe, + access_log_syslog => $access_log_syslog, access_log_format => $access_log_format, error_log_file => $error_log_file, + error_log_pipe => $error_log_pipe, + error_log_syslog => $error_log_syslog, require => Anchor['cinder::install::end'], } } diff --git a/releasenotes/notes/httpd-logs-piped-syslog-794d78fd3dfea4ac.yaml b/releasenotes/notes/httpd-logs-piped-syslog-794d78fd3dfea4ac.yaml new file mode 100644 index 00000000..07cadc9e --- /dev/null +++ b/releasenotes/notes/httpd-logs-piped-syslog-794d78fd3dfea4ac.yaml @@ -0,0 +1,6 @@ +--- +features: + - | + Added parameters for advanced configuration of httpd access and error log + destinations including piped logging and syslog (see `mod_syslog`). Note + that mod_syslog requires Apache2 >= 2.5.0. diff --git a/spec/classes/cinder_wsgi_apache_spec.rb b/spec/classes/cinder_wsgi_apache_spec.rb index d9dba259..f77cde37 100644 --- a/spec/classes/cinder_wsgi_apache_spec.rb +++ b/spec/classes/cinder_wsgi_apache_spec.rb @@ -23,7 +23,12 @@ describe 'cinder::wsgi::apache' do :wsgi_script_source => platform_params[:wsgi_script_source], :custom_wsgi_process_options => {}, :access_log_file => false, + :access_log_pipe => false, + :access_log_syslog => false, :access_log_format => false, + :error_log_file => nil, + :error_log_pipe => nil, + :error_log_syslog => nil, )} end @@ -39,9 +44,6 @@ describe 'cinder::wsgi::apache' do :custom_wsgi_process_options => { 'python_path' => '/my/python/admin/path', }, - :access_log_file => '/var/log/httpd/access_log', - :access_log_format => 'some format', - :error_log_file => '/var/log/httpd/error_log' } end it { is_expected.to contain_class('cinder::params') } @@ -67,9 +69,70 @@ describe 'cinder::wsgi::apache' do :custom_wsgi_process_options => { 'python_path' => '/my/python/admin/path', }, - :access_log_file => '/var/log/httpd/access_log', - :access_log_format => 'some format', - :error_log_file => '/var/log/httpd/error_log' + )} + end + + context 'with custom access logging' do + let :params do + { + :access_log_format => 'foo', + :access_log_syslog => 'syslog:local0', + :error_log_syslog => 'syslog:local1', + } + end + + it { should contain_openstacklib__wsgi__apache('cinder_wsgi').with( + :access_log_format => params[:access_log_format], + :access_log_syslog => params[:access_log_syslog], + :error_log_syslog => params[:error_log_syslog], + )} + end + + context 'with access_log_file' do + let :params do + { + :access_log_file => '/path/to/file', + } + end + + it { should contain_openstacklib__wsgi__apache('cinder_wsgi').with( + :access_log_file => params[:access_log_file], + )} + end + + context 'with access_log_pipe' do + let :params do + { + :access_log_pipe => 'pipe', + } + end + + it { should contain_openstacklib__wsgi__apache('cinder_wsgi').with( + :access_log_pipe => params[:access_log_pipe], + )} + end + + context 'with error_log_file' do + let :params do + { + :error_log_file => '/path/to/file', + } + end + + it { should contain_openstacklib__wsgi__apache('cinder_wsgi').with( + :error_log_file => params[:error_log_file], + )} + end + + context 'with error_log_pipe' do + let :params do + { + :error_log_pipe => 'pipe', + } + end + + it { should contain_openstacklib__wsgi__apache('cinder_wsgi').with( + :error_log_pipe => params[:error_log_pipe], )} end end