]> git.donarmstrong.com Git - dsa-puppet.git/blob - 3rdparty/modules/keystone/manifests/init.pp
Update to Kilo
[dsa-puppet.git] / 3rdparty / modules / keystone / manifests / init.pp
1 #
2 # Module for managing keystone config.
3 #
4 # == Parameters
5 #
6 # [*package_ensure*]
7 #   (optional) Desired ensure state of packages.
8 #   accepts latest or specific versions.
9 #   Defaults to present.
10 #
11 # [*client_package_ensure*]
12 #   (optional) Desired ensure state of the client package.
13 #   accepts latest or specific versions.
14 #   Defaults to present.
15 #
16 # [*public_port*]
17 #   (optional) Port that keystone binds to.
18 #   Defaults to '5000'
19 #
20 # [*compute_port*]
21 #   (optional) DEPRECATED The port for compute servie.
22 #   Defaults to '8774'
23 #
24 # [*admin_port*]
25 #   (optional) Port that can be used for admin tasks.
26 #   Defaults to '35357'
27 #
28 # [*admin_token*]
29 #   Admin token that can be used to authenticate as a keystone
30 #   admin. Required.
31 #
32 # [*verbose*]
33 #   (optional) Rather keystone should log at verbose level.
34 #   Defaults to false.
35 #
36 # [*debug*]
37 #   (optional) Rather keystone should log at debug level.
38 #   Defaults to False.
39 #
40 # [*use_syslog*]
41 #   (optional) Use syslog for logging.
42 #   Defaults to false.
43 #
44 # [*log_facility*]
45 #   (optional) Syslog facility to receive log lines.
46 #   Defaults to 'LOG_USER'.
47 #
48 # [*catalog_type*]
49 #   (optional) Type of catalog that keystone uses to store endpoints,services.
50 #   Defaults to sql. (Also accepts template)
51 #
52 # [*catalog_driver*]
53 #   (optional) Catalog driver used by Keystone to store endpoints and services.
54 #   Setting this value will override and ignore catalog_type.
55 #   Defaults to false.
56 #
57 # [*catalog_template_file*]
58 #   (optional) Path to the catalog used if catalog_type equals 'template'.
59 #   Defaults to '/etc/keystone/default_catalog.templates'
60 #
61 # [*token_provider*]
62 #   (optional) Format keystone uses for tokens.
63 #   Defaults to 'keystone.token.providers.uuid.Provider'
64 #   Supports PKI, PKIZ, Fernet, and UUID.
65 #
66 # [*token_driver*]
67 #   (optional) Driver to use for managing tokens.
68 #   Defaults to 'keystone.token.persistence.backends.sql.Token'
69 #
70 # [*token_expiration*]
71 #   (optional) Amount of time a token should remain valid (seconds).
72 #   Defaults to 3600 (1 hour).
73 #
74 # [*revoke_driver*]
75 #   (optional) Driver for token revocation.
76 #   Defaults to 'keystone.contrib.revoke.backends.sql.Revoke'
77 #
78 # [*cache_dir*]
79 #   (optional) Directory created when token_provider is pki.
80 #   Defaults to /var/cache/keystone.
81 #
82 # [*memcache_servers*]
83 #   (optional) List of memcache servers in format of server:port.
84 #   Used with token_driver 'keystone.token.backends.memcache.Token'.
85 #   Defaults to false. Example: ['localhost:11211']
86 #
87 # [*cache_backend*]
88 #   (optional) Dogpile.cache backend module. It is recommended that Memcache with pooling
89 #   (keystone.cache.memcache_pool) or Redis (dogpile.cache.redis) be used in production.
90 #   This has no effects unless 'memcache_servers' is set.
91 #   Defaults to 'keystone.common.cache.noop'
92 #
93 # [*cache_backend_argument*]
94 #   (optional) List of arguments in format of argname:value supplied to the backend module.
95 #   Specify this option once per argument to be passed to the dogpile.cache backend.
96 #   This has no effects unless 'memcache_servers' is set.
97 #   Default to undef.
98 #
99 # [*debug_cache_backend*]
100 #   (optional) Extra debugging from the cache backend (cache keys, get/set/delete calls).
101 #   This has no effects unless 'memcache_servers' is set.
102 #   Default to false.
103 #
104 # [*token_caching*]
105 #   (optional) Toggle for token system caching. This has no effects unless 'memcache_servers' is set.
106 #   Default to true.
107 #
108 # [*manage_service*]
109 #   (Optional) If Puppet should manage service startup / shutdown.
110 #   Defaults to true.
111 #
112 # [*enabled*]
113 #  (optional) If the keystone services should be enabled.
114 #   Default to true.
115 #
116 # [*database_connection*]
117 #   (optional) Url used to connect to database.
118 #   Defaults to sqlite:////var/lib/keystone/keystone.db
119 #
120 # [*database_idle_timeout*]
121 #   (optional) Timeout when db connections should be reaped.
122 #   Defaults to 200.
123 #
124 # [*enable_pki_setup*]
125 #   (optional) Enable call to pki_setup to generate the cert for signing pki tokens and
126 #   revocation lists if it doesn't already exist. This generates a cert and key stored in file
127 #   locations based on the signing_certfile and signing_keyfile paramters below. If you are
128 #   providing your own signing cert, make this false.
129 #   Default to true.
130 #
131 # [*signing_certfile*]
132 #   (optional) Location of the cert file for signing pki tokens and revocation lists.
133 #   Note that if this file already exists (i.e. you are providing your own signing cert),
134 #   the file will not be overwritten, even if enable_pki_setup is set to true.
135 #   Default: /etc/keystone/ssl/certs/signing_cert.pem
136 #
137 # [*signing_keyfile*]
138 #   (optional) Location of the key file for signing pki tokens and revocation lists.
139 #   Note that if this file already exists (i.e. you are providing your own signing cert), the file
140 #   will not be overwritten, even if enable_pki_setup is set to true.
141 #   Default: /etc/keystone/ssl/private/signing_key.pem
142 #
143 # [*signing_ca_certs*]
144 #   (optional) Use this CA certs file along with signing_certfile/signing_keyfile for
145 #   signing pki tokens and revocation lists.
146 #   Default: /etc/keystone/ssl/certs/ca.pem
147 #
148 # [*signing_ca_key*]
149 #   (optional) Use this CA key file along with signing_certfile/signing_keyfile for signing
150 #   pki tokens and revocation lists.
151 #   Default: /etc/keystone/ssl/private/cakey.pem
152 #
153 # [*signing_cert_subject*]
154 #   (optional) Certificate subject (auto generated certificate) for token signing.
155 #   Defaults to '/C=US/ST=Unset/L=Unset/O=Unset/CN=www.example.com'
156 #
157 # [*signing_key_size*]
158 #   (optional) Key size (in bits) for token signing cert (auto generated certificate)
159 #   Defaults to 2048
160 #
161 # [*rabbit_host*]
162 #   (optional) Location of rabbitmq installation.
163 #    Defaults to localhost.
164 #
165 # [*rabbit_port*]
166 #   (optional) Port for rabbitmq instance.
167 #   Defaults to 5672.
168 #
169 # [*rabbit_hosts*]
170 #   (optional) Location of rabbitmq installation.
171 #   Defaults to undef.
172 #
173 # [*rabbit_password*]
174 #   (optional) Password used to connect to rabbitmq.
175 #   Defaults to guest.
176 #
177 # [*rabbit_userid*]
178 #   (optional) User used to connect to rabbitmq.
179 #   Defaults to guest.
180 #
181 # [*rabbit_virtual_host*]
182 #   (optional) The RabbitMQ virtual host.
183 #   Defaults to /.
184 #
185 # [*rabbit_use_ssl*]
186 #   (optional) Connect over SSL for RabbitMQ
187 #   Defaults to false
188 #
189 # [*kombu_ssl_ca_certs*]
190 #   (optional) SSL certification authority file (valid only if SSL enabled).
191 #   Defaults to undef
192 #
193 # [*kombu_ssl_certfile*]
194 #   (optional) SSL cert file (valid only if SSL enabled).
195 #   Defaults to undef
196 #
197 # [*kombu_ssl_keyfile*]
198 #   (optional) SSL key file (valid only if SSL enabled).
199 #   Defaults to undef
200 #
201 # [*kombu_ssl_version*]
202 #   (optional) SSL version to use (valid only if SSL enabled).
203 #   Valid values are TLSv1, SSLv23 and SSLv3. SSLv2 may be
204 #   available on some distributions.
205 #   Defaults to 'TLSv1'
206 #
207 # [*notification_driver*]
208 #   RPC driver. Not enabled by default
209 #
210 # [*notification_topics*]
211 #   (optional) AMQP topics to publish to when using the RPC notification driver.
212 #   Default to false.
213 #
214 # [*notification_format*]
215 #   Format for the notifications. Valid values are 'basic' and 'cadf'.
216 #   Default to undef
217 #
218 # [*control_exchange*]
219 #   (optional) AMQP exchange to connect to if using RabbitMQ or Qpid
220 #   Default to false.
221 #
222 # [*public_bind_host*]
223 #   (optional) The IP address of the public network interface to listen on
224 #   Default to '0.0.0.0'.
225 #
226 # [*admin_bind_host*]
227 #   (optional) The IP address of the public network interface to listen on
228 #   Default to '0.0.0.0'.
229 #
230 # [*log_dir*]
231 #   (optional) Directory where logs should be stored
232 #   If set to boolean false, it will not log to any directory
233 #   Defaults to '/var/log/keystone'
234 #
235 # [*log_file*]
236 #   (optional) Where to log
237 #   Defaults to false
238 #
239 # [*public_endpoint*]
240 #   (optional) The base public endpoint URL for keystone that are
241 #   advertised to clients (NOTE: this does NOT affect how
242 #   keystone listens for connections) (string value)
243 #   If set to false, no public_endpoint will be defined in keystone.conf.
244 #   Sample value: 'http://localhost:5000/'
245 #   Defaults to false
246 #
247 # [*admin_endpoint*]
248 #   (optional) The base admin endpoint URL for keystone that are
249 #   advertised to clients (NOTE: this does NOT affect how keystone listens
250 #   for connections) (string value)
251 #   If set to false, no admin_endpoint will be defined in keystone.conf.
252 #   Sample value: 'http://localhost:35357/'
253 #   Defaults to false
254 #
255 # [*enable_ssl*]
256 #   (optional) Toggle for SSL support on the keystone eventlet servers.
257 #   (boolean value)
258 #   Defaults to false
259 #
260 # [*ssl_certfile*]
261 #   (optional) Path of the certfile for SSL. (string value)
262 #   Defaults to '/etc/keystone/ssl/certs/keystone.pem'
263 #
264 # [*ssl_keyfile*]
265 #   (optional) Path of the keyfile for SSL. (string value)
266 #   Defaults to '/etc/keystone/ssl/private/keystonekey.pem'
267 #
268 # [*ssl_ca_certs*]
269 #   (optional) Path of the ca cert file for SSL. (string value)
270 #   Defaults to '/etc/keystone/ssl/certs/ca.pem'
271 #
272 # [*ssl_ca_key*]
273 #   (optional) Path of the CA key file for SSL (string value)
274 #   Defaults to '/etc/keystone/ssl/private/cakey.pem'
275 #
276 # [*ssl_cert_subject*]
277 #   (optional) SSL Certificate Subject (auto generated certificate)
278 #   (string value)
279 #   Defaults to '/C=US/ST=Unset/L=Unset/O=Unset/CN=localhost'
280 #
281 # [*mysql_module*]
282 #   (optional) Deprecated. Does nothing.
283 #
284 # [*validate_service*]
285 #   (optional) Whether to validate keystone connections after
286 #   the service is started.
287 #   Defaults to false
288 #
289 # [*validate_insecure*]
290 #   (optional) Whether to validate keystone connections
291 #   using the --insecure option with keystone client.
292 #   Defaults to false
293 #
294 # [*validate_cacert*]
295 #   (optional) Whether to validate keystone connections
296 #   using the specified argument with the --os-cacert option
297 #   with keystone client.
298 #   Defaults to undef
299 #
300 # [*validate_auth_url*]
301 #   (optional) The url to validate keystone against
302 #   Defaults to undef
303 #
304 # [*service_provider*]
305 #   (optional) Provider, that can be used for keystone service.
306 #   Default value defined in keystone::params for given operation system.
307 #   If you use Pacemaker or another Cluster Resource Manager, you can make
308 #   custom service provider for changing start/stop/status behavior of service,
309 #   and set it here.
310 #
311 # [*service_name*]
312 #   (optional) Name of the service that will be providing the
313 #   server functionality of keystone.  For example, the default
314 #   is just 'keystone', which means keystone will be run as a
315 #   standalone eventlet service, and will able to be managed
316 #   separately by the operating system's service manager.  For
317 #   example, you will be able to use
318 #   service openstack-keystone restart
319 #   to restart the service.
320 #   If the value is 'httpd', this means keystone will be a web
321 #   service, and you must use another class to configure that
322 #   web service.  For example, after calling class {'keystone'...}
323 #   use class { 'keystone::wsgi::apache'...} to make keystone be
324 #   a web app using apache mod_wsgi.
325 #   Defaults to '$::keystone::params::service_name'
326 #   NOTE: validate_service only applies if the default value is used.
327 #
328 # [*paste_config*]
329 #   (optional) Name of the paste configuration file that defines the
330 #   available pipelines. (string value)
331 #   Defaults to '/usr/share/keystone/keystone-dist-paste.ini' on RedHat and
332 #   undef on other platforms.
333 #
334 # [*max_token_size*]
335 #   (optional) maximum allowable Keystone token size
336 #   Defaults to undef
337 #
338 # [*admin_workers*]
339 #   (optional) The number of worker processes to serve the admin WSGI application.
340 #   Defaults to max($::processorcount, 2)
341 #
342 # [*public_workers*]
343 #   (optional) The number of worker processes to serve the public WSGI application.
344 #   Defaults to max($::processorcount, 2)
345 #
346 # [*sync_db*]
347 #   (Optional) Run db sync on the node.
348 #   Defaults to true
349 #
350 # [*enable_fernet_setup*]
351 #   (Optional) Setup keystone for fernet tokens. This is typically only
352 #   run on a single node, then the keys are replicated to the other nodes
353 #   in a cluster. You would typically also pair this with a fernet token
354 #   provider setting.
355 #   Defaults to false
356 #
357 # [*fernet_key_repository*]
358 #   (Optional) Location for the fernet key repository. This value must
359 #   be set if enable_fernet_setup is set to true.
360 #   Defaults to '/etc/keystone/fernet-keys'
361 #
362 # [*fernet_max_active_keys*]
363 #   (Optional) Number of maximum active Fernet keys. Integer > 0.
364 #   Defaults to undef
365 #
366 # [*default_domain*]
367 #   (optional) When Keystone v3 support is enabled, v2 clients will need
368 #   to have a domain assigned for certain operations.  For example,
369 #   doing a user create operation must have a domain associated with it.
370 #   This is the domain which will be used if a domain is needed and not
371 #   explicitly set in the request.
372 #   Defaults to undef (will use built-in Keystone default)
373 #
374 # == Dependencies
375 #  None
376 #
377 # == Examples
378 #
379 #   class { 'keystone':
380 #     log_verbose => 'True',
381 #     admin_token => 'my_special_token',
382 #   }
383 #
384 #   OR
385 #
386 #   class { 'keystone':
387 #      ...
388 #      service_name => 'httpd',
389 #      ...
390 #   }
391 #   class { 'keystone::wsgi::apache':
392 #      ...
393 #   }
394 #
395 # == Authors
396 #
397 #   Dan Bode dan@puppetlabs.com
398 #
399 # == Copyright
400 #
401 # Copyright 2012 Puppetlabs Inc, unless otherwise noted.
402 #
403 class keystone(
404   $admin_token,
405   $package_ensure         = 'present',
406   $client_package_ensure  = 'present',
407   $public_bind_host       = '0.0.0.0',
408   $admin_bind_host        = '0.0.0.0',
409   $public_port            = '5000',
410   $admin_port             = '35357',
411   $verbose                = false,
412   $debug                  = false,
413   $log_dir                = '/var/log/keystone',
414   $log_file               = false,
415   $use_syslog             = false,
416   $log_facility           = 'LOG_USER',
417   $catalog_type           = 'sql',
418   $catalog_driver         = false,
419   $catalog_template_file  = '/etc/keystone/default_catalog.templates',
420   $token_provider         = 'keystone.token.providers.uuid.Provider',
421   $token_driver           = 'keystone.token.persistence.backends.sql.Token',
422   $token_expiration       = 3600,
423   $revoke_driver          = 'keystone.contrib.revoke.backends.sql.Revoke',
424   $public_endpoint        = false,
425   $admin_endpoint         = false,
426   $enable_ssl             = false,
427   $ssl_certfile           = '/etc/keystone/ssl/certs/keystone.pem',
428   $ssl_keyfile            = '/etc/keystone/ssl/private/keystonekey.pem',
429   $ssl_ca_certs           = '/etc/keystone/ssl/certs/ca.pem',
430   $ssl_ca_key             = '/etc/keystone/ssl/private/cakey.pem',
431   $ssl_cert_subject       = '/C=US/ST=Unset/L=Unset/O=Unset/CN=localhost',
432   $cache_dir              = '/var/cache/keystone',
433   $memcache_servers       = false,
434   $manage_service         = true,
435   $cache_backend          = 'keystone.common.cache.noop',
436   $cache_backend_argument = undef,
437   $debug_cache_backend    = false,
438   $token_caching          = true,
439   $enabled                = true,
440   $database_connection    = 'sqlite:////var/lib/keystone/keystone.db',
441   $database_idle_timeout  = '200',
442   $enable_pki_setup       = true,
443   $signing_certfile       = '/etc/keystone/ssl/certs/signing_cert.pem',
444   $signing_keyfile        = '/etc/keystone/ssl/private/signing_key.pem',
445   $signing_ca_certs       = '/etc/keystone/ssl/certs/ca.pem',
446   $signing_ca_key         = '/etc/keystone/ssl/private/cakey.pem',
447   $signing_cert_subject   = '/C=US/ST=Unset/L=Unset/O=Unset/CN=www.example.com',
448   $signing_key_size       = 2048,
449   $rabbit_host            = 'localhost',
450   $rabbit_hosts           = false,
451   $rabbit_password        = 'guest',
452   $rabbit_port            = '5672',
453   $rabbit_userid          = 'guest',
454   $rabbit_virtual_host    = '/',
455   $rabbit_use_ssl         = false,
456   $kombu_ssl_ca_certs     = undef,
457   $kombu_ssl_certfile     = undef,
458   $kombu_ssl_keyfile      = undef,
459   $kombu_ssl_version      = 'TLSv1',
460   $notification_driver    = false,
461   $notification_topics    = false,
462   $notification_format    = undef,
463   $control_exchange       = false,
464   $validate_service       = false,
465   $validate_insecure      = false,
466   $validate_auth_url      = false,
467   $validate_cacert        = undef,
468   $paste_config           = $::keystone::params::paste_config,
469   $service_provider       = $::keystone::params::service_provider,
470   $service_name           = $::keystone::params::service_name,
471   $max_token_size         = undef,
472   $admin_workers          = max($::processorcount, 2),
473   $public_workers         = max($::processorcount, 2),
474   $sync_db                = true,
475   $enable_fernet_setup    = false,
476   $fernet_key_repository  = '/etc/keystone/fernet-keys',
477   $fernet_max_active_keys = undef,
478   $default_domain         = undef,
479   # DEPRECATED PARAMETERS
480   $mysql_module           = undef,
481   $compute_port           = undef,
482 ) inherits keystone::params {
483
484   if ! $catalog_driver {
485     validate_re($catalog_type, 'template|sql')
486   }
487
488   if $mysql_module {
489     warning('The mysql_module parameter is deprecated. The latest 2.x mysql module will be used.')
490   }
491
492   if ($admin_endpoint and 'v2.0' in $admin_endpoint) {
493     warning('Version string /v2.0/ should not be included in keystone::admin_endpoint')
494   }
495
496   if ($public_endpoint and 'v2.0' in $public_endpoint) {
497     warning('Version string /v2.0/ should not be included in keystone::public_endpoint')
498   }
499
500   if $rabbit_use_ssl {
501     if !$kombu_ssl_ca_certs {
502       fail('The kombu_ssl_ca_certs parameter is required when rabbit_use_ssl is set to true')
503     }
504     if !$kombu_ssl_certfile {
505       fail('The kombu_ssl_certfile parameter is required when rabbit_use_ssl is set to true')
506     }
507     if !$kombu_ssl_keyfile {
508       fail('The kombu_ssl_keyfile parameter is required when rabbit_use_ssl is set to true')
509     }
510   }
511
512   File['/etc/keystone/keystone.conf'] -> Keystone_config<||> ~> Service[$service_name]
513   Keystone_config<||> ~> Exec<| title == 'keystone-manage db_sync'|>
514   Keystone_config<||> ~> Exec<| title == 'keystone-manage pki_setup'|>
515   Keystone_config<||> ~> Exec<| title == 'keystone-manage fernet_setup'|>
516
517   include ::keystone::params
518
519   package { 'keystone':
520     ensure => $package_ensure,
521     name   => $::keystone::params::package_name,
522     tag    => 'openstack',
523   }
524   if $client_package_ensure == 'present' {
525     include '::openstacklib::openstackclient'
526   } else {
527     class { '::openstacklib::openstackclient':
528       package_ensure => $client_package_ensure,
529     }
530   }
531
532   group { 'keystone':
533     ensure  => present,
534     system  => true,
535     require => Package['keystone'],
536   }
537
538   user { 'keystone':
539     ensure  => 'present',
540     gid     => 'keystone',
541     system  => true,
542     require => Package['keystone'],
543   }
544
545   file { ['/etc/keystone', '/var/log/keystone', '/var/lib/keystone']:
546     ensure  => directory,
547     mode    => '0750',
548     owner   => 'keystone',
549     group   => 'keystone',
550     require => Package['keystone'],
551     notify  => Service[$service_name],
552   }
553
554   file { '/etc/keystone/keystone.conf':
555     ensure  => present,
556     mode    => '0600',
557     owner   => 'keystone',
558     group   => 'keystone',
559     require => Package['keystone'],
560     notify  => Service[$service_name],
561   }
562
563   keystone_config {
564     'DEFAULT/admin_token':      value => $admin_token, secret => true;
565     'DEFAULT/public_bind_host': value => $public_bind_host;
566     'DEFAULT/admin_bind_host':  value => $admin_bind_host;
567     'DEFAULT/public_port':      value => $public_port;
568     'DEFAULT/admin_port':       value => $admin_port;
569     'DEFAULT/verbose':          value => $verbose;
570     'DEFAULT/debug':            value => $debug;
571   }
572
573   if $compute_port {
574     warning('The compute_port parameter is deprecated and will be removed in L')
575     keystone_config {
576       'DEFAULT/compute_port': value => $compute_port;
577     }
578   } else {
579     keystone_config {
580       'DEFAULT/compute_port': ensure => absent;
581     }
582   }
583
584   # Endpoint configuration
585   if $public_endpoint {
586     keystone_config {
587       'DEFAULT/public_endpoint': value => $public_endpoint;
588     }
589   } else {
590     keystone_config {
591       'DEFAULT/public_endpoint': ensure => absent;
592     }
593   }
594   if $admin_endpoint {
595     keystone_config {
596       'DEFAULT/admin_endpoint': value => $admin_endpoint;
597     }
598   } else {
599     keystone_config {
600       'DEFAULT/admin_endpoint': ensure => absent;
601     }
602   }
603   # requirements for memcache token driver
604   if ($token_driver =~ /memcache/ ) {
605     package { 'python-memcache':
606       ensure => present,
607       name   => $::keystone::params::python_memcache_package_name,
608     }
609   }
610
611   # token driver config
612   keystone_config {
613     'token/driver':     value => $token_driver;
614     'token/expiration': value => $token_expiration;
615   }
616
617   if $revoke_driver {
618     keystone_config {
619       'revoke/driver':    value => $revoke_driver;
620     }
621   } else {
622     keystone_config {
623       'revoke/driver':    ensure => absent;
624     }
625   }
626
627   # ssl config
628   if ($enable_ssl) {
629     keystone_config {
630       'ssl/enable':              value  => true;
631       'ssl/certfile':            value  => $ssl_certfile;
632       'ssl/keyfile':             value  => $ssl_keyfile;
633       'ssl/ca_certs':            value  => $ssl_ca_certs;
634       'ssl/ca_key':              value  => $ssl_ca_key;
635       'ssl/cert_subject':        value  => $ssl_cert_subject;
636     }
637   } else {
638     keystone_config {
639       'ssl/enable':              value  => false;
640     }
641   }
642
643   if($database_connection =~ /mysql:\/\/\S+:\S+@\S+\/\S+/) {
644     require 'mysql::bindings'
645     require 'mysql::bindings::python'
646   } elsif($database_connection =~ /postgresql:\/\/\S+:\S+@\S+\/\S+/) {
647
648   } elsif($database_connection =~ /sqlite:\/\//) {
649
650   } else {
651     fail("Invalid db connection ${database_connection}")
652   }
653
654   # memcache connection config
655   if $memcache_servers {
656     validate_array($memcache_servers)
657     Service<| title == 'memcached' |> -> Service['keystone']
658     keystone_config {
659       'cache/enabled':              value => true;
660       'cache/backend':              value => $cache_backend;
661       'cache/debug_cache_backend':  value => $debug_cache_backend;
662       'token/caching':              value => $token_caching;
663       'memcache/servers':           value => join($memcache_servers, ',');
664     }
665     if $cache_backend_argument {
666       validate_array($cache_backend_argument)
667       keystone_config {
668         'cache/backend_argument':   value => join($cache_backend_argument, ',');
669       }
670     } else {
671       keystone_config {
672         'cache/backend_argument':  ensure => absent;
673       }
674     }
675   } else {
676     keystone_config {
677       'cache/enabled':             ensure => absent;
678       'cache/backend':             ensure => absent;
679       'cache/backend_argument':    ensure => absent;
680       'cache/debug_cache_backend': ensure => absent;
681       'token/caching':             ensure => absent;
682       'memcache/servers':          ensure => absent;
683     }
684   }
685
686   # db connection config
687   keystone_config {
688     'database/connection':   value => $database_connection, secret => true;
689     'database/idle_timeout': value => $database_idle_timeout;
690   }
691
692   # configure based on the catalog backend
693   if $catalog_driver {
694     $catalog_driver_real = $catalog_driver
695   }
696   elsif ($catalog_type == 'template') {
697     $catalog_driver_real = 'keystone.catalog.backends.templated.Catalog'
698   }
699   elsif ($catalog_type == 'sql') {
700     $catalog_driver_real = 'keystone.catalog.backends.sql.Catalog'
701   }
702
703   keystone_config {
704     'catalog/driver':        value => $catalog_driver_real;
705     'catalog/template_file': value => $catalog_template_file;
706   }
707
708   # Set the signing key/cert configuration values.
709   keystone_config {
710     'signing/certfile':     value => $signing_certfile;
711     'signing/keyfile':      value => $signing_keyfile;
712     'signing/ca_certs':     value => $signing_ca_certs;
713     'signing/ca_key':       value => $signing_ca_key;
714     'signing/cert_subject': value => $signing_cert_subject;
715     'signing/key_size':     value => $signing_key_size;
716   }
717
718   # Create cache directory used for signing.
719   file { $cache_dir:
720     ensure => directory,
721   }
722
723   # Only do pki_setup if we were asked to do so.  This is needed
724   # regardless of the token provider since token revocation lists
725   # are always signed.
726   if $enable_pki_setup {
727     exec { 'keystone-manage pki_setup':
728       path        => '/usr/bin',
729       user        => 'keystone',
730       refreshonly => true,
731       creates     => $signing_keyfile,
732       notify      => Service[$service_name],
733       subscribe   => Package['keystone'],
734       require     => User['keystone'],
735     }
736   }
737
738   keystone_config { 'token/provider': value => $token_provider }
739
740   if $max_token_size {
741     keystone_config { 'DEFAULT/max_token_size': value => $max_token_size }
742   } else {
743     keystone_config { 'DEFAULT/max_token_size': ensure => absent }
744   }
745
746   if $notification_driver {
747     keystone_config { 'DEFAULT/notification_driver': value => $notification_driver }
748   } else {
749     keystone_config { 'DEFAULT/notification_driver': ensure => absent }
750   }
751   if $notification_topics {
752     keystone_config { 'DEFAULT/notification_topics': value => $notification_topics }
753   } else {
754     keystone_config { 'DEFAULT/notification_topics': ensure => absent }
755   }
756   if $notification_format {
757     keystone_config { 'DEFAULT/notification_format': value => $notification_format }
758   } else {
759     keystone_config { 'DEFAULT/notification_format': ensure => absent }
760   }
761   if $control_exchange {
762     keystone_config { 'DEFAULT/control_exchange': value => $control_exchange }
763   } else {
764     keystone_config { 'DEFAULT/control_exchange': ensure => absent }
765   }
766
767   keystone_config {
768     'DEFAULT/rabbit_password':     value => $rabbit_password, secret => true;
769     'DEFAULT/rabbit_userid':       value => $rabbit_userid;
770     'DEFAULT/rabbit_virtual_host': value => $rabbit_virtual_host;
771   }
772
773   if $rabbit_hosts {
774     keystone_config { 'DEFAULT/rabbit_hosts':     value => join($rabbit_hosts, ',') }
775     keystone_config { 'DEFAULT/rabbit_ha_queues': value => true }
776   } else {
777     keystone_config { 'DEFAULT/rabbit_host':      value => $rabbit_host }
778     keystone_config { 'DEFAULT/rabbit_port':      value => $rabbit_port }
779     keystone_config { 'DEFAULT/rabbit_hosts':     value => "${rabbit_host}:${rabbit_port}" }
780     keystone_config { 'DEFAULT/rabbit_ha_queues': value => false }
781   }
782
783   keystone_config { 'DEFAULT/rabbit_use_ssl': value => $rabbit_use_ssl }
784   if $rabbit_use_ssl {
785     keystone_config {
786       'DEFAULT/kombu_ssl_ca_certs': value => $kombu_ssl_ca_certs;
787       'DEFAULT/kombu_ssl_certfile': value => $kombu_ssl_certfile;
788       'DEFAULT/kombu_ssl_keyfile':  value => $kombu_ssl_keyfile;
789       'DEFAULT/kombu_ssl_version':  value => $kombu_ssl_version;
790     }
791   } else {
792     keystone_config {
793       'DEFAULT/kombu_ssl_ca_certs': ensure => absent;
794       'DEFAULT/kombu_ssl_certfile': ensure => absent;
795       'DEFAULT/kombu_ssl_keyfile':  ensure => absent;
796       'DEFAULT/kombu_ssl_version':  ensure => absent;
797     }
798   }
799
800   keystone_config {
801     'DEFAULT/admin_workers':  value => $admin_workers;
802     'DEFAULT/public_workers': value => $public_workers;
803   }
804
805   if $manage_service {
806     if $enabled {
807       $service_ensure = 'running'
808     } else {
809       $service_ensure = 'stopped'
810     }
811   } else {
812     warning('Execution of db_sync does not depend on $enabled anymore. Please use sync_db instead.')
813   }
814
815   if $service_name == $::keystone::params::service_name {
816     if $validate_service {
817       if $validate_auth_url {
818         $v_auth_url = $validate_auth_url
819       } else {
820         $v_auth_url = $admin_endpoint
821       }
822
823       class { '::keystone::service':
824         ensure         => $service_ensure,
825         service_name   => $service_name,
826         enable         => $enabled,
827         hasstatus      => true,
828         hasrestart     => true,
829         provider       => $service_provider,
830         validate       => true,
831         admin_endpoint => $v_auth_url,
832         admin_token    => $admin_token,
833         insecure       => $validate_insecure,
834         cacert         => $validate_cacert,
835       }
836     } else {
837       class { '::keystone::service':
838         ensure       => $service_ensure,
839         service_name => $service_name,
840         enable       => $enabled,
841         hasstatus    => true,
842         hasrestart   => true,
843         provider     => $service_provider,
844         validate     => false,
845       }
846     }
847   } elsif $service_name == 'httpd' {
848     class { '::keystone::service':
849       ensure       => 'stopped',
850       service_name => $::keystone::params::service_name,
851       enable       => false,
852       provider     => $service_provider,
853       validate     => false,
854     }
855   } else {
856     fail('Invalid service_name. Either keystone/openstack-keystone for running as a standalone service, or httpd for being run by a httpd server')
857   }
858
859   if $sync_db {
860     include ::keystone::db::sync
861     Class['::keystone::db::sync'] ~> Service[$service_name]
862   }
863
864   # Syslog configuration
865   if $use_syslog {
866     keystone_config {
867       'DEFAULT/use_syslog':           value  => true;
868       'DEFAULT/syslog_log_facility':  value  => $log_facility;
869     }
870   } else {
871     keystone_config {
872       'DEFAULT/use_syslog':           value => false;
873     }
874   }
875
876   if $log_file {
877     keystone_config {
878       'DEFAULT/log_file': value => $log_file;
879       'DEFAULT/log_dir':  value => $log_dir;
880     }
881   } else {
882     if $log_dir {
883       keystone_config {
884         'DEFAULT/log_dir':  value  => $log_dir;
885         'DEFAULT/log_file': ensure => absent;
886       }
887     } else {
888       keystone_config {
889         'DEFAULT/log_dir':  ensure => absent;
890         'DEFAULT/log_file': ensure => absent;
891       }
892     }
893   }
894
895   if $paste_config {
896     keystone_config {
897         'paste_deploy/config_file':   value => $paste_config;
898     }
899   } else {
900     keystone_config {
901         'paste_deploy/config_file':   ensure => absent;
902     }
903   }
904
905   # Fernet tokens support
906   if $enable_fernet_setup {
907     validate_string($fernet_key_repository)
908
909     exec { 'keystone-manage fernet_setup':
910       path        => '/usr/bin',
911       user        => 'keystone',
912       refreshonly => true,
913       creates     => "${fernet_key_repository}/0",
914       notify      => Service[$service_name],
915       subscribe   => [Package['keystone'], Keystone_config['fernet_tokens/key_repository']],
916     }
917   }
918
919   if $fernet_key_repository {
920     keystone_config {
921         'fernet_tokens/key_repository':   value => $fernet_key_repository;
922     }
923   } else {
924     keystone_config {
925         'fernet_tokens/key_repository':   ensure => absent;
926     }
927   }
928
929   if $fernet_max_active_keys {
930     keystone_config {
931         'fernet_tokens/max_active_keys':   value => $fernet_max_active_keys;
932     }
933   } else {
934     keystone_config {
935         'fernet_tokens/max_active_keys':   ensure => absent;
936     }
937   }
938
939   if $default_domain {
940     keystone_domain { $default_domain:
941       ensure     => present,
942       enabled    => true,
943       is_default => true,
944       require    => File['/etc/keystone/keystone.conf'],
945       notify     => Exec['restart_keystone'],
946     }
947     # Update this code when https://bugs.launchpad.net/keystone/+bug/1472285 is addressed.
948     # 1/ Keystone needs to be started before creating the default domain
949     # 2/ Once the default domain is created, we can query Keystone to get the default domain ID
950     # 3/ The Keystone_domain provider has in charge of doing the query and configure keystone.conf
951     # 4/ After such a change, we need to restart Keystone service.
952     # restart_keystone exec is doing 4/, it restart Keystone if we have a new default domain setted
953     # and if we manage the service to be enabled.
954     if $manage_service and $enabled {
955       exec { 'restart_keystone':
956         path        => ['/usr/sbin', '/usr/bin', '/sbin', '/bin/'],
957         command     => "service ${service_name} restart",
958         refreshonly => true,
959       }
960     }
961   }
962 }