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: I3df74ddc4a258083ccfe4e47180f022742655ba6
This commit is contained in:
Benedikt Trefzer 2017-06-26 15:28:32 +02:00
parent f7e6fd9180
commit 10a7db8463
7 changed files with 216 additions and 173 deletions

View File

@ -69,6 +69,14 @@
# [*vhost_custom_fragment*]
# (optional) Additional vhost configuration, if applicable.
#
# [*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['heat']
@ -81,21 +89,22 @@
#
define heat::wsgi::apache (
$port,
$servername = $::fqdn,
$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,
$threads = $::os_workers,
$priority = '10',
$vhost_custom_fragment = undef,
$servername = $::fqdn,
$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,
$threads = $::os_workers,
$priority = '10',
$vhost_custom_fragment = undef,
$custom_wsgi_process_options = {},
) {
if $title !~ /^api(|_cfn|_cloudwatch)$/ {
fail('The valid options are api, api_cfn, api_cloudwatch')
@ -109,30 +118,31 @@ define heat::wsgi::apache (
}
::openstacklib::wsgi::apache { "heat_${title}_wsgi":
bind_host => $bind_host,
bind_port => $port,
group => 'heat',
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 => 'heat',
workers => $workers,
wsgi_daemon_process => "heat_${title}",
wsgi_process_group => "heat_${title}",
wsgi_script_dir => $::heat::params::heat_wsgi_script_path,
wsgi_script_file => "heat_${title}",
wsgi_script_source => getvar("::heat::params::heat_${title}_wsgi_script_source"),
allow_encoded_slashes => 'on',
require => Anchor['heat::install::end'],
vhost_custom_fragment => $vhost_custom_fragment,
bind_host => $bind_host,
bind_port => $port,
group => 'heat',
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 => 'heat',
workers => $workers,
wsgi_daemon_process => "heat_${title}",
wsgi_process_group => "heat_${title}",
wsgi_script_dir => $::heat::params::heat_wsgi_script_path,
wsgi_script_file => "heat_${title}",
wsgi_script_source => getvar("::heat::params::heat_${title}_wsgi_script_source"),
custom_wsgi_process_options => $custom_wsgi_process_options,
allow_encoded_slashes => 'on',
require => Anchor['heat::install::end'],
vhost_custom_fragment => $vhost_custom_fragment,
}
}

View File

@ -61,6 +61,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['heat']
@ -72,37 +80,39 @@
# class { 'heat::wsgi::apache': }
#
class heat::wsgi::apache_api (
$port = 8004,
$servername = $::fqdn,
$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,
$threads = $::os_workers,
$priority = '10',
$port = 8004,
$servername = $::fqdn,
$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,
$threads = $::os_workers,
$priority = '10',
$custom_wsgi_process_options = {},
) {
heat::wsgi::apache { 'api':
port => $port,
servername => $servername,
bind_host => $bind_host,
path => $path,
ssl => $ssl,
workers => $workers,
ssl_cert => $ssl_cert,
ssl_key => $ssl_key,
ssl_chain => $ssl_chain,
ssl_ca => $ssl_ca,
ssl_crl_path => $ssl_crl_path,
ssl_crl => $ssl_crl,
ssl_certs_dir => $ssl_certs_dir,
threads => $threads,
priority => $priority,
port => $port,
servername => $servername,
bind_host => $bind_host,
path => $path,
ssl => $ssl,
workers => $workers,
ssl_cert => $ssl_cert,
ssl_key => $ssl_key,
ssl_chain => $ssl_chain,
ssl_ca => $ssl_ca,
ssl_crl_path => $ssl_crl_path,
ssl_crl => $ssl_crl,
ssl_certs_dir => $ssl_certs_dir,
threads => $threads,
custom_wsgi_process_options => $custom_wsgi_process_options,
priority => $priority,
}
}

View File

@ -61,6 +61,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['heat']
@ -72,21 +80,22 @@
# class { 'heat::wsgi::apache': }
#
class heat::wsgi::apache_api_cfn (
$port = 8000,
$servername = $::fqdn,
$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,
$threads = $::os_workers,
$priority = '10',
$port = 8000,
$servername = $::fqdn,
$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,
$threads = $::os_workers,
$priority = '10',
$custom_wsgi_process_options = {},
) {
# See custom fragment below
@ -105,22 +114,23 @@ class heat::wsgi::apache_api_cfn (
}
heat::wsgi::apache { 'api_cfn':
port => $port,
servername => $servername,
bind_host => $bind_host,
path => $path,
ssl => $ssl,
workers => $workers,
ssl_cert => $ssl_cert,
ssl_key => $ssl_key,
ssl_chain => $ssl_chain,
ssl_ca => $ssl_ca,
ssl_crl_path => $ssl_crl_path,
ssl_crl => $ssl_crl,
ssl_certs_dir => $ssl_certs_dir,
threads => $threads,
priority => $priority,
port => $port,
servername => $servername,
bind_host => $bind_host,
path => $path,
ssl => $ssl,
workers => $workers,
ssl_cert => $ssl_cert,
ssl_key => $ssl_key,
ssl_chain => $ssl_chain,
ssl_ca => $ssl_ca,
ssl_crl_path => $ssl_crl_path,
ssl_crl => $ssl_crl,
ssl_certs_dir => $ssl_certs_dir,
threads => $threads,
priority => $priority,
# Enforce content-type, see https://bugs.launchpad.net/tripleo/+bug/1641589
vhost_custom_fragment => 'RequestHeader set Content-Type "application/json"',
vhost_custom_fragment => 'RequestHeader set Content-Type "application/json"',
custom_wsgi_process_options => $custom_wsgi_process_options,
}
}

View File

@ -61,6 +61,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['heat']
@ -72,37 +80,39 @@
# class { 'heat::wsgi::apache': }
#
class heat::wsgi::apache_api_cloudwatch (
$port = 8003,
$servername = $::fqdn,
$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,
$threads = $::os_workers,
$priority = '10',
$port = 8003,
$servername = $::fqdn,
$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,
$threads = $::os_workers,
$priority = '10',
$custom_wsgi_process_options = {},
) {
heat::wsgi::apache { 'api_cloudwatch':
port => $port,
servername => $servername,
bind_host => $bind_host,
path => $path,
ssl => $ssl,
workers => $workers,
ssl_cert => $ssl_cert,
ssl_key => $ssl_key,
ssl_chain => $ssl_chain,
ssl_ca => $ssl_ca,
ssl_crl_path => $ssl_crl_path,
ssl_crl => $ssl_crl,
ssl_certs_dir => $ssl_certs_dir,
threads => $threads,
priority => $priority,
port => $port,
servername => $servername,
bind_host => $bind_host,
path => $path,
ssl => $ssl,
workers => $workers,
ssl_cert => $ssl_cert,
ssl_key => $ssl_key,
ssl_chain => $ssl_chain,
ssl_ca => $ssl_ca,
ssl_crl_path => $ssl_crl_path,
ssl_crl => $ssl_crl,
ssl_certs_dir => $ssl_certs_dir,
threads => $threads,
priority => $priority,
custom_wsgi_process_options => $custom_wsgi_process_options,
}
}

View File

@ -6,20 +6,21 @@ describe 'heat::wsgi::apache_api_cfn' do
context 'default parameters' do
it { is_expected.to contain_class('heat::wsgi::apache_api_cfn') }
it { is_expected.to contain_heat__wsgi__apache('api_cfn').with(
:port => 8000,
:servername => facts[:fqdn],
:bind_host => nil,
:path => '/',
:ssl => true,
:workers => 1,
:ssl_cert => nil,
:ssl_key => nil,
:ssl_chain => nil,
:ssl_ca => nil,
:ssl_crl_path => nil,
:ssl_certs_dir => nil,
:threads => facts[:os_workers],
:priority => 10, )
:port => 8000,
:servername => facts[:fqdn],
:bind_host => nil,
:path => '/',
:ssl => true,
:workers => 1,
:ssl_cert => nil,
:ssl_key => nil,
:ssl_chain => nil,
:ssl_ca => nil,
:ssl_crl_path => nil,
:ssl_certs_dir => nil,
:threads => facts[:os_workers],
:priority => 10,
:custom_wsgi_process_options => {}, )
}
end
end

View File

@ -6,20 +6,21 @@ describe 'heat::wsgi::apache_api_cloudwatch' do
context 'default parameters' do
it { is_expected.to contain_class('heat::wsgi::apache_api_cloudwatch') }
it { is_expected.to contain_heat__wsgi__apache('api_cloudwatch').with(
:port => 8003,
:servername => facts[:fqdn],
:bind_host => nil,
:path => '/',
:ssl => true,
:workers => 1,
:ssl_cert => nil,
:ssl_key => nil,
:ssl_chain => nil,
:ssl_ca => nil,
:ssl_crl_path => nil,
:ssl_certs_dir => nil,
:threads => facts[:os_workers],
:priority => 10, )
:port => 8003,
:servername => facts[:fqdn],
:bind_host => nil,
:path => '/',
:ssl => true,
:workers => 1,
:ssl_cert => nil,
:ssl_key => nil,
:ssl_chain => nil,
:ssl_ca => nil,
:ssl_crl_path => nil,
:ssl_certs_dir => nil,
:threads => facts[:os_workers],
:priority => 10,
:custom_wsgi_process_options => {}, )
}
end
end

View File

@ -6,20 +6,21 @@ describe 'heat::wsgi::apache_api' do
context 'default parameters' do
it { is_expected.to contain_class('heat::wsgi::apache_api') }
it { is_expected.to contain_heat__wsgi__apache('api').with(
:port => 8004,
:servername => facts[:fqdn],
:bind_host => nil,
:path => '/',
:ssl => true,
:workers => 1,
:ssl_cert => nil,
:ssl_key => nil,
:ssl_chain => nil,
:ssl_ca => nil,
:ssl_crl_path => nil,
:ssl_certs_dir => nil,
:threads => facts[:os_workers],
:priority => 10, )
:port => 8004,
:servername => facts[:fqdn],
:bind_host => nil,
:path => '/',
:ssl => true,
:workers => 1,
:ssl_cert => nil,
:ssl_key => nil,
:ssl_chain => nil,
:ssl_ca => nil,
:ssl_crl_path => nil,
:ssl_certs_dir => nil,
:threads => facts[:os_workers],
:priority => 10,
:custom_wsgi_process_options => {}, )
}
end
end