Merge "add parameter to overwrite/add wsgi process options"

This commit is contained in:
Zuul 2017-11-10 05:31:03 +00:00 committed by Gerrit Code Review
commit acfbee116c
3 changed files with 110 additions and 89 deletions

View File

@ -78,6 +78,14 @@
# The error log file name for the virtualhost. # The error log file name for the virtualhost.
# Optional. Defaults to undef. # Optional. Defaults to undef.
# #
# [*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['zaqar'] # requires Class['apache'] & Class['zaqar']
@ -89,25 +97,26 @@
# class { 'zaqar::wsgi::apache': } # class { 'zaqar::wsgi::apache': }
# #
class zaqar::wsgi::apache ( class zaqar::wsgi::apache (
$servername = $::fqdn, $servername = $::fqdn,
$port = 8888, $port = 8888,
$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',
$access_log_file = false, $access_log_file = false,
$access_log_format = false, $access_log_format = false,
$error_log_file = undef, $error_log_file = undef,
$custom_wsgi_process_options = {},
) { ) {
include ::zaqar::deps include ::zaqar::deps
@ -119,33 +128,34 @@ class zaqar::wsgi::apache (
} }
::openstacklib::wsgi::apache { 'zaqar_wsgi': ::openstacklib::wsgi::apache { 'zaqar_wsgi':
bind_host => $bind_host, bind_host => $bind_host,
bind_port => $port, bind_port => $port,
group => 'zaqar', group => 'zaqar',
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 => 'zaqar', user => 'zaqar',
workers => $workers, workers => $workers,
wsgi_daemon_process => 'zaqar-server', wsgi_daemon_process => 'zaqar-server',
wsgi_process_display_name => $wsgi_process_display_name, wsgi_process_display_name => $wsgi_process_display_name,
wsgi_process_group => 'zaqar-server', wsgi_process_group => 'zaqar-server',
wsgi_script_dir => $::zaqar::params::zaqar_wsgi_script_path, wsgi_script_dir => $::zaqar::params::zaqar_wsgi_script_path,
wsgi_script_file => 'zaqar-server', wsgi_script_file => 'zaqar-server',
wsgi_script_source => $::zaqar::params::zaqar_wsgi_script_source, wsgi_script_source => $::zaqar::params::zaqar_wsgi_script_source,
require => Anchor['zaqar::install::end'], require => Anchor['zaqar::install::end'],
vhost_custom_fragment => 'WSGICallableObject app', vhost_custom_fragment => 'WSGICallableObject app',
access_log_file => $access_log_file, access_log_file => $access_log_file,
access_log_format => $access_log_format, access_log_format => $access_log_format,
error_log_file => $error_log_file, error_log_file => $error_log_file,
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,36 +9,40 @@ describe 'zaqar::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('zaqar_wsgi').with( it { is_expected.to contain_openstacklib__wsgi__apache('zaqar_wsgi').with(
:bind_port => 8888, :bind_port => 8888,
:group => 'zaqar', :group => 'zaqar',
:path => '/', :path => '/',
:servername => facts[:fqdn], :servername => facts[:fqdn],
:ssl => true, :ssl => true,
:threads => 1, :threads => 1,
:user => 'zaqar', :user => 'zaqar',
:workers => facts[:os_workers], :workers => facts[:os_workers],
:wsgi_daemon_process => 'zaqar-server', :wsgi_daemon_process => 'zaqar-server',
:wsgi_process_group => 'zaqar-server', :wsgi_process_group => 'zaqar-server',
:wsgi_script_dir => platform_params[:wsgi_script_path], :wsgi_script_dir => platform_params[:wsgi_script_path],
:wsgi_script_file => 'zaqar-server', :wsgi_script_file => 'zaqar-server',
:wsgi_script_source => platform_params[:wsgi_script_source], :wsgi_script_source => platform_params[:wsgi_script_source],
:access_log_file => false, :access_log_file => false,
:access_log_format => false, :access_log_format => false,
: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 => 'zaqar-server', :wsgi_process_display_name => 'zaqar-server',
:workers => 37, :workers => 37,
:access_log_file => '/var/log/httpd/access_log', :access_log_file => '/var/log/httpd/access_log',
:access_log_format => 'some format', :access_log_format => 'some format',
:error_log_file => '/var/log/httpd/error_log' :error_log_file => '/var/log/httpd/error_log',
:custom_wsgi_process_options => {
'python_path' => '/my/python/path',
},
} }
end end
it { is_expected.to contain_class('zaqar::params') } it { is_expected.to contain_class('zaqar::params') }
@ -46,24 +50,27 @@ describe 'zaqar::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_not contain_class('apache::mod::ssl') } it { is_expected.to_not contain_class('apache::mod::ssl') }
it { is_expected.to contain_openstacklib__wsgi__apache('zaqar_wsgi').with( it { is_expected.to contain_openstacklib__wsgi__apache('zaqar_wsgi').with(
:bind_host => '10.42.51.1', :bind_host => '10.42.51.1',
:bind_port => 12345, :bind_port => 12345,
:group => 'zaqar', :group => 'zaqar',
:path => '/', :path => '/',
:servername => 'dummy.host', :servername => 'dummy.host',
:ssl => false, :ssl => false,
:threads => 1, :threads => 1,
:user => 'zaqar', :user => 'zaqar',
:workers => 37, :workers => 37,
:wsgi_daemon_process => 'zaqar-server', :wsgi_daemon_process => 'zaqar-server',
:wsgi_process_display_name => 'zaqar-server', :wsgi_process_display_name => 'zaqar-server',
:wsgi_process_group => 'zaqar-server', :wsgi_process_group => 'zaqar-server',
:wsgi_script_dir => platform_params[:wsgi_script_path], :wsgi_script_dir => platform_params[:wsgi_script_path],
:wsgi_script_file => 'zaqar-server', :wsgi_script_file => 'zaqar-server',
:wsgi_script_source => platform_params[:wsgi_script_source], :wsgi_script_source => platform_params[:wsgi_script_source],
:access_log_file => '/var/log/httpd/access_log', :access_log_file => '/var/log/httpd/access_log',
:access_log_format => 'some format', :access_log_format => 'some format',
:error_log_file => '/var/log/httpd/error_log' :error_log_file => '/var/log/httpd/error_log',
:custom_wsgi_process_options => {
'python_path' => '/my/python/path',
},
)} )}
end end
end end