From dfeb00ade4a802c201cd72cf48379708f3d909b0 Mon Sep 17 00:00:00 2001 From: Benedikt Trefzer Date: Tue, 19 Sep 2017 14:22:07 +0200 Subject: [PATCH] add parameter to overwrite/add wsgi process options Add parameter to apache_wsgi to allow overwrite and/or add additional wsgi process options. This possibility was added to openstacklib with Change-Id: I41914ce3361988d5db1695f09d21209772fdf548 Change-Id: I2bcd2068f2d2968a63c29247d4e65815be33b176 --- manifests/wsgi/apache.pp | 88 +++++++++++-------- ...wsgi_process_options-c96a71aca0c2e1e5.yaml | 4 + spec/classes/gnocchi_wsgi_apache_spec.rb | 33 ++++--- 3 files changed, 73 insertions(+), 52 deletions(-) create mode 100644 releasenotes/notes/wsgi_process_options-c96a71aca0c2e1e5.yaml diff --git a/manifests/wsgi/apache.pp b/manifests/wsgi/apache.pp index 44a89c0a..7a9611d2 100644 --- a/manifests/wsgi/apache.pp +++ b/manifests/wsgi/apache.pp @@ -70,6 +70,14 @@ # apache::vhost ssl parameters. # Optional. Default to apache::vhost 'ssl_*' defaults. # +# [*custom_wsgi_process_options*] +# (optional) gives you the oportunity to add custom process options or to +# overwrite the default options for the WSGI main process. +# eg. to use a virtual python environment for the WSGI process +# you could set it to: +# { python-path => '/my/python/virtualenv' } +# Defaults to {} +# # == Dependencies # # requires Class['apache'] & Class['gnocchi'] @@ -81,22 +89,23 @@ # class { 'gnocchi::wsgi::apache': } # class gnocchi::wsgi::apache ( - $servername = $::fqdn, - $port = 8041, - $bind_host = undef, - $path = '/', - $ssl = true, - $workers = $::os_workers, - $ssl_cert = undef, - $ssl_key = undef, - $ssl_chain = undef, - $ssl_ca = undef, - $ssl_crl_path = undef, - $ssl_crl = undef, - $ssl_certs_dir = undef, - $wsgi_process_display_name = undef, - $threads = 1, - $priority = '10', + $servername = $::fqdn, + $port = 8041, + $bind_host = undef, + $path = '/', + $ssl = true, + $workers = $::os_workers, + $ssl_cert = undef, + $ssl_key = undef, + $ssl_chain = undef, + $ssl_ca = undef, + $ssl_crl_path = undef, + $ssl_crl = undef, + $ssl_certs_dir = undef, + $wsgi_process_display_name = undef, + $threads = 1, + $priority = '10', + $custom_wsgi_process_options = {}, ) { include ::gnocchi::deps @@ -108,28 +117,29 @@ class gnocchi::wsgi::apache ( } ::openstacklib::wsgi::apache { 'gnocchi_wsgi': - bind_host => $bind_host, - bind_port => $port, - group => 'gnocchi', - path => $path, - priority => $priority, - servername => $servername, - ssl => $ssl, - ssl_ca => $ssl_ca, - ssl_cert => $ssl_cert, - ssl_certs_dir => $ssl_certs_dir, - ssl_chain => $ssl_chain, - ssl_crl => $ssl_crl, - ssl_crl_path => $ssl_crl_path, - ssl_key => $ssl_key, - threads => $threads, - user => 'gnocchi', - workers => $workers, - wsgi_daemon_process => 'gnocchi', - wsgi_process_display_name => $wsgi_process_display_name, - wsgi_process_group => 'gnocchi', - wsgi_script_dir => $::gnocchi::params::gnocchi_wsgi_script_path, - wsgi_script_file => 'app', - wsgi_script_source => $::gnocchi::params::gnocchi_wsgi_script_source, + bind_host => $bind_host, + bind_port => $port, + group => 'gnocchi', + path => $path, + priority => $priority, + servername => $servername, + ssl => $ssl, + ssl_ca => $ssl_ca, + ssl_cert => $ssl_cert, + ssl_certs_dir => $ssl_certs_dir, + ssl_chain => $ssl_chain, + ssl_crl => $ssl_crl, + ssl_crl_path => $ssl_crl_path, + ssl_key => $ssl_key, + threads => $threads, + user => 'gnocchi', + workers => $workers, + wsgi_daemon_process => 'gnocchi', + wsgi_process_display_name => $wsgi_process_display_name, + wsgi_process_group => 'gnocchi', + wsgi_script_dir => $::gnocchi::params::gnocchi_wsgi_script_path, + wsgi_script_file => 'app', + wsgi_script_source => $::gnocchi::params::gnocchi_wsgi_script_source, + custom_wsgi_process_options => $custom_wsgi_process_options, } } diff --git a/releasenotes/notes/wsgi_process_options-c96a71aca0c2e1e5.yaml b/releasenotes/notes/wsgi_process_options-c96a71aca0c2e1e5.yaml new file mode 100644 index 00000000..1c678912 --- /dev/null +++ b/releasenotes/notes/wsgi_process_options-c96a71aca0c2e1e5.yaml @@ -0,0 +1,4 @@ +--- +features: + - Add parameter to wsgi::apache to allow overwrite + and/or add additional wsgi process options. diff --git a/spec/classes/gnocchi_wsgi_apache_spec.rb b/spec/classes/gnocchi_wsgi_apache_spec.rb index bdb2cc06..2be7efb8 100644 --- a/spec/classes/gnocchi_wsgi_apache_spec.rb +++ b/spec/classes/gnocchi_wsgi_apache_spec.rb @@ -9,19 +9,20 @@ describe 'gnocchi::wsgi::apache' do it { is_expected.to contain_class('apache::mod::wsgi') } it { is_expected.to contain_class('apache::mod::ssl') } it { is_expected.to contain_openstacklib__wsgi__apache('gnocchi_wsgi').with( - :bind_port => 8041, - :group => 'gnocchi', - :path => '/', - :servername => facts[:fqdn], - :ssl => true, - :threads => 1, - :user => 'gnocchi', - :workers => facts[:os_workers], - :wsgi_daemon_process => 'gnocchi', - :wsgi_process_group => 'gnocchi', - :wsgi_script_dir => platform_params[:wsgi_script_path], - :wsgi_script_file => 'app', - :wsgi_script_source => platform_params[:wsgi_script_source], + :bind_port => 8041, + :group => 'gnocchi', + :path => '/', + :servername => facts[:fqdn], + :ssl => true, + :threads => 1, + :user => 'gnocchi', + :workers => facts[:os_workers], + :wsgi_daemon_process => 'gnocchi', + :wsgi_process_group => 'gnocchi', + :wsgi_script_dir => platform_params[:wsgi_script_path], + :wsgi_script_file => 'app', + :wsgi_script_source => platform_params[:wsgi_script_source], + :custom_wsgi_process_options => {}, )} end @@ -35,6 +36,9 @@ describe 'gnocchi::wsgi::apache' do :workers => 8, :wsgi_process_display_name => 'gnocchi', :threads => 2, + :custom_wsgi_process_options => { + 'python_path' => '/my/python/path', + }, } end @@ -58,6 +62,9 @@ describe 'gnocchi::wsgi::apache' do :wsgi_script_dir => platform_params[:wsgi_script_path], :wsgi_script_file => 'app', :wsgi_script_source => platform_params[:wsgi_script_source], + :custom_wsgi_process_options => { + 'python_path' => '/my/python/path', + }, )} end end