diff --git a/manifests/wsgi/apache.pp b/manifests/wsgi/apache.pp index a6d31da8..7f8f666c 100644 --- a/manifests/wsgi/apache.pp +++ b/manifests/wsgi/apache.pp @@ -134,6 +134,25 @@ # WSGIChunkedRequest option in the vhost. # Defaults to undef # +# [*set_wsgi_import_script*] +# (Optional) Enable WSGIImportScript. +# Defaults to false +# +# [*wsgi_import_script*] +# (Optional) WSGIImportScript path. +# Defaults to undef +# If not set and set_wsgi_import_script is true, defaults to the WSGI +# application module path +# +# [*wsgi_import_script_options*] +# (Optional) Sets WSGIImportScript options. +# Defaults to undef +# If not set and set_wsgi_import_script is true, push a dict as follow: +# { +# process-group => $wsgi_daemon_process, +# application-group => $wsgi_application_group, +# } +# # [*headers*] # (Optional) Headers for the vhost. # Defaults to undef @@ -224,6 +243,9 @@ define openstacklib::wsgi::apache ( $wsgi_application_group = '%{GLOBAL}', $wsgi_pass_authorization = undef, $wsgi_chunked_request = undef, + $set_wsgi_import_script = false, + $wsgi_import_script = undef, + $wsgi_import_script_options = undef, $headers = undef, $custom_wsgi_process_options = {}, $custom_wsgi_script_aliases = undef, @@ -285,6 +307,27 @@ define openstacklib::wsgi::apache ( $wsgi_script_aliases_real = $wsgi_script_aliases_default } + # Sets WSGIImportScript related options + if $set_wsgi_import_script { + if $wsgi_import_script { + $wsgi_import_script_real = $wsgi_import_script + } else { + $wsgi_import_script_real = $wsgi_script_aliases_real[$path_real] + } + if $wsgi_import_script_options { + $wsgi_import_script_options_real = $wsgi_import_script_options + } else { + $wsgi_import_script_options_real = { + process-group => $wsgi_daemon_process, + application-group => $wsgi_application_group, + } + } + } else { + $wsgi_import_script_real = undef + $wsgi_import_script_options_real = undef + } + # End of WSGIImportScript related options + ::apache::vhost { $service_name: ensure => 'present', servername => $servername, @@ -310,6 +353,8 @@ define openstacklib::wsgi::apache ( wsgi_application_group => $wsgi_application_group, wsgi_pass_authorization => $wsgi_pass_authorization, wsgi_chunked_request => $wsgi_chunked_request, + wsgi_import_script => $wsgi_import_script_real, + wsgi_import_script_options => $wsgi_import_script_options_real, headers => $headers, custom_fragment => $vhost_custom_fragment, allow_encoded_slashes => $allow_encoded_slashes, diff --git a/releasenotes/notes/wsgi-import-script-64665fae9dccf797.yaml b/releasenotes/notes/wsgi-import-script-64665fae9dccf797.yaml new file mode 100644 index 00000000..e78042c1 --- /dev/null +++ b/releasenotes/notes/wsgi-import-script-64665fae9dccf797.yaml @@ -0,0 +1,5 @@ +--- +features: + - | + Add new WSGI related options that should allow faster application startup + and loading. diff --git a/spec/defines/openstacklib_wsgi_apache_spec.rb b/spec/defines/openstacklib_wsgi_apache_spec.rb index 3dab9d7f..81df3f5d 100644 --- a/spec/defines/openstacklib_wsgi_apache_spec.rb +++ b/spec/defines/openstacklib_wsgi_apache_spec.rb @@ -197,6 +197,53 @@ describe 'openstacklib::wsgi::apache' do it { should contain_apache__vhost('keystone_wsgi').with_port(params[:bind_port]) } end + + context 'with set_wsgi_import_script enabled' 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', + :set_wsgi_import_script => true, + } + end + it { should contain_apache__vhost('keystone_wsgi').with( + :wsgi_import_script_options => { + 'process-group' => 'keystone_wsgi', + 'application-group' => '%{GLOBAL}', + } + )} + end + context 'with custom wsgi_import_script and options' 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', + :set_wsgi_import_script => true, + :wsgi_import_script => '/foo/bar', + :wsgi_import_script_options => { + 'process-group' => 'foo', + 'application-group' => 'bar', + }, + } + end + it { should contain_apache__vhost('keystone_wsgi').with( + :wsgi_import_script => '/foo/bar', + :wsgi_import_script_options => { + 'process-group' => 'foo', + 'application-group' => 'bar', + } + )} + end end on_supported_os({