add parameter to overwrite/add wsgi process options

Add two parameters to apache wsgi to allow overwrite
    and/or add additional wsgi process options.

Change-Id: I41914ce3361988d5db1695f09d21209772fdf548
This commit is contained in:
Benedikt Trefzer 2017-06-24 16:30:13 +02:00
parent f23007de76
commit 8832df01b0
3 changed files with 80 additions and 36 deletions

View File

@ -134,6 +134,14 @@
# WSGIChunkedRequest option in the vhost.
# Defaults to undef
#
# [*custom_wsgi_process_options*]
# (optional) gives you the oportunity to add custom process options or to
# overwrite the default options for the WSGI process.
# eg. to use a virtual python environment for the WSGI process
# you could set it to:
# { python-path => '/my/python/virtualenv' }
# Defaults to {}
#
# [*vhost_custom_fragment*]
# (optional) Passes a string of custom configuration
# directives to be placed at the end of the vhost configuration.
@ -147,35 +155,36 @@
# Defaults to undef.
#
define openstacklib::wsgi::apache (
$service_name = $name,
$bind_host = undef,
$bind_port = undef,
$group = undef,
$path = '/',
$priority = '10',
$servername = $::fqdn,
$ssl = false,
$ssl_ca = undef,
$ssl_cert = undef,
$ssl_certs_dir = undef,
$ssl_chain = undef,
$ssl_crl = undef,
$ssl_crl_path = undef,
$ssl_key = undef,
$threads = $::os_workers,
$user = undef,
$workers = 1,
$wsgi_daemon_process = $name,
$wsgi_process_display_name = $name,
$wsgi_process_group = $name,
$wsgi_script_dir = undef,
$wsgi_script_file = undef,
$wsgi_script_source = undef,
$wsgi_application_group = '%{GLOBAL}',
$wsgi_pass_authorization = undef,
$wsgi_chunked_request = undef,
$vhost_custom_fragment = undef,
$allow_encoded_slashes = undef,
$service_name = $name,
$bind_host = undef,
$bind_port = undef,
$group = undef,
$path = '/',
$priority = '10',
$servername = $::fqdn,
$ssl = false,
$ssl_ca = undef,
$ssl_cert = undef,
$ssl_certs_dir = undef,
$ssl_chain = undef,
$ssl_crl = undef,
$ssl_crl_path = undef,
$ssl_key = undef,
$threads = $::os_workers,
$user = undef,
$workers = 1,
$wsgi_daemon_process = $name,
$wsgi_process_display_name = $name,
$wsgi_process_group = $name,
$wsgi_script_dir = undef,
$wsgi_script_file = undef,
$wsgi_script_source = undef,
$wsgi_application_group = '%{GLOBAL}',
$wsgi_pass_authorization = undef,
$wsgi_chunked_request = undef,
$custom_wsgi_process_options = {},
$vhost_custom_fragment = undef,
$allow_encoded_slashes = undef,
) {
include ::apache
@ -205,13 +214,16 @@ define openstacklib::wsgi::apache (
mode => '0644',
}
$wsgi_daemon_process_options = {
user => $user,
group => $group,
processes => $workers,
threads => $threads,
display-name => $wsgi_process_display_name,
}
$wsgi_daemon_process_options = merge (
{
user => $user,
group => $group,
processes => $workers,
threads => $threads,
display-name => $wsgi_process_display_name,
},
$custom_wsgi_process_options,
)
$wsgi_script_aliases = hash([$path_real,"${wsgi_script_dir}/${wsgi_script_file}"])
::apache::vhost { $service_name:

View File

@ -0,0 +1,4 @@
---
features:
- Add two parameters to apache wsgi to allow overwrite
and/or add additional wsgi process options.

View File

@ -132,6 +132,34 @@ describe 'openstacklib::wsgi::apache' do
end
describe 'when wsgi_daemon_process_options are overriden' do
let :params do
{
:bind_port => 5000,
:group => 'keystone',
:ssl => true,
:user => 'keystone',
:wsgi_script_dir => '/var/www/cgi-bin/keystone',
:wsgi_script_file => 'main',
:wsgi_script_source => '/usr/share/keystone/keystone.wsgi',
:custom_wsgi_process_options => {
'user' => 'someotheruser',
'group' => 'someothergroup',
'python_path' => '/my/python/admin/path',
},
}
end
it { is_expected.to contain_apache__vhost('keystone_wsgi').with(
'wsgi_daemon_process_options' => {
'user' => 'someotheruser',
'group' => 'someothergroup',
'processes' => 1,
'threads' => global_facts[:os_workers],
'display-name' => 'keystone_wsgi',
'python_path' => '/my/python/admin/path',
},
)}
end
end
on_supported_os({