2013-05-02 18:03:12 +02:00
#
# Class to serve keystone with apache mod_wsgi in place of keystone service
#
# Serving keystone from apache is the recommended way to go for production
# systems as the current keystone implementation is not multi- processor aware,
# thus limiting the performance for concurrent accesses.
#
# See the following URIs for reference :
# https: //etherpad.openstack.org/havana-keystone-performance
# http: //adam.younglogic.com/2012/03/keystone-should-move-to-apache-httpd/
#
# When using this class you should disable your keystone service.
#
# = = Parameters
#
# [ * servername* ]
# The servername for the virtualhost.
# Optional. Defaults to $ : : fqdn
#
# [ * public_port* ]
# The public port.
# Optional. Defaults to 5 0 0 0
#
# [ * admin_port* ]
# The admin port.
# Optional. Defaults to 3 5 3 5 7
#
2014-01-28 15:57:24 +01:00
# [ * bind_host* ]
# The host/ ip address Apache will listen on.
# Optional. Defaults to undef ( listen on all ip addresses) .
#
2016-01-27 16:13:08 -05:00
# [ * admin_bind_host* ]
# The host/ ip address Apache will listen on for admin API connections.
# Optional. Defaults to undef or bind_host if only that setting is used.
#
2013-05-02 18:03:12 +02:00
# [ * public_path* ]
# The prefix for the public endpoint.
# Optional. Defaults to '/'
#
# [ * admin_path* ]
# The prefix for the admin endpoint.
# Optional. Defaults to '/'
#
# [ * ssl* ]
# Use ssl ? ( boolean )
# Optional. Defaults to true
#
# [ * workers* ]
# Number of WSGI workers to spawn.
# Optional. Defaults to 1
#
# [ * ssl_cert* ]
2015-03-15 16:23:09 +01:00
# ( optional) Path to SSL certificate
# Default to apache: : vhost 'ssl_*' defaults.
#
2013-05-02 18:03:12 +02:00
# [ * ssl_key* ]
2015-03-15 16:23:09 +01:00
# ( optional) Path to SSL key
# Default to apache: : vhost 'ssl_*' defaults.
#
2016-09-01 12:01:35 +03:00
# [ * ssl_cert_admin* ]
# ( optional) Path to SSL certificate for the admin endpoint.
# Default to apache: : vhost 'ssl_*' defaults.
#
# [ * ssl_key_admin* ]
# ( optional) Path to SSL key for the admin endpoint.
# Default to apache: : vhost 'ssl_*' defaults.
#
2013-05-02 18:03:12 +02:00
# [ * ssl_chain* ]
2015-03-15 16:23:09 +01:00
# ( optional) SSL chain
# Default to apache: : vhost 'ssl_*' defaults.
#
2013-05-02 18:03:12 +02:00
# [ * ssl_ca* ]
2015-03-15 16:23:09 +01:00
# ( optional) Path to SSL certificate authority
# Default to apache: : vhost 'ssl_*' defaults.
#
2013-05-02 18:03:12 +02:00
# [ * ssl_crl_path* ]
2015-03-15 16:23:09 +01:00
# ( optional) Path to SSL certificate revocation list
# Default to apache: : vhost 'ssl_*' defaults.
#
2013-05-02 18:03:12 +02:00
# [ * ssl_crl* ]
2015-03-15 16:23:09 +01:00
# ( optional) SSL certificate revocation list name
# Default to apache: : vhost 'ssl_*' defaults.
#
2013-05-02 18:03:12 +02:00
# [ * ssl_certs_dir* ]
# apache: : vhost ssl parameters.
# Optional. Default to apache: : vhost 'ssl_*' defaults.
#
2015-04-28 16:00:25 +03:00
# [ * priority* ]
# ( optional) The priority for the vhost.
# Defaults to '10'
2015-03-15 16:23:09 +01:00
#
2015-04-28 16:00:25 +03:00
# [ * threads* ]
# ( optional) The number of threads for the vhost.
# Defaults to $ : : processorcount
#
2015-10-02 23:18:55 +03:00
# [ * wsgi_application_group* ]
# ( optional) The application group of the WSGI script.
# Defaults to '%{GLOBAL}'
#
# [ * wsgi_pass_authorization* ]
# ( optional) Whether HTTP authorisation headers are passed through to a WSGI
# script when the equivalent HTTP request headers are present.
# Defaults to 'On'
#
2016-03-17 16:00:29 -06:00
# [ * wsgi_script_ensure* ]
# ( optional) File ensure parameter for wsgi scripts.
# Defaults to undef.
#
# [ * wsgi_admin_script_source* ]
# ( optional) Wsgi script source for the admin endpoint. If set to undef
# $ : : keystone: : params: : keystone_wsgi_admin_script_path is used. This source
# is copied to the apache cgi- bin path as keystone- admin.
# Defaults to undef.
#
# [ * wsgi_public_script_source* ]
# ( optional) Wsgi script source for the public endpoint. If set to undef
# $ : : keystone: : params: : keystone_wsgi_public_script_path is used. This source
# is copied to the apache cgi- bin path as keystone- admin.
# Defaults to undef.
#
2015-08-12 10:21:43 -06:00
# [ * access_log_format* ]
# The log format for the virtualhost.
# Optional. Defaults to false .
#
2016-03-01 16:23:14 +01:00
# [ * headers* ]
# ( optional) Headers for the vhost.
# Defaults to undef.
#
2015-07-29 18:15:04 +03:00
# [ * vhost_custom_fragment* ]
# ( optional) Passes a string of custom configuration
# directives to be placed at the end of the vhost configuration.
# Defaults to undef.
#
2014-10-27 09:45:08 -07:00
# [ * wsgi_chunked_request* ]
# ( optional) apache: : vhost wsgi_chunked_request parameter.
# Defaults to undef
#
2016-03-17 16:00:29 -06:00
# DEPRECATED OPTIONS
#
# [ * wsgi_script_source* ]
# ( optional) Wsgi script source.
# Defaults to undef.
#
2013-05-02 18:03:12 +02:00
# = = Dependencies
#
# requires Class [ 'apache' ] & Class [ 'keystone' ]
#
# = = Examples
#
# include apache
#
# class { 'keystone::wsgi::apache': }
#
# = = Note about ports & paths
#
# When using same port for both endpoints ( 4 4 3 anyone ? ) , you * MUST* use two
# different public_path & admin_path !
#
# = = Authors
#
2015-03-20 21:51:04 +01:00
# Francois Charlier < francois. charlier@ enovance. com>
2013-05-02 18:03:12 +02:00
#
# = = Copyright
#
# Copyright 2 0 1 3 eNovance < licensing@ enovance. com>
#
class keystone: : wsgi: : apache (
2016-03-17 16:00:29 -06:00
$ servername = $ : : fqdn,
$ public_port = 5 0 0 0 ,
$ad min_port = 3 5 3 5 7 ,
$b ind_host = undef,
$ad min_bind_host = undef,
$ public_path = '/' ,
$ad min_path = '/' ,
$ ssl = true ,
$ workers = 1 ,
$ ssl_cert = undef,
$ ssl_key = undef,
2016-09-01 12:01:35 +03:00
$ ssl_cert_admin = undef,
$ ssl_key_admin = undef,
2016-03-17 16:00:29 -06:00
$ ssl_chain = undef,
$ ssl_ca = undef,
$ ssl_crl_path = undef,
$ ssl_crl = undef,
$ ssl_certs_dir = undef,
$ threads = $ : : processorcount,
$ priority = '10' ,
$ wsgi_application_group = '%{GLOBAL}' ,
$ wsgi_pass_authorization = 'On' ,
$ wsgi_chunked_request = undef,
2016-07-06 09:29:29 -06:00
$ wsgi_admin_script_source = $ : : keystone: : params: : keystone_wsgi_admin_script_path,
$ wsgi_public_script_source = $ : : keystone: : params: : keystone_wsgi_public_script_path,
2016-03-17 16:00:29 -06:00
$ wsgi_script_ensure = undef,
$acce ss_log_format = false ,
$ headers = undef,
$ vhost_custom_fragment = undef,
#DE PRECATED
$ wsgi_script_source = undef,
2016-07-06 09:29:29 -06:00
) inherits : : keystone: : params {
2013-05-02 18:03:12 +02:00
2016-02-23 18:31:15 -07:00
include : : keystone: : deps
2013-05-02 18:03:12 +02:00
include : : apache
include : : apache: : mod : : wsgi
2014-07-17 16:22:34 -06:00
if $ ssl {
include : : apache: : mod : : ssl
2016-04-05 14:21:03 -07:00
# This is probably a bug in Class [ apache: : mod : : ssl] or in the mod_ssl EL
# package but for now I want this to pass p- o- i CI. The issue is that the
# mod_ssl package is placing a ssl. conf file after the confd_dir is purged
# on Puppet 4 .
Class [ '::apache::mod::ssl' ] - > File [ $ : : apache: : confd_dir]
2016-09-01 12:01:35 +03:00
# Attempt to use the admin cert/ key, else default to the public one.
# Since it' s possible that no cert/ key were given, we allow this to be
# empty with pick_default
$ ssl_cert_admin_real = pick_default( $ ssl_cert_admin, $ ssl_cert)
$ ssl_key_admin_real = pick_default( $ ssl_key_admin, $ ssl_key)
} else {
$ ssl_cert_admin_real = undef
$ ssl_key_admin_real = undef
2014-07-17 16:22:34 -06:00
}
2013-05-02 18:03:12 +02:00
2016-02-23 18:31:15 -07:00
# The httpd package is untagged, but needs to have ordering enforced,
# so handle it here rather than in the deps class .
Anchor[ 'keystone::install::begin' ]
- > Package [ 'httpd' ]
- > Anchor[ 'keystone::install::end' ]
# Configure apache during the config phase
Anchor[ 'keystone::config::begin' ]
- > Apache: : Vhost< | | >
~ > Anchor[ 'keystone::config::end' ]
# Start the service during the service phase
Anchor[ 'keystone::service::begin' ]
- > Service[ 'httpd' ]
- > Anchor[ 'keystone::service::end' ]
# Notify the service when config changes
Anchor[ 'keystone::config::end' ]
~ > Service[ 'httpd' ]
2013-05-02 18:03:12 +02:00
# # Sanitize parameters
# Ensure there's no trailing ' / ' except if this is also the only character
$ public_path_real = regsubst( $ public_path, '(^/.*)/$' , '\1' )
# Ensure there's no trailing ' / ' except if this is also the only character
$ad min_path_real = regsubst( $ad min_path, '(^/.*)/$' , '\1' )
if $ public_port = = $ad min_port and $ public_path_real = = $ad min_path_real {
fail( 'When using the same port for public & private endpoints, public_path and admin_path should be different.' )
}
file { $ : : keystone: : params: : keystone_wsgi_script_path:
ensure = > directory,
owner = > 'keystone' ,
group = > 'keystone' ,
2016-02-23 18:31:15 -07:00
require = > Anchor[ 'keystone::install::end' ] ,
2013-05-02 18:03:12 +02:00
}
2016-03-17 16:00:29 -06:00
$ wsgi_file_target = $ wsgi_script_ensure ? {
'link' = > 'target' ,
default = > 'source'
2013-05-02 18:03:12 +02:00
}
2015-04-28 16:00:25 +03:00
$ wsgi_file_defaults = {
'ensure' = > $ wsgi_script_ensure,
'owner' = > 'keystone' ,
'group' = > 'keystone' ,
'mode' = > '0644' ,
2016-02-23 18:31:15 -07:00
'require' = > File [ $ : : keystone: : params: : keystone_wsgi_script_path] ,
2013-05-02 18:03:12 +02:00
}
2016-03-17 16:00:29 -06:00
if $ wsgi_script_source {
warning( 'The single wsgi script source has been deprecated as part of the Mitaka cycle, please switch to $wsgi_admin_script_source and $wsgi_public_script_source' )
$ wsgi_admin_source = $ wsgi_script_source
$ wsgi_public_source = $ wsgi_script_source
} else {
2016-07-06 09:29:29 -06:00
$ wsgi_admin_source = $ wsgi_admin_script_source
$ wsgi_public_source = $ wsgi_public_script_source
2015-04-28 16:00:25 +03:00
}
2016-03-17 16:00:29 -06:00
$ wsgi_files = {
'keystone_wsgi_admin' = > {
'path' = > "${::keystone::params::keystone_wsgi_script_path}/keystone-admin" ,
"${wsgi_file_target}" = > $ wsgi_admin_source,
} ,
'keystone_wsgi_main' = > {
'path' = > "${::keystone::params::keystone_wsgi_script_path}/keystone-public" ,
"${wsgi_file_target}" = > $ wsgi_public_source,
} ,
2015-04-28 16:00:25 +03:00
}
2016-03-17 16:00:29 -06:00
create_resources( 'file' , $ wsgi_files, $ wsgi_file_defaults)
2015-04-28 16:00:25 +03:00
2015-01-09 12:30:22 -08:00
$ wsgi_daemon_process_options_main = {
user = > 'keystone' ,
group = > 'keystone' ,
processes = > $ workers,
threads = > $ threads,
display- name = > 'keystone-main' ,
2013-05-02 18:03:12 +02:00
}
2015-01-09 12:30:22 -08:00
$ wsgi_daemon_process_options_admin = {
user = > 'keystone' ,
group = > 'keystone' ,
processes = > $ workers,
threads = > $ threads,
display- name = > 'keystone-admin' ,
}
2016-03-17 16:00:29 -06:00
$ wsgi_script_aliases_main = hash( [ $ public_path_real, "${::keystone::params::keystone_wsgi_script_path}/keystone-public" ] )
$ wsgi_script_aliases_admin = hash( [ $ad min_path_real, "${::keystone::params::keystone_wsgi_script_path}/keystone-admin" ] )
2013-05-02 18:03:12 +02:00
if $ public_port = = $ad min_port {
$ wsgi_script_aliases_main_real = merge( $ wsgi_script_aliases_main, $ wsgi_script_aliases_admin)
} else {
$ wsgi_script_aliases_main_real = $ wsgi_script_aliases_main
}
2016-01-27 16:13:08 -05:00
if $ad min_bind_host {
$ real_admin_bind_host = $ad min_bind_host
} else {
# backwards compat before we had admin_bind_host
$ real_admin_bind_host = $b ind_host
}
2014-07-17 16:22:34 -06:00
: : apache: : vhost { 'keystone_wsgi_main' :
ensure = > 'present' ,
2013-05-02 18:03:12 +02:00
servername = > $ servername,
2014-01-28 15:57:24 +01:00
ip = > $b ind_host,
2013-05-02 18:03:12 +02:00
port = > $ public_port,
docroot = > $ : : keystone: : params: : keystone_wsgi_script_path,
docroot_owner = > 'keystone' ,
docroot_group = > 'keystone' ,
2014-07-17 16:22:34 -06:00
priority = > $ priority,
2013-05-02 18:03:12 +02:00
ssl = > $ ssl,
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,
2014-07-17 16:22:34 -06:00
wsgi_daemon_process = > 'keystone_main' ,
2015-01-09 12:30:22 -08:00
wsgi_daemon_process_options = > $ wsgi_daemon_process_options_main,
2014-07-17 16:22:34 -06:00
wsgi_process_group = > 'keystone_main' ,
2013-05-02 18:03:12 +02:00
wsgi_script_aliases = > $ wsgi_script_aliases_main_real,
2015-10-02 23:18:55 +03:00
wsgi_application_group = > $ wsgi_application_group,
wsgi_pass_authorization = > $ wsgi_pass_authorization,
2016-03-01 16:23:14 +01:00
headers = > $ headers,
2015-07-29 18:15:04 +03:00
custom_fragment = > $ vhost_custom_fragment,
2014-10-27 09:45:08 -07:00
wsgi_chunked_request = > $ wsgi_chunked_request,
2014-07-17 16:22:34 -06:00
require = > File [ 'keystone_wsgi_main' ] ,
2015-08-12 10:21:43 -06:00
access_log_format = > $acce ss_log_format,
2013-05-02 18:03:12 +02:00
}
if $ public_port ! = $ad min_port {
2014-07-17 16:22:34 -06:00
: : apache: : vhost { 'keystone_wsgi_admin' :
ensure = > 'present' ,
servername = > $ servername,
2016-01-27 16:13:08 -05:00
ip = > $ real_admin_bind_host,
2014-07-17 16:22:34 -06:00
port = > $ad min_port,
docroot = > $ : : keystone: : params: : keystone_wsgi_script_path,
docroot_owner = > 'keystone' ,
docroot_group = > 'keystone' ,
priority = > $ priority,
ssl = > $ ssl,
2016-09-01 12:01:35 +03:00
ssl_cert = > $ ssl_cert_admin_real,
ssl_key = > $ ssl_key_admin_real,
2014-07-17 16:22:34 -06:00
ssl_chain = > $ ssl_chain,
ssl_ca = > $ ssl_ca,
ssl_crl_path = > $ ssl_crl_path,
ssl_crl = > $ ssl_crl,
ssl_certs_dir = > $ ssl_certs_dir,
wsgi_daemon_process = > 'keystone_admin' ,
2015-01-09 12:30:22 -08:00
wsgi_daemon_process_options = > $ wsgi_daemon_process_options_admin,
2014-07-17 16:22:34 -06:00
wsgi_process_group = > 'keystone_admin' ,
wsgi_script_aliases = > $ wsgi_script_aliases_admin,
2015-10-02 23:18:55 +03:00
wsgi_application_group = > $ wsgi_application_group,
wsgi_pass_authorization = > $ wsgi_pass_authorization,
2016-03-01 16:23:14 +01:00
headers = > $ headers,
2015-07-29 18:15:04 +03:00
custom_fragment = > $ vhost_custom_fragment,
2014-10-27 09:45:08 -07:00
wsgi_chunked_request = > $ wsgi_chunked_request,
2014-07-17 16:22:34 -06:00
require = > File [ 'keystone_wsgi_admin' ] ,
2015-08-12 10:21:43 -06:00
access_log_format = > $acce ss_log_format,
2013-05-02 18:03:12 +02:00
}
}
}