]> git.donarmstrong.com Git - dsa-puppet.git/blob - 3rdparty/modules/keystone/manifests/init.pp
try with modules from master
[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 # == Dependencies
367 #  None
368 #
369 # == Examples
370 #
371 #   class { 'keystone':
372 #     log_verbose => 'True',
373 #     admin_token => 'my_special_token',
374 #   }
375 #
376 #   OR
377 #
378 #   class { 'keystone':
379 #      ...
380 #      service_name => 'httpd',
381 #      ...
382 #   }
383 #   class { 'keystone::wsgi::apache':
384 #      ...
385 #   }
386 #
387 # == Authors
388 #
389 #   Dan Bode dan@puppetlabs.com
390 #
391 # == Copyright
392 #
393 # Copyright 2012 Puppetlabs Inc, unless otherwise noted.
394 #
395 class keystone(
396   $admin_token,
397   $package_ensure         = 'present',
398   $client_package_ensure  = 'present',
399   $public_bind_host       = '0.0.0.0',
400   $admin_bind_host        = '0.0.0.0',
401   $public_port            = '5000',
402   $admin_port             = '35357',
403   $verbose                = false,
404   $debug                  = false,
405   $log_dir                = '/var/log/keystone',
406   $log_file               = false,
407   $use_syslog             = false,
408   $log_facility           = 'LOG_USER',
409   $catalog_type           = 'sql',
410   $catalog_driver         = false,
411   $catalog_template_file  = '/etc/keystone/default_catalog.templates',
412   $token_provider         = 'keystone.token.providers.uuid.Provider',
413   $token_driver           = 'keystone.token.persistence.backends.sql.Token',
414   $token_expiration       = 3600,
415   $revoke_driver          = 'keystone.contrib.revoke.backends.sql.Revoke',
416   $public_endpoint        = false,
417   $admin_endpoint         = false,
418   $enable_ssl             = false,
419   $ssl_certfile           = '/etc/keystone/ssl/certs/keystone.pem',
420   $ssl_keyfile            = '/etc/keystone/ssl/private/keystonekey.pem',
421   $ssl_ca_certs           = '/etc/keystone/ssl/certs/ca.pem',
422   $ssl_ca_key             = '/etc/keystone/ssl/private/cakey.pem',
423   $ssl_cert_subject       = '/C=US/ST=Unset/L=Unset/O=Unset/CN=localhost',
424   $cache_dir              = '/var/cache/keystone',
425   $memcache_servers       = false,
426   $manage_service         = true,
427   $cache_backend          = 'keystone.common.cache.noop',
428   $cache_backend_argument = undef,
429   $debug_cache_backend    = false,
430   $token_caching          = true,
431   $enabled                = true,
432   $database_connection    = 'sqlite:////var/lib/keystone/keystone.db',
433   $database_idle_timeout  = '200',
434   $enable_pki_setup       = true,
435   $signing_certfile       = '/etc/keystone/ssl/certs/signing_cert.pem',
436   $signing_keyfile        = '/etc/keystone/ssl/private/signing_key.pem',
437   $signing_ca_certs       = '/etc/keystone/ssl/certs/ca.pem',
438   $signing_ca_key         = '/etc/keystone/ssl/private/cakey.pem',
439   $signing_cert_subject   = '/C=US/ST=Unset/L=Unset/O=Unset/CN=www.example.com',
440   $signing_key_size       = 2048,
441   $rabbit_host            = 'localhost',
442   $rabbit_hosts           = false,
443   $rabbit_password        = 'guest',
444   $rabbit_port            = '5672',
445   $rabbit_userid          = 'guest',
446   $rabbit_virtual_host    = '/',
447   $rabbit_use_ssl         = false,
448   $kombu_ssl_ca_certs     = undef,
449   $kombu_ssl_certfile     = undef,
450   $kombu_ssl_keyfile      = undef,
451   $kombu_ssl_version      = 'TLSv1',
452   $notification_driver    = false,
453   $notification_topics    = false,
454   $notification_format    = undef,
455   $control_exchange       = false,
456   $validate_service       = false,
457   $validate_insecure      = false,
458   $validate_auth_url      = false,
459   $validate_cacert        = undef,
460   $paste_config           = $::keystone::params::paste_config,
461   $service_provider       = $::keystone::params::service_provider,
462   $service_name           = $::keystone::params::service_name,
463   $max_token_size         = undef,
464   $admin_workers          = max($::processorcount, 2),
465   $public_workers         = max($::processorcount, 2),
466   $sync_db                = true,
467   $enable_fernet_setup    = false,
468   $fernet_key_repository  = '/etc/keystone/fernet-keys',
469   $fernet_max_active_keys = undef,
470   # DEPRECATED PARAMETERS
471   $mysql_module           = undef,
472   $compute_port           = undef,
473 ) inherits keystone::params {
474
475   if ! $catalog_driver {
476     validate_re($catalog_type, 'template|sql')
477   }
478
479   if $mysql_module {
480     warning('The mysql_module parameter is deprecated. The latest 2.x mysql module will be used.')
481   }
482
483   if ($admin_endpoint and 'v2.0' in $admin_endpoint) {
484     warning('Version string /v2.0/ should not be included in keystone::admin_endpoint')
485   }
486
487   if ($public_endpoint and 'v2.0' in $public_endpoint) {
488     warning('Version string /v2.0/ should not be included in keystone::public_endpoint')
489   }
490
491   if $rabbit_use_ssl {
492     if !$kombu_ssl_ca_certs {
493       fail('The kombu_ssl_ca_certs parameter is required when rabbit_use_ssl is set to true')
494     }
495     if !$kombu_ssl_certfile {
496       fail('The kombu_ssl_certfile parameter is required when rabbit_use_ssl is set to true')
497     }
498     if !$kombu_ssl_keyfile {
499       fail('The kombu_ssl_keyfile parameter is required when rabbit_use_ssl is set to true')
500     }
501   }
502
503   File['/etc/keystone/keystone.conf'] -> Keystone_config<||> ~> Service[$service_name]
504   Keystone_config<||> ~> Exec<| title == 'keystone-manage db_sync'|>
505   Keystone_config<||> ~> Exec<| title == 'keystone-manage pki_setup'|>
506   Keystone_config<||> ~> Exec<| title == 'keystone-manage fernet_setup'|>
507
508   include ::keystone::params
509
510   package { 'keystone':
511     ensure => $package_ensure,
512     name   => $::keystone::params::package_name,
513     tag    => 'openstack',
514   }
515   if $client_package_ensure == 'present' {
516     include '::openstacklib::openstackclient'
517   } else {
518     class { '::openstacklib::openstackclient':
519       package_ensure => $client_package_ensure,
520     }
521   }
522
523   group { 'keystone':
524     ensure  => present,
525     system  => true,
526     require => Package['keystone'],
527   }
528
529   user { 'keystone':
530     ensure  => 'present',
531     gid     => 'keystone',
532     system  => true,
533     require => Package['keystone'],
534   }
535
536   file { ['/etc/keystone', '/var/log/keystone', '/var/lib/keystone']:
537     ensure  => directory,
538     mode    => '0750',
539     owner   => 'keystone',
540     group   => 'keystone',
541     require => Package['keystone'],
542     notify  => Service[$service_name],
543   }
544
545   file { '/etc/keystone/keystone.conf':
546     ensure  => present,
547     mode    => '0600',
548     owner   => 'keystone',
549     group   => 'keystone',
550     require => Package['keystone'],
551     notify  => Service[$service_name],
552   }
553
554   keystone_config {
555     'DEFAULT/admin_token':      value => $admin_token, secret => true;
556     'DEFAULT/public_bind_host': value => $public_bind_host;
557     'DEFAULT/admin_bind_host':  value => $admin_bind_host;
558     'DEFAULT/public_port':      value => $public_port;
559     'DEFAULT/admin_port':       value => $admin_port;
560     'DEFAULT/verbose':          value => $verbose;
561     'DEFAULT/debug':            value => $debug;
562   }
563
564   if $compute_port {
565     warning('The compute_port parameter is deprecated and will be removed in L')
566     keystone_config {
567       'DEFAULT/compute_port': value => $compute_port;
568     }
569   } else {
570     keystone_config {
571       'DEFAULT/compute_port': ensure => absent;
572     }
573   }
574
575   # Endpoint configuration
576   if $public_endpoint {
577     keystone_config {
578       'DEFAULT/public_endpoint': value => $public_endpoint;
579     }
580   } else {
581     keystone_config {
582       'DEFAULT/public_endpoint': ensure => absent;
583     }
584   }
585   if $admin_endpoint {
586     keystone_config {
587       'DEFAULT/admin_endpoint': value => $admin_endpoint;
588     }
589   } else {
590     keystone_config {
591       'DEFAULT/admin_endpoint': ensure => absent;
592     }
593   }
594   # requirements for memcache token driver
595   if ($token_driver =~ /memcache/ ) {
596     package { 'python-memcache':
597       ensure => present,
598       name   => $::keystone::params::python_memcache_package_name,
599     }
600   }
601
602   # token driver config
603   keystone_config {
604     'token/driver':     value => $token_driver;
605     'token/expiration': value => $token_expiration;
606   }
607
608   if $revoke_driver {
609     keystone_config {
610       'revoke/driver':    value => $revoke_driver;
611     }
612   } else {
613     keystone_config {
614       'revoke/driver':    ensure => absent;
615     }
616   }
617
618   # ssl config
619   if ($enable_ssl) {
620     keystone_config {
621       'ssl/enable':              value  => true;
622       'ssl/certfile':            value  => $ssl_certfile;
623       'ssl/keyfile':             value  => $ssl_keyfile;
624       'ssl/ca_certs':            value  => $ssl_ca_certs;
625       'ssl/ca_key':              value  => $ssl_ca_key;
626       'ssl/cert_subject':        value  => $ssl_cert_subject;
627     }
628   } else {
629     keystone_config {
630       'ssl/enable':              value  => false;
631     }
632   }
633
634   if($database_connection =~ /mysql:\/\/\S+:\S+@\S+\/\S+/) {
635     require 'mysql::bindings'
636     require 'mysql::bindings::python'
637   } elsif($database_connection =~ /postgresql:\/\/\S+:\S+@\S+\/\S+/) {
638
639   } elsif($database_connection =~ /sqlite:\/\//) {
640
641   } else {
642     fail("Invalid db connection ${database_connection}")
643   }
644
645   # memcache connection config
646   if $memcache_servers {
647     validate_array($memcache_servers)
648     Service<| title == 'memcached' |> -> Service['keystone']
649     keystone_config {
650       'cache/enabled':              value => true;
651       'cache/backend':              value => $cache_backend;
652       'cache/debug_cache_backend':  value => $debug_cache_backend;
653       'token/caching':              value => $token_caching;
654       'memcache/servers':           value => join($memcache_servers, ',');
655     }
656     if $cache_backend_argument {
657       validate_array($cache_backend_argument)
658       keystone_config {
659         'cache/backend_argument':   value => join($cache_backend_argument, ',');
660       }
661     } else {
662       keystone_config {
663         'cache/backend_argument':  ensure => absent;
664       }
665     }
666   } else {
667     keystone_config {
668       'cache/enabled':             ensure => absent;
669       'cache/backend':             ensure => absent;
670       'cache/backend_argument':    ensure => absent;
671       'cache/debug_cache_backend': ensure => absent;
672       'token/caching':             ensure => absent;
673       'memcache/servers':          ensure => absent;
674     }
675   }
676
677   # db connection config
678   keystone_config {
679     'database/connection':   value => $database_connection, secret => true;
680     'database/idle_timeout': value => $database_idle_timeout;
681   }
682
683   # configure based on the catalog backend
684   if $catalog_driver {
685     $catalog_driver_real = $catalog_driver
686   }
687   elsif ($catalog_type == 'template') {
688     $catalog_driver_real = 'keystone.catalog.backends.templated.Catalog'
689   }
690   elsif ($catalog_type == 'sql') {
691     $catalog_driver_real = 'keystone.catalog.backends.sql.Catalog'
692   }
693
694   keystone_config {
695     'catalog/driver':        value => $catalog_driver_real;
696     'catalog/template_file': value => $catalog_template_file;
697   }
698
699   # Set the signing key/cert configuration values.
700   keystone_config {
701     'signing/certfile':     value => $signing_certfile;
702     'signing/keyfile':      value => $signing_keyfile;
703     'signing/ca_certs':     value => $signing_ca_certs;
704     'signing/ca_key':       value => $signing_ca_key;
705     'signing/cert_subject': value => $signing_cert_subject;
706     'signing/key_size':     value => $signing_key_size;
707   }
708
709   # Create cache directory used for signing.
710   file { $cache_dir:
711     ensure => directory,
712   }
713
714   # Only do pki_setup if we were asked to do so.  This is needed
715   # regardless of the token provider since token revocation lists
716   # are always signed.
717   if $enable_pki_setup {
718     exec { 'keystone-manage pki_setup':
719       path        => '/usr/bin',
720       user        => 'keystone',
721       refreshonly => true,
722       creates     => $signing_keyfile,
723       notify      => Service[$service_name],
724       subscribe   => Package['keystone'],
725       require     => User['keystone'],
726     }
727   }
728
729   keystone_config { 'token/provider': value => $token_provider }
730
731   if $max_token_size {
732     keystone_config { 'DEFAULT/max_token_size': value => $max_token_size }
733   } else {
734     keystone_config { 'DEFAULT/max_token_size': ensure => absent }
735   }
736
737   if $notification_driver {
738     keystone_config { 'DEFAULT/notification_driver': value => $notification_driver }
739   } else {
740     keystone_config { 'DEFAULT/notification_driver': ensure => absent }
741   }
742   if $notification_topics {
743     keystone_config { 'DEFAULT/notification_topics': value => $notification_topics }
744   } else {
745     keystone_config { 'DEFAULT/notification_topics': ensure => absent }
746   }
747   if $notification_format {
748     keystone_config { 'DEFAULT/notification_format': value => $notification_format }
749   } else {
750     keystone_config { 'DEFAULT/notification_format': ensure => absent }
751   }
752   if $control_exchange {
753     keystone_config { 'DEFAULT/control_exchange': value => $control_exchange }
754   } else {
755     keystone_config { 'DEFAULT/control_exchange': ensure => absent }
756   }
757
758   keystone_config {
759     'DEFAULT/rabbit_password':     value => $rabbit_password, secret => true;
760     'DEFAULT/rabbit_userid':       value => $rabbit_userid;
761     'DEFAULT/rabbit_virtual_host': value => $rabbit_virtual_host;
762   }
763
764   if $rabbit_hosts {
765     keystone_config { 'DEFAULT/rabbit_hosts':     value => join($rabbit_hosts, ',') }
766     keystone_config { 'DEFAULT/rabbit_ha_queues': value => true }
767   } else {
768     keystone_config { 'DEFAULT/rabbit_host':      value => $rabbit_host }
769     keystone_config { 'DEFAULT/rabbit_port':      value => $rabbit_port }
770     keystone_config { 'DEFAULT/rabbit_hosts':     value => "${rabbit_host}:${rabbit_port}" }
771     keystone_config { 'DEFAULT/rabbit_ha_queues': value => false }
772   }
773
774   keystone_config { 'DEFAULT/rabbit_use_ssl': value => $rabbit_use_ssl }
775   if $rabbit_use_ssl {
776     keystone_config {
777       'DEFAULT/kombu_ssl_ca_certs': value => $kombu_ssl_ca_certs;
778       'DEFAULT/kombu_ssl_certfile': value => $kombu_ssl_certfile;
779       'DEFAULT/kombu_ssl_keyfile':  value => $kombu_ssl_keyfile;
780       'DEFAULT/kombu_ssl_version':  value => $kombu_ssl_version;
781     }
782   } else {
783     keystone_config {
784       'DEFAULT/kombu_ssl_ca_certs': ensure => absent;
785       'DEFAULT/kombu_ssl_certfile': ensure => absent;
786       'DEFAULT/kombu_ssl_keyfile':  ensure => absent;
787       'DEFAULT/kombu_ssl_version':  ensure => absent;
788     }
789   }
790
791   keystone_config {
792     'DEFAULT/admin_workers':  value => $admin_workers;
793     'DEFAULT/public_workers': value => $public_workers;
794   }
795
796   if $manage_service {
797     if $enabled {
798       $service_ensure = 'running'
799     } else {
800       $service_ensure = 'stopped'
801     }
802   } else {
803     warning('Execution of db_sync does not depend on $enabled anymore. Please use sync_db instead.')
804   }
805
806   if $service_name == $::keystone::params::service_name {
807     if $validate_service {
808       if $validate_auth_url {
809         $v_auth_url = $validate_auth_url
810       } else {
811         $v_auth_url = $admin_endpoint
812       }
813
814       class { '::keystone::service':
815         ensure         => $service_ensure,
816         service_name   => $service_name,
817         enable         => $enabled,
818         hasstatus      => true,
819         hasrestart     => true,
820         provider       => $service_provider,
821         validate       => true,
822         admin_endpoint => $v_auth_url,
823         admin_token    => $admin_token,
824         insecure       => $validate_insecure,
825         cacert         => $validate_cacert,
826       }
827     } else {
828       class { '::keystone::service':
829         ensure       => $service_ensure,
830         service_name => $service_name,
831         enable       => $enabled,
832         hasstatus    => true,
833         hasrestart   => true,
834         provider     => $service_provider,
835         validate     => false,
836       }
837     }
838   } elsif $service_name == 'httpd' {
839     class { '::keystone::service':
840       ensure       => 'stopped',
841       service_name => $::keystone::params::service_name,
842       enable       => false,
843       provider     => $service_provider,
844       validate     => false,
845     }
846   } else {
847     fail('Invalid service_name. Either keystone/openstack-keystone for running as a standalone service, or httpd for being run by a httpd server')
848   }
849
850   if $sync_db {
851     include ::keystone::db::sync
852     Class['::keystone::db::sync'] ~> Service[$service_name]
853   }
854
855   # Syslog configuration
856   if $use_syslog {
857     keystone_config {
858       'DEFAULT/use_syslog':           value  => true;
859       'DEFAULT/syslog_log_facility':  value  => $log_facility;
860     }
861   } else {
862     keystone_config {
863       'DEFAULT/use_syslog':           value => false;
864     }
865   }
866
867   if $log_file {
868     keystone_config {
869       'DEFAULT/log_file': value => $log_file;
870       'DEFAULT/log_dir':  value => $log_dir;
871     }
872   } else {
873     if $log_dir {
874       keystone_config {
875         'DEFAULT/log_dir':  value  => $log_dir;
876         'DEFAULT/log_file': ensure => absent;
877       }
878     } else {
879       keystone_config {
880         'DEFAULT/log_dir':  ensure => absent;
881         'DEFAULT/log_file': ensure => absent;
882       }
883     }
884   }
885
886   if $paste_config {
887     keystone_config {
888         'paste_deploy/config_file':   value => $paste_config;
889     }
890   } else {
891     keystone_config {
892         'paste_deploy/config_file':   ensure => absent;
893     }
894   }
895
896   # Fernet tokens support
897   if $enable_fernet_setup {
898     validate_string($fernet_key_repository)
899
900     exec { 'keystone-manage fernet_setup':
901       path        => '/usr/bin',
902       user        => 'keystone',
903       refreshonly => true,
904       creates     => "${fernet_key_repository}/0",
905       notify      => Service[$service_name],
906       subscribe   => [Package['keystone'], Keystone_config['fernet_tokens/key_repository']],
907     }
908   }
909
910   if $fernet_key_repository {
911     keystone_config {
912         'fernet_tokens/key_repository':   value => $fernet_key_repository;
913     }
914   } else {
915     keystone_config {
916         'fernet_tokens/key_repository':   ensure => absent;
917     }
918   }
919
920   if $fernet_max_active_keys {
921     keystone_config {
922         'fernet_tokens/max_active_keys':   value => $fernet_max_active_keys;
923     }
924   } else {
925     keystone_config {
926         'fernet_tokens/max_active_keys':   ensure => absent;
927     }
928   }
929
930 }