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: I93e1d46e1f7c3121f866251620bf88435d4084d1
This commit is contained in:
Benedikt Trefzer 2017-09-19 14:09:02 +02:00
parent 3a7b6f7f0b
commit 5e0be79f84
3 changed files with 79 additions and 58 deletions

View File

@ -69,6 +69,14 @@
# [*ssl_certs_dir*] # [*ssl_certs_dir*]
# 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
# #
@ -81,22 +89,23 @@
# class { 'aodh::wsgi::apache': } # class { 'aodh::wsgi::apache': }
# #
class aodh::wsgi::apache ( class aodh::wsgi::apache (
$servername = $::fqdn, $servername = $::fqdn,
$port = 8042, $port = 8042,
$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 ::aodh::deps include ::aodh::deps
@ -112,28 +121,29 @@ class aodh::wsgi::apache (
Anchor['aodh::install::end'] -> Class['apache'] Anchor['aodh::install::end'] -> Class['apache']
::openstacklib::wsgi::apache { 'aodh_wsgi': ::openstacklib::wsgi::apache { 'aodh_wsgi':
bind_host => $bind_host, bind_host => $bind_host,
bind_port => $port, bind_port => $port,
group => 'aodh', group => 'aodh',
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 => 'aodh', user => 'aodh',
workers => $workers, workers => $workers,
wsgi_daemon_process => 'aodh', wsgi_daemon_process => 'aodh',
wsgi_process_display_name => $wsgi_process_display_name, wsgi_process_display_name => $wsgi_process_display_name,
wsgi_process_group => 'aodh', wsgi_process_group => 'aodh',
wsgi_script_dir => $::aodh::params::aodh_wsgi_script_path, wsgi_script_dir => $::aodh::params::aodh_wsgi_script_path,
wsgi_script_file => 'app', wsgi_script_file => 'app',
wsgi_script_source => $::aodh::params::aodh_wsgi_script_source, wsgi_script_source => $::aodh::params::aodh_wsgi_script_source,
custom_wsgi_process_options => $custom_wsgi_process_options,
} }
} }

View File

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

View File

@ -9,31 +9,35 @@ describe 'aodh::wsgi::apache' 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('aodh_wsgi').with( it { is_expected.to contain_openstacklib__wsgi__apache('aodh_wsgi').with(
:bind_port => 8042, :bind_port => 8042,
:group => 'aodh', :group => 'aodh',
:path => '/', :path => '/',
:servername => facts[:fqdn], :servername => facts[:fqdn],
:ssl => true, :ssl => true,
:threads => facts[:os_workers], :threads => facts[:os_workers],
:user => 'aodh', :user => 'aodh',
:workers => 1, :workers => 1,
:wsgi_daemon_process => 'aodh', :wsgi_daemon_process => 'aodh',
:wsgi_process_group => 'aodh', :wsgi_process_group => 'aodh',
:wsgi_script_dir => platform_params[:wsgi_script_path], :wsgi_script_dir => platform_params[:wsgi_script_path],
:wsgi_script_file => 'app', :wsgi_script_file => 'app',
:wsgi_script_source => platform_params[:wsgi_script_source], :wsgi_script_source => platform_params[:wsgi_script_source],
:custom_wsgi_process_options => {},
)} )}
end end
context 'when overriding parameters using different ports' do context 'when overriding parameters using different ports' 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',
:port => 12345, :port => 12345,
:ssl => false, :ssl => false,
:wsgi_process_display_name => 'aodh', :wsgi_process_display_name => 'aodh',
:workers => 37, :workers => 37,
:custom_wsgi_process_options => {
'python_path' => '/my/python/path',
},
} }
end end
it { is_expected.to contain_class('aodh::params') } it { is_expected.to contain_class('aodh::params') }
@ -56,6 +60,9 @@ describe 'aodh::wsgi::apache' do
:wsgi_script_dir => platform_params[:wsgi_script_path], :wsgi_script_dir => platform_params[:wsgi_script_path],
:wsgi_script_file => 'app', :wsgi_script_file => 'app',
:wsgi_script_source => platform_params[:wsgi_script_source], :wsgi_script_source => platform_params[:wsgi_script_source],
:custom_wsgi_process_options => {
'python_path' => '/my/python/path',
},
)} )}
end end
end end