From 8832df01b0b089e6a3f3210bdbb575bbc3de0d30 Mon Sep 17 00:00:00 2001 From: Benedikt Trefzer Date: Sat, 24 Jun 2017 16:30:13 +0200 Subject: [PATCH] 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 --- manifests/wsgi/apache.pp | 84 +++++++++++-------- ...wsgi_process_options-5ff706a7beb9b893.yaml | 4 + spec/defines/openstacklib_wsgi_apache_spec.rb | 28 +++++++ 3 files changed, 80 insertions(+), 36 deletions(-) create mode 100644 releasenotes/notes/wsgi_process_options-5ff706a7beb9b893.yaml diff --git a/manifests/wsgi/apache.pp b/manifests/wsgi/apache.pp index 917c0649..b669837b 100644 --- a/manifests/wsgi/apache.pp +++ b/manifests/wsgi/apache.pp @@ -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: diff --git a/releasenotes/notes/wsgi_process_options-5ff706a7beb9b893.yaml b/releasenotes/notes/wsgi_process_options-5ff706a7beb9b893.yaml new file mode 100644 index 00000000..426826a4 --- /dev/null +++ b/releasenotes/notes/wsgi_process_options-5ff706a7beb9b893.yaml @@ -0,0 +1,4 @@ +--- +features: + - Add two parameters to apache wsgi to allow overwrite + and/or add additional wsgi process options. diff --git a/spec/defines/openstacklib_wsgi_apache_spec.rb b/spec/defines/openstacklib_wsgi_apache_spec.rb index 51dbe332..a23884be 100644 --- a/spec/defines/openstacklib_wsgi_apache_spec.rb +++ b/spec/defines/openstacklib_wsgi_apache_spec.rb @@ -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({