2 # Copyright (C) 2014 eNovance SAS <licensing@enovance.com>
4 # Author: Emilien Macchi <emilien.macchi@enovance.com>
6 # Licensed under the Apache License, Version 2.0 (the "License"); you may
7 # not use this file except in compliance with the License. You may obtain
8 # a copy of the License at
10 # http://www.apache.org/licenses/LICENSE-2.0
12 # Unless required by applicable law or agreed to in writing, software
13 # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
14 # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
15 # License for the specific language governing permissions and limitations
18 # == Class: openstacklib::wsgi::apache
20 # Serve a service with apache mod_wsgi
21 # When using this class you should disable your service.
26 # (optional) Name of the service to run.
31 # (optional) The servername for the virtualhost.
35 # (optional) The host/ip address Apache will listen on.
36 # Defaults to undef (listen on all ip addresses).
39 # (optional) The port to listen.
43 # (optional) Group with permissions on the script
47 # (optional) The prefix for the endpoint.
51 # (optional) The priority for the vhost.
55 # (optional) Use ssl ? (boolean)
59 # (optional) Path to SSL certificate
60 # Default to apache::vhost 'ssl_*' defaults.
63 # (optional) Path to SSL key
64 # Default to apache::vhost 'ssl_*' defaults.
67 # (optional) SSL chain
68 # Default to apache::vhost 'ssl_*' defaults.
71 # (optional) Path to SSL certificate authority
72 # Default to apache::vhost 'ssl_*' defaults.
75 # (optional) Path to SSL certificate revocation list
76 # Default to apache::vhost 'ssl_*' defaults.
79 # (optional) SSL certificate revocation list name
80 # Default to apache::vhost 'ssl_*' defaults.
83 # (optional) Path to SSL certificate directory
84 # Default to apache::vhost 'ssl_*' defaults.
87 # (optional) The number of threads for the vhost.
88 # Defaults to $::processorcount
91 # (optional) User with permissions on the script
95 # (optional) The number of workers for the vhost.
98 # [*wsgi_daemon_process*]
99 # (optional) Name of the WSGI daemon process.
102 # [*wsgi_process_group*]
103 # (optional) Name of the WSGI process group.
106 # [*wsgi_script_dir*]
107 # (optional) The directory path of the WSGI script.
110 # [*wsgi_script_file*]
111 # (optional) The file path of the WSGI script.
114 # [*wsgi_script_source*]
115 # (optional) The source of the WSGI script.
118 define openstacklib::wsgi::apache (
119 $service_name = $name,
125 $servername = $::fqdn,
129 $ssl_certs_dir = undef,
132 $ssl_crl_path = undef,
134 $threads = $::processorcount,
137 $wsgi_daemon_process = $name,
138 $wsgi_process_group = $name,
139 $wsgi_script_dir = undef,
140 $wsgi_script_file = undef,
141 $wsgi_script_source = undef,
145 include ::apache::mod::wsgi
147 include ::apache::mod::ssl
150 # Ensure there's no trailing '/' except if this is also the only character
151 $path_real = regsubst($path, '(^/.*)/$', '\1')
153 if !defined(File[$wsgi_script_dir]) {
154 file { $wsgi_script_dir:
158 require => Package['httpd'],
162 file { $service_name:
164 path => "${wsgi_script_dir}/${wsgi_script_file}",
165 source => $wsgi_script_source,
169 require => File[$wsgi_script_dir],
172 $wsgi_daemon_process_options = {
175 processes => $workers,
178 $wsgi_script_aliases = hash([$path_real,"${wsgi_script_dir}/${wsgi_script_file}"])
180 ::apache::vhost { $service_name:
182 servername => $servername,
185 docroot => $wsgi_script_dir,
186 docroot_owner => $user,
187 docroot_group => $group,
188 priority => $priority,
190 ssl_cert => $ssl_cert,
192 ssl_chain => $ssl_chain,
194 ssl_crl_path => $ssl_crl_path,
196 ssl_certs_dir => $ssl_certs_dir,
197 wsgi_daemon_process => $wsgi_daemon_process,
198 wsgi_daemon_process_options => $wsgi_daemon_process_options,
199 wsgi_process_group => $wsgi_process_group,
200 wsgi_script_aliases => $wsgi_script_aliases,
201 require => File[$service_name],