]> git.donarmstrong.com Git - dsa-puppet.git/blob - 3rdparty/modules/keystone/manifests/wsgi/apache.pp
newline
[dsa-puppet.git] / 3rdparty / modules / keystone / manifests / wsgi / apache.pp
1 #
2 # Class to serve keystone with apache mod_wsgi in place of keystone service
3 #
4 #
5 # Serving keystone from apache is the recommended way to go for production
6 # systems as the current keystone implementation is not multi-processor aware,
7 # thus limiting the performance for concurrent accesses.
8 #
9 # See the following URIs for reference:
10 #    https://etherpad.openstack.org/havana-keystone-performance
11 #    http://adam.younglogic.com/2012/03/keystone-should-move-to-apache-httpd/
12 #
13 # When using this class you should disable your keystone service.
14 #
15 # == Parameters
16 #
17 #   [*servername*]
18 #     The servername for the virtualhost.
19 #     Optional. Defaults to $::fqdn
20 #
21 #   [*public_port*]
22 #     The public port.
23 #     Optional. Defaults to 5000
24 #
25 #   [*admin_port*]
26 #     The admin port.
27 #     Optional. Defaults to 35357
28 #
29 #   [*bind_host*]
30 #     The host/ip address Apache will listen on.
31 #     Optional. Defaults to undef (listen on all ip addresses).
32 #
33 #   [*public_path*]
34 #     The prefix for the public endpoint.
35 #     Optional. Defaults to '/'
36 #
37 #   [*admin_path*]
38 #     The prefix for the admin endpoint.
39 #     Optional. Defaults to '/'
40 #
41 #   [*ssl*]
42 #     Use ssl ? (boolean)
43 #     Optional. Defaults to true
44 #
45 #   [*workers*]
46 #     Number of WSGI workers to spawn.
47 #     Optional. Defaults to 1
48 #
49 #   [*ssl_cert*]
50 #   [*ssl_key*]
51 #   [*ssl_chain*]
52 #   [*ssl_ca*]
53 #   [*ssl_crl_path*]
54 #   [*ssl_crl*]
55 #   [*ssl_certs_dir*]
56 #     apache::vhost ssl parameters.
57 #     Optional. Default to apache::vhost 'ssl_*' defaults.
58 #
59 # == Dependencies
60 #
61 #   requires Class['apache'] & Class['keystone']
62 #
63 # == Examples
64 #
65 #   include apache
66 #
67 #   class { 'keystone::wsgi::apache': }
68 #
69 # == Note about ports & paths
70 #
71 #   When using same port for both endpoints (443 anyone ?), you *MUST* use two
72 #  different public_path & admin_path !
73 #
74 # == Authors
75 #
76 #   Francois Charlier <francois.charlier@enovance.com>
77 #
78 # == Copyright
79 #
80 #   Copyright 2013 eNovance <licensing@enovance.com>
81 #
82 class keystone::wsgi::apache (
83   $servername    = $::fqdn,
84   $public_port   = 5000,
85   $admin_port    = 35357,
86   $bind_host     = undef,
87   $public_path   = '/',
88   $admin_path    = '/',
89   $ssl           = true,
90   $workers       = 1,
91   $ssl_cert      = undef,
92   $ssl_key       = undef,
93   $ssl_chain     = undef,
94   $ssl_ca        = undef,
95   $ssl_crl_path  = undef,
96   $ssl_crl       = undef,
97   $ssl_certs_dir = undef,
98   $threads       = $::processorcount,
99   $priority      = '10',
100 ) {
101
102   include ::keystone::params
103   include ::apache
104   include ::apache::mod::wsgi
105   if $ssl {
106     include ::apache::mod::ssl
107   }
108
109   Package['keystone'] -> Package['httpd']
110   Package['keystone'] ~> Service['httpd']
111   Keystone_config <| |> ~> Service['httpd']
112   Service['httpd'] -> Keystone_endpoint <| |>
113   Service['httpd'] -> Keystone_role <| |>
114   Service['httpd'] -> Keystone_service <| |>
115   Service['httpd'] -> Keystone_tenant <| |>
116   Service['httpd'] -> Keystone_user <| |>
117   Service['httpd'] -> Keystone_user_role <| |>
118
119   ## Sanitize parameters
120
121   # Ensure there's no trailing '/' except if this is also the only character
122   $public_path_real = regsubst($public_path, '(^/.*)/$', '\1')
123   # Ensure there's no trailing '/' except if this is also the only character
124   $admin_path_real = regsubst($admin_path, '(^/.*)/$', '\1')
125
126   if $public_port == $admin_port and $public_path_real == $admin_path_real {
127     fail('When using the same port for public & private endpoints, public_path and admin_path should be different.')
128   }
129
130   file { $::keystone::params::keystone_wsgi_script_path:
131     ensure  => directory,
132     owner   => 'keystone',
133     group   => 'keystone',
134     require => Package['httpd'],
135   }
136
137   file { 'keystone_wsgi_admin':
138     ensure  => file,
139     path    => "${::keystone::params::keystone_wsgi_script_path}/admin",
140     source  => $::keystone::params::keystone_wsgi_script_source,
141     owner   => 'keystone',
142     group   => 'keystone',
143     mode    => '0644',
144     # source file provided by keystone package
145     require => [File[$::keystone::params::keystone_wsgi_script_path], Package['keystone']],
146   }
147
148   file { 'keystone_wsgi_main':
149     ensure  => file,
150     path    => "${::keystone::params::keystone_wsgi_script_path}/main",
151     source  => $::keystone::params::keystone_wsgi_script_source,
152     owner   => 'keystone',
153     group   => 'keystone',
154     mode    => '0644',
155     # source file provided by keystone package
156     require => [File[$::keystone::params::keystone_wsgi_script_path], Package['keystone']],
157   }
158
159   $wsgi_daemon_process_options_main = {
160     user         => 'keystone',
161     group        => 'keystone',
162     processes    => $workers,
163     threads      => $threads,
164     display-name => 'keystone-main',
165   }
166
167   $wsgi_daemon_process_options_admin = {
168     user         => 'keystone',
169     group        => 'keystone',
170     processes    => $workers,
171     threads      => $threads,
172     display-name => 'keystone-admin',
173   }
174
175   $wsgi_script_aliases_main = hash([$public_path_real,"${::keystone::params::keystone_wsgi_script_path}/main"])
176   $wsgi_script_aliases_admin = hash([$admin_path_real, "${::keystone::params::keystone_wsgi_script_path}/admin"])
177
178   if $public_port == $admin_port {
179     $wsgi_script_aliases_main_real = merge($wsgi_script_aliases_main, $wsgi_script_aliases_admin)
180   } else {
181     $wsgi_script_aliases_main_real = $wsgi_script_aliases_main
182   }
183
184   ::apache::vhost { 'keystone_wsgi_main':
185     ensure                      => 'present',
186     servername                  => $servername,
187     ip                          => $bind_host,
188     port                        => $public_port,
189     docroot                     => $::keystone::params::keystone_wsgi_script_path,
190     docroot_owner               => 'keystone',
191     docroot_group               => 'keystone',
192     priority                    => $priority,
193     ssl                         => $ssl,
194     ssl_cert                    => $ssl_cert,
195     ssl_key                     => $ssl_key,
196     ssl_chain                   => $ssl_chain,
197     ssl_ca                      => $ssl_ca,
198     ssl_crl_path                => $ssl_crl_path,
199     ssl_crl                     => $ssl_crl,
200     ssl_certs_dir               => $ssl_certs_dir,
201     wsgi_daemon_process         => 'keystone_main',
202     wsgi_daemon_process_options => $wsgi_daemon_process_options_main,
203     wsgi_process_group          => 'keystone_main',
204     wsgi_script_aliases         => $wsgi_script_aliases_main_real,
205     require                     => File['keystone_wsgi_main'],
206   }
207
208   if $public_port != $admin_port {
209     ::apache::vhost { 'keystone_wsgi_admin':
210       ensure                      => 'present',
211       servername                  => $servername,
212       ip                          => $bind_host,
213       port                        => $admin_port,
214       docroot                     => $::keystone::params::keystone_wsgi_script_path,
215       docroot_owner               => 'keystone',
216       docroot_group               => 'keystone',
217       priority                    => $priority,
218       ssl                         => $ssl,
219       ssl_cert                    => $ssl_cert,
220       ssl_key                     => $ssl_key,
221       ssl_chain                   => $ssl_chain,
222       ssl_ca                      => $ssl_ca,
223       ssl_crl_path                => $ssl_crl_path,
224       ssl_crl                     => $ssl_crl,
225       ssl_certs_dir               => $ssl_certs_dir,
226       wsgi_daemon_process         => 'keystone_admin',
227       wsgi_daemon_process_options => $wsgi_daemon_process_options_admin,
228       wsgi_process_group          => 'keystone_admin',
229       wsgi_script_aliases         => $wsgi_script_aliases_admin,
230       require                     => File['keystone_wsgi_admin'],
231     }
232   }
233 }