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
This commit is contained in:
Benedikt Trefzer
2017-09-18 11:41:23 +02:00
parent 2e5e936595
commit 1584887d9d
5 changed files with 179 additions and 141 deletions

View File

@@ -70,6 +70,14 @@
# apache::vhost ssl parameters. # apache::vhost ssl parameters.
# Optional. Default to apache::vhost 'ssl_*' defaults. # 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 # == Dependencies
# #
# requires Class['apache'] & Class['nova'] & Class['nova::api'] # requires Class['apache'] & Class['nova'] & Class['nova::api']
@@ -81,22 +89,23 @@
# class { 'nova::wsgi::apache': } # class { 'nova::wsgi::apache': }
# #
class nova::wsgi::apache_api ( class nova::wsgi::apache_api (
$servername = $::fqdn, $servername = $::fqdn,
$api_port = 8774, $api_port = 8774,
$bind_host = undef, $bind_host = undef,
$path = '/', $path = '/',
$ssl = true, $ssl = true,
$workers = 1, $workers = 1,
$ssl_cert = undef, $ssl_cert = undef,
$ssl_key = undef, $ssl_key = undef,
$ssl_chain = undef, $ssl_chain = undef,
$ssl_ca = undef, $ssl_ca = undef,
$ssl_crl_path = undef, $ssl_crl_path = undef,
$ssl_crl = undef, $ssl_crl = undef,
$ssl_certs_dir = undef, $ssl_certs_dir = undef,
$wsgi_process_display_name = undef, $wsgi_process_display_name = undef,
$threads = $::os_workers, $threads = $::os_workers,
$priority = '10', $priority = '10',
$custom_wsgi_process_options = {},
) { ) {
include ::nova::params include ::nova::params
@@ -111,29 +120,30 @@ class nova::wsgi::apache_api (
} }
::openstacklib::wsgi::apache { 'nova_api_wsgi': ::openstacklib::wsgi::apache { 'nova_api_wsgi':
bind_host => $bind_host, bind_host => $bind_host,
bind_port => $api_port, bind_port => $api_port,
group => 'nova', group => 'nova',
path => $path, path => $path,
priority => $priority, priority => $priority,
servername => $servername, servername => $servername,
ssl => $ssl, ssl => $ssl,
ssl_ca => $ssl_ca, ssl_ca => $ssl_ca,
ssl_cert => $ssl_cert, ssl_cert => $ssl_cert,
ssl_certs_dir => $ssl_certs_dir, ssl_certs_dir => $ssl_certs_dir,
ssl_chain => $ssl_chain, ssl_chain => $ssl_chain,
ssl_crl => $ssl_crl, ssl_crl => $ssl_crl,
ssl_crl_path => $ssl_crl_path, ssl_crl_path => $ssl_crl_path,
ssl_key => $ssl_key, ssl_key => $ssl_key,
threads => $threads, threads => $threads,
user => 'nova', user => 'nova',
workers => $workers, workers => $workers,
wsgi_daemon_process => 'nova-api', wsgi_daemon_process => 'nova-api',
wsgi_process_display_name => $wsgi_process_display_name, wsgi_process_display_name => $wsgi_process_display_name,
wsgi_process_group => 'nova-api', wsgi_process_group => 'nova-api',
wsgi_script_dir => $::nova::params::nova_wsgi_script_path, wsgi_script_dir => $::nova::params::nova_wsgi_script_path,
wsgi_script_file => 'nova-api', wsgi_script_file => 'nova-api',
wsgi_script_source => $::nova::params::nova_api_wsgi_script_source, wsgi_script_source => $::nova::params::nova_api_wsgi_script_source,
custom_wsgi_process_options => $custom_wsgi_process_options,
} }
} }

View File

@@ -72,6 +72,14 @@
# apache::vhost ssl parameters. # apache::vhost ssl parameters.
# Optional. Default to apache::vhost 'ssl_*' defaults. # 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 # == Examples
# #
# include apache # include apache
@@ -79,23 +87,24 @@
# class { 'nova::wsgi::apache': } # class { 'nova::wsgi::apache': }
# #
class nova::wsgi::apache_placement ( class nova::wsgi::apache_placement (
$servername = $::fqdn, $servername = $::fqdn,
$api_port = 80, $api_port = 80,
$bind_host = undef, $bind_host = undef,
$path = '/placement', $path = '/placement',
$ssl = true, $ssl = true,
$workers = 1, $workers = 1,
$ssl_cert = undef, $ssl_cert = undef,
$ssl_key = undef, $ssl_key = undef,
$ssl_chain = undef, $ssl_chain = undef,
$ssl_ca = undef, $ssl_ca = undef,
$ssl_crl_path = undef, $ssl_crl_path = undef,
$ssl_crl = undef, $ssl_crl = undef,
$ssl_certs_dir = undef, $ssl_certs_dir = undef,
$wsgi_process_display_name = undef, $wsgi_process_display_name = undef,
$threads = $::os_workers, $threads = $::os_workers,
$priority = '10', $priority = '10',
$ensure_package = 'present', $ensure_package = 'present',
$custom_wsgi_process_options = {},
) { ) {
include ::nova::params include ::nova::params
@@ -127,29 +136,30 @@ class nova::wsgi::apache_placement (
~> Service['httpd'] ~> Service['httpd']
::openstacklib::wsgi::apache { 'placement_wsgi': ::openstacklib::wsgi::apache { 'placement_wsgi':
bind_host => $bind_host, bind_host => $bind_host,
bind_port => $api_port, bind_port => $api_port,
group => 'nova', group => 'nova',
path => $path, path => $path,
priority => $priority, priority => $priority,
servername => $servername, servername => $servername,
ssl => $ssl, ssl => $ssl,
ssl_ca => $ssl_ca, ssl_ca => $ssl_ca,
ssl_cert => $ssl_cert, ssl_cert => $ssl_cert,
ssl_certs_dir => $ssl_certs_dir, ssl_certs_dir => $ssl_certs_dir,
ssl_chain => $ssl_chain, ssl_chain => $ssl_chain,
ssl_crl => $ssl_crl, ssl_crl => $ssl_crl,
ssl_crl_path => $ssl_crl_path, ssl_crl_path => $ssl_crl_path,
ssl_key => $ssl_key, ssl_key => $ssl_key,
threads => $threads, threads => $threads,
user => 'nova', user => 'nova',
workers => $workers, workers => $workers,
wsgi_daemon_process => 'placement-api', wsgi_daemon_process => 'placement-api',
wsgi_process_display_name => $wsgi_process_display_name, wsgi_process_display_name => $wsgi_process_display_name,
wsgi_process_group => 'placement-api', wsgi_process_group => 'placement-api',
wsgi_script_dir => $::nova::params::nova_wsgi_script_path, wsgi_script_dir => $::nova::params::nova_wsgi_script_path,
wsgi_script_file => 'nova-placement-api', wsgi_script_file => 'nova-placement-api',
wsgi_script_source => $::nova::params::placement_wsgi_script_source, wsgi_script_source => $::nova::params::placement_wsgi_script_source,
custom_wsgi_process_options => $custom_wsgi_process_options,
} }
} }

View File

@@ -0,0 +1,4 @@
---
features:
- Add parameter to apacher_wsgi to allow overwrite
and/or add additional wsgi process options.

View File

@@ -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::wsgi') }
it { is_expected.to contain_class('apache::mod::ssl') } it { is_expected.to contain_class('apache::mod::ssl') }
it { is_expected.to contain_openstacklib__wsgi__apache('nova_api_wsgi').with( it { is_expected.to contain_openstacklib__wsgi__apache('nova_api_wsgi').with(
:bind_port => 8774, :bind_port => 8774,
:group => 'nova', :group => 'nova',
:path => '/', :path => '/',
:servername => facts[:fqdn], :servername => facts[:fqdn],
:ssl => true, :ssl => true,
:threads => facts[:os_workers], :threads => facts[:os_workers],
:user => 'nova', :user => 'nova',
:workers => 1, :workers => 1,
:wsgi_daemon_process => 'nova-api', :wsgi_daemon_process => 'nova-api',
:wsgi_process_group => 'nova-api', :wsgi_process_group => 'nova-api',
:wsgi_script_dir => platform_params[:wsgi_script_path], :wsgi_script_dir => platform_params[:wsgi_script_path],
:wsgi_script_file => 'nova-api', :wsgi_script_file => 'nova-api',
:wsgi_script_source => platform_params[:api_wsgi_script_source], :wsgi_script_source => platform_params[:api_wsgi_script_source],
:custom_wsgi_process_options => {},
)} )}
end end
@@ -47,12 +48,15 @@ describe 'nova::wsgi::apache_api' do
let :params do let :params do
{ {
:servername => 'dummy.host', :servername => 'dummy.host',
:bind_host => '10.42.51.1', :bind_host => '10.42.51.1',
:api_port => 12345, :api_port => 12345,
:ssl => false, :ssl => false,
:wsgi_process_display_name => 'nova-api', :wsgi_process_display_name => 'nova-api',
:workers => 37, :workers => 37,
:custom_wsgi_process_options => {
'python_path' => '/my/python/path',
},
} }
end end
@@ -61,21 +65,24 @@ describe 'nova::wsgi::apache_api' do
it { is_expected.to contain_class('apache::mod::wsgi') } it { is_expected.to contain_class('apache::mod::wsgi') }
it { is_expected.to_not contain_class('apache::mod::ssl') } it { is_expected.to_not contain_class('apache::mod::ssl') }
it { is_expected.to contain_openstacklib__wsgi__apache('nova_api_wsgi').with( it { is_expected.to contain_openstacklib__wsgi__apache('nova_api_wsgi').with(
:bind_host => '10.42.51.1', :bind_host => '10.42.51.1',
:bind_port => 12345, :bind_port => 12345,
:group => 'nova', :group => 'nova',
:path => '/', :path => '/',
:servername => 'dummy.host', :servername => 'dummy.host',
:ssl => false, :ssl => false,
:threads => facts[:os_workers], :threads => facts[:os_workers],
:user => 'nova', :user => 'nova',
:workers => 37, :workers => 37,
:wsgi_daemon_process => 'nova-api', :wsgi_daemon_process => 'nova-api',
:wsgi_process_display_name => 'nova-api', :wsgi_process_display_name => 'nova-api',
:wsgi_process_group => 'nova-api', :wsgi_process_group => 'nova-api',
:wsgi_script_dir => platform_params[:wsgi_script_path], :wsgi_script_dir => platform_params[:wsgi_script_path],
:wsgi_script_file => 'nova-api', :wsgi_script_file => 'nova-api',
:wsgi_script_source => platform_params[:api_wsgi_script_source], :wsgi_script_source => platform_params[:api_wsgi_script_source],
:custom_wsgi_process_options => {
'python_path' => '/my/python/path',
},
)} )}
end end

View File

@@ -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_file(platform_params[:placement_httpd_config_file]) }
it { is_expected.to contain_openstacklib__wsgi__apache('placement_wsgi').with( it { is_expected.to contain_openstacklib__wsgi__apache('placement_wsgi').with(
:bind_port => 80, :bind_port => 80,
:group => 'nova', :group => 'nova',
:path => '/placement', :path => '/placement',
:servername => facts[:fqdn], :servername => facts[:fqdn],
:ssl => true, :ssl => true,
:threads => facts[:os_workers], :threads => facts[:os_workers],
:user => 'nova', :user => 'nova',
:workers => 1, :workers => 1,
:wsgi_daemon_process => 'placement-api', :wsgi_daemon_process => 'placement-api',
:wsgi_process_group => 'placement-api', :wsgi_process_group => 'placement-api',
:wsgi_script_dir => platform_params[:wsgi_script_path], :wsgi_script_dir => platform_params[:wsgi_script_path],
:wsgi_script_file => 'nova-placement-api', :wsgi_script_file => 'nova-placement-api',
:wsgi_script_source => platform_params[:placement_wsgi_script_source], :wsgi_script_source => platform_params[:placement_wsgi_script_source],
:custom_wsgi_process_options => {},
)} )}
end end
@@ -57,6 +58,9 @@ describe 'nova::wsgi::apache_placement' do
:ssl => false, :ssl => false,
:wsgi_process_display_name => 'placement-api', :wsgi_process_display_name => 'placement-api',
:workers => 37, :workers => 37,
:custom_wsgi_process_options => {
'python_path' => '/my/python/path',
},
} }
end 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_file(platform_params[:placement_httpd_config_file]) }
it { is_expected.to contain_openstacklib__wsgi__apache('placement_wsgi').with( it { is_expected.to contain_openstacklib__wsgi__apache('placement_wsgi').with(
:bind_host => '10.42.51.1', :bind_host => '10.42.51.1',
:bind_port => 12345, :bind_port => 12345,
:group => 'nova', :group => 'nova',
:path => '/placement', :path => '/placement',
:servername => 'dummy.host', :servername => 'dummy.host',
:ssl => false, :ssl => false,
:workers => 37, :workers => 37,
:threads => facts[:os_workers], :threads => facts[:os_workers],
:user => 'nova', :user => 'nova',
:wsgi_daemon_process => 'placement-api', :wsgi_daemon_process => 'placement-api',
:wsgi_process_display_name => 'placement-api', :wsgi_process_display_name => 'placement-api',
:wsgi_process_group => 'placement-api', :wsgi_process_group => 'placement-api',
:wsgi_script_dir => platform_params[:wsgi_script_path], :wsgi_script_dir => platform_params[:wsgi_script_path],
:wsgi_script_file => 'nova-placement-api', :wsgi_script_file => 'nova-placement-api',
:wsgi_script_source => platform_params[:placement_wsgi_script_source], :wsgi_script_source => platform_params[:placement_wsgi_script_source],
:custom_wsgi_process_options => {
'python_path' => '/my/python/path',
},
)} )}
end end
end end