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
This commit is contained in:
Benedikt Trefzer 2017-09-19 14:22:07 +02:00
parent 6ec650490c
commit dfeb00ade4
3 changed files with 73 additions and 52 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['gnocchi'] # requires Class['apache'] & Class['gnocchi']
@ -81,22 +89,23 @@
# class { 'gnocchi::wsgi::apache': } # class { 'gnocchi::wsgi::apache': }
# #
class gnocchi::wsgi::apache ( class gnocchi::wsgi::apache (
$servername = $::fqdn, $servername = $::fqdn,
$port = 8041, $port = 8041,
$bind_host = undef, $bind_host = undef,
$path = '/', $path = '/',
$ssl = true, $ssl = true,
$workers = $::os_workers, $workers = $::os_workers,
$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 = 1, $threads = 1,
$priority = '10', $priority = '10',
$custom_wsgi_process_options = {},
) { ) {
include ::gnocchi::deps include ::gnocchi::deps
@ -108,28 +117,29 @@ class gnocchi::wsgi::apache (
} }
::openstacklib::wsgi::apache { 'gnocchi_wsgi': ::openstacklib::wsgi::apache { 'gnocchi_wsgi':
bind_host => $bind_host, bind_host => $bind_host,
bind_port => $port, bind_port => $port,
group => 'gnocchi', group => 'gnocchi',
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 => 'gnocchi', user => 'gnocchi',
workers => $workers, workers => $workers,
wsgi_daemon_process => 'gnocchi', wsgi_daemon_process => 'gnocchi',
wsgi_process_display_name => $wsgi_process_display_name, wsgi_process_display_name => $wsgi_process_display_name,
wsgi_process_group => 'gnocchi', wsgi_process_group => 'gnocchi',
wsgi_script_dir => $::gnocchi::params::gnocchi_wsgi_script_path, wsgi_script_dir => $::gnocchi::params::gnocchi_wsgi_script_path,
wsgi_script_file => 'app', wsgi_script_file => 'app',
wsgi_script_source => $::gnocchi::params::gnocchi_wsgi_script_source, wsgi_script_source => $::gnocchi::params::gnocchi_wsgi_script_source,
custom_wsgi_process_options => $custom_wsgi_process_options,
} }
} }

View File

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

View File

@ -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::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('gnocchi_wsgi').with( it { is_expected.to contain_openstacklib__wsgi__apache('gnocchi_wsgi').with(
:bind_port => 8041, :bind_port => 8041,
:group => 'gnocchi', :group => 'gnocchi',
:path => '/', :path => '/',
:servername => facts[:fqdn], :servername => facts[:fqdn],
:ssl => true, :ssl => true,
:threads => 1, :threads => 1,
:user => 'gnocchi', :user => 'gnocchi',
:workers => facts[:os_workers], :workers => facts[:os_workers],
:wsgi_daemon_process => 'gnocchi', :wsgi_daemon_process => 'gnocchi',
:wsgi_process_group => 'gnocchi', :wsgi_process_group => 'gnocchi',
: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
@ -35,6 +36,9 @@ describe 'gnocchi::wsgi::apache' do
:workers => 8, :workers => 8,
:wsgi_process_display_name => 'gnocchi', :wsgi_process_display_name => 'gnocchi',
:threads => 2, :threads => 2,
:custom_wsgi_process_options => {
'python_path' => '/my/python/path',
},
} }
end end
@ -58,6 +62,9 @@ describe 'gnocchi::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