Merge "Expose headers option of apache::vhost"

This commit is contained in:
Zuul 2022-07-30 15:01:34 +00:00 committed by Gerrit Code Review
commit cce2e3d977
3 changed files with 33 additions and 9 deletions

View File

@ -83,13 +83,22 @@
# apache::vhost ssl parameters. # apache::vhost ssl parameters.
# Optional. Default to apache::vhost 'ssl_*' defaults. # Optional. Default to apache::vhost 'ssl_*' defaults.
# #
# [*custom_wsgi_process_options*] # [*custom_wsgi_process_options*]
# (optional) gives you the oportunity to add custom process options or to # (optional) gives you the oportunity to add custom process options or to
# overwrite the default options for the WSGI main process. # overwrite the default options for the WSGI main process.
# eg. to use a virtual python environment for the WSGI process # eg. to use a virtual python environment for the WSGI process
# you could set it to: # you could set it to:
# { python-path => '/my/python/virtualenv' } # { python-path => '/my/python/virtualenv' }
# Defaults to {} # Defaults to {}
#
# [*headers*]
# (optional) Headers for the vhost.
# Defaults to undef
#
# [*request_headers*]
# (optional) Modifies collected request headers in various ways.
# Defaults to undef
#
# #
# == Dependencies # == Dependencies
# #
@ -122,6 +131,8 @@ class vitrage::wsgi::apache (
$access_log_format = false, $access_log_format = false,
$error_log_file = undef, $error_log_file = undef,
$custom_wsgi_process_options = {}, $custom_wsgi_process_options = {},
$headers = undef,
$request_headers = undef,
) { ) {
include vitrage::deps include vitrage::deps
@ -153,6 +164,8 @@ class vitrage::wsgi::apache (
wsgi_script_dir => $::vitrage::params::vitrage_wsgi_script_path, wsgi_script_dir => $::vitrage::params::vitrage_wsgi_script_path,
wsgi_script_file => 'app', wsgi_script_file => 'app',
wsgi_script_source => $::vitrage::params::vitrage_wsgi_script_source, wsgi_script_source => $::vitrage::params::vitrage_wsgi_script_source,
headers => $headers,
request_headers => $request_headers,
access_log_file => $access_log_file, access_log_file => $access_log_file,
access_log_format => $access_log_format, access_log_format => $access_log_format,
error_log_file => $error_log_file, error_log_file => $error_log_file,

View File

@ -0,0 +1,5 @@
---
features:
- |
The ``vitrage::wsgi::apache`` class now supports customizing
request/response headers added by apache.

View File

@ -19,13 +19,15 @@ describe 'vitrage::wsgi::apache' do
:wsgi_script_dir => platform_params[:wsgi_script_path], :wsgi_script_dir => platform_params[:wsgi_script_path],
:wsgi_script_file => 'app', :wsgi_script_file => 'app',
:wsgi_script_source => platform_params[:wsgi_script_source], :wsgi_script_source => platform_params[:wsgi_script_source],
:headers => nil,
:request_headers => nil,
:custom_wsgi_process_options => {},
:access_log_file => false, :access_log_file => false,
:access_log_format => false, :access_log_format => false,
:custom_wsgi_process_options => {},
)} )}
end end
describe 'when overriding parameters using different ports' do describe 'when overriding parameters' do
let :params do let :params do
{ {
:servername => 'dummy.host', :servername => 'dummy.host',
@ -40,6 +42,8 @@ describe 'vitrage::wsgi::apache' do
:custom_wsgi_process_options => { :custom_wsgi_process_options => {
'python_path' => '/my/python/path', 'python_path' => '/my/python/path',
}, },
:headers => ['set X-XSS-Protection "1; mode=block"'],
:request_headers => ['set Content-Type "application/json"'],
} }
end end
it { is_expected.to contain_class('vitrage::params') } it { is_expected.to contain_class('vitrage::params') }
@ -62,6 +66,8 @@ describe 'vitrage::wsgi::apache' do
:access_log_file => '/var/log/httpd/access_log', :access_log_file => '/var/log/httpd/access_log',
:access_log_format => 'some format', :access_log_format => 'some format',
:error_log_file => '/var/log/httpd/error_log', :error_log_file => '/var/log/httpd/error_log',
:headers => ['set X-XSS-Protection "1; mode=block"'],
:request_headers => ['set Content-Type "application/json"'],
:custom_wsgi_process_options => { :custom_wsgi_process_options => {
'python_path' => '/my/python/path', 'python_path' => '/my/python/path',
}, },