From 1584887d9d0c85bb0d29efcdd54c833bc1ceceba Mon Sep 17 00:00:00 2001 From: Benedikt Trefzer Date: Mon, 18 Sep 2017 11:41:23 +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: I1d50ee01ebfdfaeb2ac02bc5b944f5b996cbc2db --- manifests/wsgi/apache_api.pp | 88 ++++++++++-------- manifests/wsgi/apache_placement.pp | 90 ++++++++++--------- ...wsgi_process_options-f8e93a0bb83e0bc8.yaml | 4 + spec/classes/nova_wsgi_apache_api_spec.rb | 75 +++++++++------- .../nova_wsgi_apache_placement_spec.rb | 63 +++++++------ 5 files changed, 179 insertions(+), 141 deletions(-) create mode 100644 releasenotes/notes/wsgi_process_options-f8e93a0bb83e0bc8.yaml diff --git a/manifests/wsgi/apache_api.pp b/manifests/wsgi/apache_api.pp index 1183669d6..c6cade275 100644 --- a/manifests/wsgi/apache_api.pp +++ b/manifests/wsgi/apache_api.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['nova'] & Class['nova::api'] @@ -81,22 +89,23 @@ # class { 'nova::wsgi::apache': } # class nova::wsgi::apache_api ( - $servername = $::fqdn, - $api_port = 8774, - $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, + $api_port = 8774, + $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 ::nova::params @@ -111,29 +120,30 @@ class nova::wsgi::apache_api ( } ::openstacklib::wsgi::apache { 'nova_api_wsgi': - bind_host => $bind_host, - bind_port => $api_port, - group => 'nova', - 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 => 'nova', - workers => $workers, - wsgi_daemon_process => 'nova-api', - wsgi_process_display_name => $wsgi_process_display_name, - wsgi_process_group => 'nova-api', - wsgi_script_dir => $::nova::params::nova_wsgi_script_path, - wsgi_script_file => 'nova-api', - wsgi_script_source => $::nova::params::nova_api_wsgi_script_source, + bind_host => $bind_host, + bind_port => $api_port, + group => 'nova', + 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 => 'nova', + workers => $workers, + wsgi_daemon_process => 'nova-api', + wsgi_process_display_name => $wsgi_process_display_name, + wsgi_process_group => 'nova-api', + wsgi_script_dir => $::nova::params::nova_wsgi_script_path, + wsgi_script_file => 'nova-api', + wsgi_script_source => $::nova::params::nova_api_wsgi_script_source, + custom_wsgi_process_options => $custom_wsgi_process_options, } } diff --git a/manifests/wsgi/apache_placement.pp b/manifests/wsgi/apache_placement.pp index 3994b73f4..e552f8a70 100644 --- a/manifests/wsgi/apache_placement.pp +++ b/manifests/wsgi/apache_placement.pp @@ -72,6 +72,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 {} +# # == Examples # # include apache @@ -79,23 +87,24 @@ # class { 'nova::wsgi::apache': } # class nova::wsgi::apache_placement ( - $servername = $::fqdn, - $api_port = 80, - $bind_host = undef, - $path = '/placement', - $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', - $ensure_package = 'present', + $servername = $::fqdn, + $api_port = 80, + $bind_host = undef, + $path = '/placement', + $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', + $ensure_package = 'present', + $custom_wsgi_process_options = {}, ) { include ::nova::params @@ -127,29 +136,30 @@ class nova::wsgi::apache_placement ( ~> Service['httpd'] ::openstacklib::wsgi::apache { 'placement_wsgi': - bind_host => $bind_host, - bind_port => $api_port, - group => 'nova', - 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 => 'nova', - workers => $workers, - wsgi_daemon_process => 'placement-api', - wsgi_process_display_name => $wsgi_process_display_name, - wsgi_process_group => 'placement-api', - wsgi_script_dir => $::nova::params::nova_wsgi_script_path, - wsgi_script_file => 'nova-placement-api', - wsgi_script_source => $::nova::params::placement_wsgi_script_source, + bind_host => $bind_host, + bind_port => $api_port, + group => 'nova', + 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 => 'nova', + workers => $workers, + wsgi_daemon_process => 'placement-api', + wsgi_process_display_name => $wsgi_process_display_name, + wsgi_process_group => 'placement-api', + wsgi_script_dir => $::nova::params::nova_wsgi_script_path, + wsgi_script_file => 'nova-placement-api', + wsgi_script_source => $::nova::params::placement_wsgi_script_source, + custom_wsgi_process_options => $custom_wsgi_process_options, } } diff --git a/releasenotes/notes/wsgi_process_options-f8e93a0bb83e0bc8.yaml b/releasenotes/notes/wsgi_process_options-f8e93a0bb83e0bc8.yaml new file mode 100644 index 000000000..2ad68c680 --- /dev/null +++ b/releasenotes/notes/wsgi_process_options-f8e93a0bb83e0bc8.yaml @@ -0,0 +1,4 @@ +--- +features: + - Add parameter to apacher_wsgi to allow overwrite + and/or add additional wsgi process options. diff --git a/spec/classes/nova_wsgi_apache_api_spec.rb b/spec/classes/nova_wsgi_apache_api_spec.rb index 6331a30ba..9e67b49e4 100644 --- a/spec/classes/nova_wsgi_apache_api_spec.rb +++ b/spec/classes/nova_wsgi_apache_api_spec.rb @@ -18,19 +18,20 @@ describe 'nova::wsgi::apache_api' 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('nova_api_wsgi').with( - :bind_port => 8774, - :group => 'nova', - :path => '/', - :servername => facts[:fqdn], - :ssl => true, - :threads => facts[:os_workers], - :user => 'nova', - :workers => 1, - :wsgi_daemon_process => 'nova-api', - :wsgi_process_group => 'nova-api', - :wsgi_script_dir => platform_params[:wsgi_script_path], - :wsgi_script_file => 'nova-api', - :wsgi_script_source => platform_params[:api_wsgi_script_source], + :bind_port => 8774, + :group => 'nova', + :path => '/', + :servername => facts[:fqdn], + :ssl => true, + :threads => facts[:os_workers], + :user => 'nova', + :workers => 1, + :wsgi_daemon_process => 'nova-api', + :wsgi_process_group => 'nova-api', + :wsgi_script_dir => platform_params[:wsgi_script_path], + :wsgi_script_file => 'nova-api', + :wsgi_script_source => platform_params[:api_wsgi_script_source], + :custom_wsgi_process_options => {}, )} end @@ -47,12 +48,15 @@ describe 'nova::wsgi::apache_api' do let :params do { - :servername => 'dummy.host', - :bind_host => '10.42.51.1', - :api_port => 12345, - :ssl => false, - :wsgi_process_display_name => 'nova-api', - :workers => 37, + :servername => 'dummy.host', + :bind_host => '10.42.51.1', + :api_port => 12345, + :ssl => false, + :wsgi_process_display_name => 'nova-api', + :workers => 37, + :custom_wsgi_process_options => { + 'python_path' => '/my/python/path', + }, } end @@ -61,21 +65,24 @@ describe 'nova::wsgi::apache_api' do it { is_expected.to contain_class('apache::mod::wsgi') } it { is_expected.to_not contain_class('apache::mod::ssl') } it { is_expected.to contain_openstacklib__wsgi__apache('nova_api_wsgi').with( - :bind_host => '10.42.51.1', - :bind_port => 12345, - :group => 'nova', - :path => '/', - :servername => 'dummy.host', - :ssl => false, - :threads => facts[:os_workers], - :user => 'nova', - :workers => 37, - :wsgi_daemon_process => 'nova-api', - :wsgi_process_display_name => 'nova-api', - :wsgi_process_group => 'nova-api', - :wsgi_script_dir => platform_params[:wsgi_script_path], - :wsgi_script_file => 'nova-api', - :wsgi_script_source => platform_params[:api_wsgi_script_source], + :bind_host => '10.42.51.1', + :bind_port => 12345, + :group => 'nova', + :path => '/', + :servername => 'dummy.host', + :ssl => false, + :threads => facts[:os_workers], + :user => 'nova', + :workers => 37, + :wsgi_daemon_process => 'nova-api', + :wsgi_process_display_name => 'nova-api', + :wsgi_process_group => 'nova-api', + :wsgi_script_dir => platform_params[:wsgi_script_path], + :wsgi_script_file => 'nova-api', + :wsgi_script_source => platform_params[:api_wsgi_script_source], + :custom_wsgi_process_options => { + 'python_path' => '/my/python/path', + }, )} end diff --git a/spec/classes/nova_wsgi_apache_placement_spec.rb b/spec/classes/nova_wsgi_apache_placement_spec.rb index e23e5a9de..183213be9 100644 --- a/spec/classes/nova_wsgi_apache_placement_spec.rb +++ b/spec/classes/nova_wsgi_apache_placement_spec.rb @@ -23,19 +23,20 @@ describe 'nova::wsgi::apache_placement' do )} it { is_expected.to contain_file(platform_params[:placement_httpd_config_file]) } it { is_expected.to contain_openstacklib__wsgi__apache('placement_wsgi').with( - :bind_port => 80, - :group => 'nova', - :path => '/placement', - :servername => facts[:fqdn], - :ssl => true, - :threads => facts[:os_workers], - :user => 'nova', - :workers => 1, - :wsgi_daemon_process => 'placement-api', - :wsgi_process_group => 'placement-api', - :wsgi_script_dir => platform_params[:wsgi_script_path], - :wsgi_script_file => 'nova-placement-api', - :wsgi_script_source => platform_params[:placement_wsgi_script_source], + :bind_port => 80, + :group => 'nova', + :path => '/placement', + :servername => facts[:fqdn], + :ssl => true, + :threads => facts[:os_workers], + :user => 'nova', + :workers => 1, + :wsgi_daemon_process => 'placement-api', + :wsgi_process_group => 'placement-api', + :wsgi_script_dir => platform_params[:wsgi_script_path], + :wsgi_script_file => 'nova-placement-api', + :wsgi_script_source => platform_params[:placement_wsgi_script_source], + :custom_wsgi_process_options => {}, )} end @@ -57,6 +58,9 @@ describe 'nova::wsgi::apache_placement' do :ssl => false, :wsgi_process_display_name => 'placement-api', :workers => 37, + :custom_wsgi_process_options => { + 'python_path' => '/my/python/path', + }, } end @@ -71,21 +75,24 @@ describe 'nova::wsgi::apache_placement' do )} it { is_expected.to contain_file(platform_params[:placement_httpd_config_file]) } it { is_expected.to contain_openstacklib__wsgi__apache('placement_wsgi').with( - :bind_host => '10.42.51.1', - :bind_port => 12345, - :group => 'nova', - :path => '/placement', - :servername => 'dummy.host', - :ssl => false, - :workers => 37, - :threads => facts[:os_workers], - :user => 'nova', - :wsgi_daemon_process => 'placement-api', - :wsgi_process_display_name => 'placement-api', - :wsgi_process_group => 'placement-api', - :wsgi_script_dir => platform_params[:wsgi_script_path], - :wsgi_script_file => 'nova-placement-api', - :wsgi_script_source => platform_params[:placement_wsgi_script_source], + :bind_host => '10.42.51.1', + :bind_port => 12345, + :group => 'nova', + :path => '/placement', + :servername => 'dummy.host', + :ssl => false, + :workers => 37, + :threads => facts[:os_workers], + :user => 'nova', + :wsgi_daemon_process => 'placement-api', + :wsgi_process_display_name => 'placement-api', + :wsgi_process_group => 'placement-api', + :wsgi_script_dir => platform_params[:wsgi_script_path], + :wsgi_script_file => 'nova-placement-api', + :wsgi_script_source => platform_params[:placement_wsgi_script_source], + :custom_wsgi_process_options => { + 'python_path' => '/my/python/path', + }, )} end end