From 6ce85f2ecd4517f309fb0a7b59cdef87dfceb1c9 Mon Sep 17 00:00:00 2001 From: Benedikt Trefzer Date: Sun, 24 Sep 2017 12:18:14 +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: I3679119ce50651e4f6dc89498d31435cde5449e8 --- manifests/wsgi/apache.pp | 90 ++++++++++--------- ...wsgi_process_options-7a09c21cd187ee0b.yaml | 5 ++ spec/classes/cloudkitty_wsgi_apache_spec.rb | 45 ++++++---- 3 files changed, 81 insertions(+), 59 deletions(-) create mode 100644 releasenotes/notes/wsgi_process_options-7a09c21cd187ee0b.yaml diff --git a/manifests/wsgi/apache.pp b/manifests/wsgi/apache.pp index 997c1da..7885ef7 100644 --- a/manifests/wsgi/apache.pp +++ b/manifests/wsgi/apache.pp @@ -66,6 +66,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['cloudkitty'] @@ -77,22 +85,23 @@ # class { 'cloudkitty::wsgi::apache': } # class cloudkitty::wsgi::apache ( - $servername = $::fqdn, - $port = 8889, - $bind_host = undef, - $path = '/', - $ssl = true, - $workers = 1, - $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 = $::os_workers, - $priority = '10', + $servername = $::fqdn, + $port = 8889, + $bind_host = undef, + $path = '/', + $ssl = true, + $workers = 1, + $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 = $::os_workers, + $priority = '10', + $custom_wsgi_process_options = {}, ) { include ::cloudkitty::deps @@ -104,29 +113,30 @@ class cloudkitty::wsgi::apache ( } ::openstacklib::wsgi::apache { 'cloudkitty_wsgi': - bind_host => $bind_host, - bind_port => $port, - group => 'cloudkitty', - 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 => 'cloudkitty', - workers => $workers, - wsgi_daemon_process => 'cloudkitty', - wsgi_process_display_name => $wsgi_process_display_name, - wsgi_process_group => 'cloudkitty', - wsgi_script_dir => $::cloudkitty::params::cloudkitty_wsgi_script_path, - wsgi_script_file => 'app', - wsgi_script_source => $::cloudkitty::params::cloudkitty_wsgi_script_source, - require => Anchor['cloudkitty::install::end'], + bind_host => $bind_host, + bind_port => $port, + group => 'cloudkitty', + 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 => 'cloudkitty', + workers => $workers, + wsgi_daemon_process => 'cloudkitty', + wsgi_process_display_name => $wsgi_process_display_name, + wsgi_process_group => 'cloudkitty', + wsgi_script_dir => $::cloudkitty::params::cloudkitty_wsgi_script_path, + wsgi_script_file => 'app', + wsgi_script_source => $::cloudkitty::params::cloudkitty_wsgi_script_source, + custom_wsgi_process_options => $custom_wsgi_process_options, + require => Anchor['cloudkitty::install::end'], } } diff --git a/releasenotes/notes/wsgi_process_options-7a09c21cd187ee0b.yaml b/releasenotes/notes/wsgi_process_options-7a09c21cd187ee0b.yaml new file mode 100644 index 0000000..aabf09f --- /dev/null +++ b/releasenotes/notes/wsgi_process_options-7a09c21cd187ee0b.yaml @@ -0,0 +1,5 @@ +--- +features: + - Add parameter to wsgi::apache to allow overwrite + and/or add additional wsgi process options. + diff --git a/spec/classes/cloudkitty_wsgi_apache_spec.rb b/spec/classes/cloudkitty_wsgi_apache_spec.rb index 624461f..63fde6c 100644 --- a/spec/classes/cloudkitty_wsgi_apache_spec.rb +++ b/spec/classes/cloudkitty_wsgi_apache_spec.rb @@ -9,31 +9,35 @@ describe 'cloudkitty::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('cloudkitty_wsgi').with( - :bind_port => 8889, - :group => 'cloudkitty', - :path => '/', - :servername => facts[:fqdn], - :ssl => true, - :threads => facts[:os_workers], - :user => 'cloudkitty', - :workers => 1, - :wsgi_daemon_process => 'cloudkitty', - :wsgi_process_group => 'cloudkitty', - :wsgi_script_dir => platform_params[:wsgi_script_path], - :wsgi_script_file => 'app', - :wsgi_script_source => platform_params[:wsgi_script_source], + :bind_port => 8889, + :group => 'cloudkitty', + :path => '/', + :servername => facts[:fqdn], + :ssl => true, + :threads => facts[:os_workers], + :user => 'cloudkitty', + :workers => 1, + :wsgi_daemon_process => 'cloudkitty', + :wsgi_process_group => 'cloudkitty', + :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 context 'when overriding parameters using different ports' do let :params do { - :servername => 'dummy.host', - :bind_host => '10.42.51.1', - :port => 12345, - :ssl => false, - :wsgi_process_display_name => 'cloudkitty', - :workers => 37, + :servername => 'dummy.host', + :bind_host => '10.42.51.1', + :port => 12345, + :ssl => false, + :wsgi_process_display_name => 'cloudkitty', + :workers => 37, + :custom_wsgi_process_options => { + 'python_path' => '/my/python/admin/path', + }, } end it { is_expected.to contain_class('cloudkitty::params') } @@ -56,6 +60,9 @@ describe 'cloudkitty::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/admin/path', + }, )} end end