Add support for multiple WSGI script aliases

This patch adds a new parameter named custom_wsgi_script_aliases
to the openstacklib::wsgi::apache class. This can be used to specify
extra WSGI script alias statements for the apache::vhost resource
which is merged with the default one calculated using $path,
$wsgi_script_dir and $wsgi_script_file.

This is the final piece to be able to move keystone::wsgi::apache
over to using openstacklib::wsgi::apache.

Change-Id: I31096140a6f355ec99496053fb06ce6c73094180
This commit is contained in:
Tobias Urdin
2018-04-05 17:24:29 +02:00
parent 0db9730c51
commit 809396defb
3 changed files with 49 additions and 23 deletions

View File

@@ -146,6 +146,12 @@
# { python-path => '/my/python/virtualenv' } # { python-path => '/my/python/virtualenv' }
# Defaults to {} # Defaults to {}
# #
# [*custom_wsgi_script_aliases*]
# (Optional) Pass a hash with any extra WSGI script aliases that you want
# to load for the same vhost, this is then combined with the default
# script alias built usin $path, $wsgi_script_dir and $wsgi_script_file.
# Defaults to undef
#
# [*vhost_custom_fragment*] # [*vhost_custom_fragment*]
# (Optional) Passes a string of custom configuration # (Optional) Passes a string of custom configuration
# directives to be placed at the end of the vhost configuration. # directives to be placed at the end of the vhost configuration.
@@ -220,6 +226,7 @@ define openstacklib::wsgi::apache (
$wsgi_chunked_request = undef, $wsgi_chunked_request = undef,
$headers = undef, $headers = undef,
$custom_wsgi_process_options = {}, $custom_wsgi_process_options = {},
$custom_wsgi_script_aliases = undef,
$vhost_custom_fragment = undef, $vhost_custom_fragment = undef,
$allow_encoded_slashes = undef, $allow_encoded_slashes = undef,
$access_log_file = false, $access_log_file = false,
@@ -268,7 +275,14 @@ define openstacklib::wsgi::apache (
}, },
$custom_wsgi_process_options, $custom_wsgi_process_options,
) )
$wsgi_script_aliases = hash([$path_real,"${wsgi_script_dir}/${wsgi_script_file}"])
$wsgi_script_aliases_default = hash([$path_real,"${wsgi_script_dir}/${wsgi_script_file}"])
if $custom_wsgi_script_aliases {
$wsgi_script_aliases_real = merge($wsgi_script_aliases_default, $custom_wsgi_script_aliases)
} else {
$wsgi_script_aliases_real = $wsgi_script_aliases_default
}
::apache::vhost { $service_name: ::apache::vhost { $service_name:
ensure => 'present', ensure => 'present',
@@ -291,7 +305,7 @@ define openstacklib::wsgi::apache (
wsgi_daemon_process => $wsgi_daemon_process, wsgi_daemon_process => $wsgi_daemon_process,
wsgi_daemon_process_options => $wsgi_daemon_process_options, wsgi_daemon_process_options => $wsgi_daemon_process_options,
wsgi_process_group => $wsgi_process_group, wsgi_process_group => $wsgi_process_group,
wsgi_script_aliases => $wsgi_script_aliases, wsgi_script_aliases => $wsgi_script_aliases_real,
wsgi_application_group => $wsgi_application_group, wsgi_application_group => $wsgi_application_group,
wsgi_pass_authorization => $wsgi_pass_authorization, wsgi_pass_authorization => $wsgi_pass_authorization,
wsgi_chunked_request => $wsgi_chunked_request, wsgi_chunked_request => $wsgi_chunked_request,

View File

@@ -0,0 +1,7 @@
---
features:
- |
openstacklib::wsgi::apache now has a parameter named custom_wsgi_script_aliases
which can be used to add more WSGI script alises to the apache::vhost resource.
These additional WSGI script aliases is added upon the default script alias which
is $path combined with $wsgi_script_dir and $wsgi_script_file.

View File

@@ -101,28 +101,30 @@ describe 'openstacklib::wsgi::apache' do
describe 'when overriding parameters' do describe 'when overriding parameters' do
let :params do let :params do
{ {
:wsgi_script_dir => '/var/www/cgi-bin/keystone', :wsgi_script_dir => '/var/www/cgi-bin/keystone',
:wsgi_script_file => 'main', :wsgi_script_file => 'main',
:wsgi_script_source => '/usr/share/keystone/keystone.wsgi', :wsgi_script_source => '/usr/share/keystone/keystone.wsgi',
:wsgi_pass_authorization => 'On', :wsgi_pass_authorization => 'On',
:wsgi_chunked_request => 'On', :wsgi_chunked_request => 'On',
:headers => 'set X-Frame-Options "DENY"', :custom_wsgi_script_aliases => { '/admin' => '/var/www/cgi-bin/keystone/admin' },
:servername => 'dummy.host', :headers => 'set X-Frame-Options "DENY"',
:bind_host => '10.42.51.1', :servername => 'dummy.host',
:bind_port => 4142, :bind_host => '10.42.51.1',
:user => 'keystone', :bind_port => 4142,
:group => 'keystone', :user => 'keystone',
:ssl => false, :group => 'keystone',
:workers => 37, :ssl => false,
:vhost_custom_fragment => 'LimitRequestFieldSize 81900', :workers => 37,
:allow_encoded_slashes => 'on', :vhost_custom_fragment => 'LimitRequestFieldSize 81900',
:access_log_file => '/var/log/httpd/access_log', :allow_encoded_slashes => 'on',
:access_log_syslog => 'syslog:local0', :access_log_file => '/var/log/httpd/access_log',
:access_log_format => 'some format', :access_log_syslog => 'syslog:local0',
:error_log_file => '/var/log/httpd/error_log', :access_log_format => 'some format',
:error_log_syslog => 'syslog:local0' :error_log_file => '/var/log/httpd/error_log',
:error_log_syslog => 'syslog:local0'
} }
end end
it { is_expected.to contain_apache__vhost('keystone_wsgi').with( it { is_expected.to contain_apache__vhost('keystone_wsgi').with(
'servername' => 'dummy.host', 'servername' => 'dummy.host',
'ip' => '10.42.51.1', 'ip' => '10.42.51.1',
@@ -138,7 +140,10 @@ describe 'openstacklib::wsgi::apache' do
'display-name' => 'keystone_wsgi', 'display-name' => 'keystone_wsgi',
}, },
'wsgi_process_group' => 'keystone_wsgi', 'wsgi_process_group' => 'keystone_wsgi',
'wsgi_script_aliases' => { '/' => "/var/www/cgi-bin/keystone/main" }, 'wsgi_script_aliases' => {
'/' => '/var/www/cgi-bin/keystone/main',
'/admin' => '/var/www/cgi-bin/keystone/admin',
},
'wsgi_application_group' => '%{GLOBAL}', 'wsgi_application_group' => '%{GLOBAL}',
'wsgi_pass_authorization' => 'On', 'wsgi_pass_authorization' => 'On',
'wsgi_chunked_request' => 'On', 'wsgi_chunked_request' => 'On',