3 # Configure API service in glance
7 # [*keystone_password*]
8 # (required) Password used to authentication.
11 # (optional) Rather to log the glance api service at verbose level.
15 # (optional) Rather to log the glance api service at debug level.
19 # (optional) The address of the host to bind to.
23 # (optional) The port the server should bind to.
27 # (optional) Backlog requests when creating socket
31 # (optional) Number of Glance API worker processes to start
32 # Default: $::processorcount
35 # (optional) The path of file used for logging
36 # If set to boolean false, it will not log to any file.
37 # Default: /var/log/glance/api.log
40 # (optional) directory to which glance logs are sent.
41 # If set to boolean false, it will not log to any directory.
42 # Defaults to '/var/log/glance'
45 # (optional) The address used to connect to the registry service.
49 # (optional) The port of the Glance registry service.
52 # [*registry_client_protocol*]
53 # (optional) The protocol of the Glance registry service.
57 # (optional) Type is authorization being used.
58 # Defaults to 'keystone'
61 # (optional) Host running auth service.
62 # Defaults to '127.0.0.1'.
65 # (optional) Authentication URL.
66 # Defaults to 'http://localhost:5000/v2.0'.
69 # (optional) Port to use for auth service on auth_host.
70 # Defaults to '35357'.
73 # (optional) Complete public Identity API endpoint.
76 # [*auth_admin_prefix*]
77 # (optional) Path part of the auth url.
78 # This allow admin auth URIs like http://auth_host:35357/keystone/admin.
79 # (where '/keystone/admin' is auth_admin_prefix)
80 # Defaults to false for empty. If defined, should be a string with a leading '/' and no trailing '/'.
83 # (optional) Protocol to use for auth.
87 # (optional) Partial name of a pipeline in your paste configuration file with the
88 # service name removed.
89 # Defaults to 'keystone+cachemanagement'.
92 # (optional) Tenant to authenticate to.
93 # Defaults to services.
96 # (optional) User to authenticate as with keystone.
97 # Defaults to 'glance'.
100 # (optional) If Puppet should manage service startup / shutdown.
104 # (optional) Whether to enable services.
107 # [*sql_idle_timeout*]
108 # (optional) Deprecated. Use database_idle_timeout instead
112 # (optional) Deprecated. Use database_connection instead.
115 # [*database_connection*]
116 # (optional) Connection url to connect to nova database.
117 # Defaults to 'sqlite:///var/lib/glance/glance.sqlite'
119 # [*database_idle_timeout*]
120 # (optional) Timeout before idle db connections are reaped.
124 # (optional) Use syslog for logging.
128 # (optional) Syslog facility to receive log lines.
129 # Defaults to 'LOG_USER'.
131 # [*show_image_direct_url*]
132 # (optional) Expose image location to trusted clients.
136 # (optional) Whether to set only the specified config options
141 # (optinal) Certificate file to use when starting API server securely
142 # Defaults to false, not set
145 # (optional) Private key file to use when starting API server securely
146 # Defaults to false, not set
149 # (optional) CA certificate file to use to verify connecting clients
150 # Defaults to false, not set
153 # (optional) Deprecated. Does nothing.
156 # (optional)List of which store classes and store class locations are
157 # currently known to glance at startup.
159 # Example: ['glance.store.filesystem.Store','glance.store.http.Store']
161 # [*image_cache_dir*]
162 # (optional) Base directory that the Image Cache uses.
163 # Defaults to '/var/lib/glance/image-cache'.
166 # (optional) Sets the keystone region to use.
167 # Defaults to 'RegionOne'.
170 # (optional) Whether to validate the service is working after any service refreshes
173 # [*validation_options*]
174 # (optional) Service validation options
175 # Should be a hash of options defined in openstacklib::service_validation
176 # If empty, defaults values are taken from openstacklib function.
177 # Default command list images.
178 # Require validate set at True.
180 # glance::api::validation_options:
182 # command: check_glance-api.py
183 # path: /usr/bin:/bin:/usr/sbin:/sbin
193 $bind_host = '0.0.0.0',
196 $workers = $::processorcount,
197 $log_file = '/var/log/glance/api.log',
198 $log_dir = '/var/log/glance',
199 $registry_host = '0.0.0.0',
200 $registry_port = '9191',
201 $registry_client_protocol = 'http',
202 $auth_type = 'keystone',
203 $auth_host = '127.0.0.1',
204 $auth_url = 'http://localhost:5000/v2.0',
205 $auth_port = '35357',
207 $auth_admin_prefix = false,
208 $auth_protocol = 'http',
209 $pipeline = 'keystone+cachemanagement',
210 $keystone_tenant = 'services',
211 $keystone_user = 'glance',
212 $manage_service = true,
215 $log_facility = 'LOG_USER',
216 $show_image_direct_url = false,
217 $purge_config = false,
221 $known_stores = false,
222 $database_connection = 'sqlite:///var/lib/glance/glance.sqlite',
223 $database_idle_timeout = 3600,
224 $image_cache_dir = '/var/lib/glance/image-cache',
225 $os_region_name = 'RegionOne',
227 $validation_options = {},
228 # DEPRECATED PARAMETERS
229 $mysql_module = undef,
230 $sql_idle_timeout = false,
231 $sql_connection = false,
234 include glance::policy
235 require keystone::python
238 warning('The mysql_module parameter is deprecated. The latest 2.x mysql module will be used.')
241 if ( $glance::params::api_package_name != $glance::params::registry_package_name ) {
242 ensure_packages([$glance::params::api_package_name],
244 tag => ['openstack'],
249 Package[$glance::params::api_package_name] -> File['/etc/glance/']
250 Package[$glance::params::api_package_name] -> Class['glance::policy']
251 Package[$glance::params::api_package_name] -> Glance_api_config<||>
252 Package[$glance::params::api_package_name] -> Glance_cache_config<||>
254 # adding all of this stuff b/c it devstack says glance-api uses the
256 Glance_api_config<||> ~> Exec<| title == 'glance-manage db_sync' |>
257 Glance_cache_config<||> ~> Exec<| title == 'glance-manage db_sync' |>
258 Exec<| title == 'glance-manage db_sync' |> ~> Service['glance-api']
259 Glance_api_config<||> ~> Service['glance-api']
260 Glance_cache_config<||> ~> Service['glance-api']
261 Class['glance::policy'] ~> Service['glance-api']
262 Service['glance-api'] ~> Glance_image<||>
269 notify => Service['glance-api'],
270 require => Class['glance']
274 warning('The sql_connection parameter is deprecated, use database_connection instead.')
275 $database_connection_real = $sql_connection
277 $database_connection_real = $database_connection
280 if $sql_idle_timeout {
281 warning('The sql_idle_timeout parameter is deprecated, use database_idle_timeout instead.')
282 $database_idle_timeout_real = $sql_idle_timeout
284 $database_idle_timeout_real = $database_idle_timeout
287 if $database_connection_real {
288 if($database_connection_real =~ /mysql:\/\/\S+:\S+@\S+\/\S+/) {
289 require 'mysql::bindings'
290 require 'mysql::bindings::python'
291 } elsif($database_connection_real =~ /postgresql:\/\/\S+:\S+@\S+\/\S+/) {
293 } elsif($database_connection_real =~ /sqlite:\/\//) {
296 fail("Invalid db connection ${database_connection_real}")
299 'database/connection': value => $database_connection_real, secret => true;
300 'database/idle_timeout': value => $database_idle_timeout_real;
304 # basic service config
306 'DEFAULT/verbose': value => $verbose;
307 'DEFAULT/debug': value => $debug;
308 'DEFAULT/bind_host': value => $bind_host;
309 'DEFAULT/bind_port': value => $bind_port;
310 'DEFAULT/backlog': value => $backlog;
311 'DEFAULT/workers': value => $workers;
312 'DEFAULT/show_image_direct_url': value => $show_image_direct_url;
313 'DEFAULT/image_cache_dir': value => $image_cache_dir;
314 'DEFAULT/os_region_name': value => $os_region_name;
317 # known_stores config
320 'glance_store/stores': value => join($known_stores, ',');
324 'glance_store/stores': ensure => absent;
328 glance_cache_config {
329 'DEFAULT/verbose': value => $verbose;
330 'DEFAULT/debug': value => $debug;
331 'DEFAULT/os_region_name': value => $os_region_name;
334 # configure api service to connect registry service
336 'DEFAULT/registry_host': value => $registry_host;
337 'DEFAULT/registry_port': value => $registry_port;
338 'DEFAULT/registry_client_protocol': value => $registry_client_protocol;
341 glance_cache_config {
342 'DEFAULT/registry_host': value => $registry_host;
343 'DEFAULT/registry_port': value => $registry_port;
347 glance_api_config { 'keystone_authtoken/auth_uri': value => $auth_uri; }
349 glance_api_config { 'keystone_authtoken/auth_uri': value => "${auth_protocol}://${auth_host}:5000/"; }
354 'keystone_authtoken/auth_host': value => $auth_host;
355 'keystone_authtoken/auth_port': value => $auth_port;
356 'keystone_authtoken/auth_protocol': value => $auth_protocol;
359 if $auth_admin_prefix {
360 validate_re($auth_admin_prefix, '^(/.+[^/])?$')
362 'keystone_authtoken/auth_admin_prefix': value => $auth_admin_prefix;
366 'keystone_authtoken/auth_admin_prefix': ensure => absent;
370 # Set the pipeline, it is allowed to be blank
372 validate_re($pipeline, '^(\w+([+]\w+)*)*$')
374 'paste_deploy/flavor':
379 glance_api_config { 'paste_deploy/flavor': ensure => absent }
383 if $auth_type == 'keystone' {
385 'keystone_authtoken/admin_tenant_name': value => $keystone_tenant;
386 'keystone_authtoken/admin_user' : value => $keystone_user;
387 'keystone_authtoken/admin_password' : value => $keystone_password, secret => true;
389 glance_cache_config {
390 'DEFAULT/auth_url' : value => $auth_url;
391 'DEFAULT/admin_tenant_name': value => $keystone_tenant;
392 'DEFAULT/admin_user' : value => $keystone_user;
393 'DEFAULT/admin_password' : value => $keystone_password, secret => true;
400 'DEFAULT/cert_file' : value => $cert_file;
404 'DEFAULT/cert_file': ensure => absent;
409 'DEFAULT/key_file' : value => $key_file;
413 'DEFAULT/key_file': ensure => absent;
418 'DEFAULT/ca_file' : value => $ca_file;
422 'DEFAULT/ca_file': ensure => absent;
429 'DEFAULT/log_file': value => $log_file;
433 'DEFAULT/log_file': ensure => absent;
439 'DEFAULT/log_dir': value => $log_dir;
443 'DEFAULT/log_dir': ensure => absent;
450 'DEFAULT/use_syslog' : value => true;
451 'DEFAULT/syslog_log_facility' : value => $log_facility;
455 'DEFAULT/use_syslog': value => false;
459 resources { 'glance_api_config':
460 purge => $purge_config,
463 file { ['/etc/glance/glance-api.conf',
464 '/etc/glance/glance-api-paste.ini',
465 '/etc/glance/glance-cache.conf']:
470 $service_ensure = 'running'
472 $service_ensure = 'stopped'
476 service { 'glance-api':
477 ensure => $service_ensure,
478 name => $::glance::params::api_service_name,
487 'command' => "glance --os-auth-url ${auth_url} --os-tenant-name ${keystone_tenant} --os-username ${keystone_user} --os-password ${keystone_password} image-list",
490 $validation_options_hash = merge ($defaults, $validation_options)
491 create_resources('openstacklib::service_validation', $validation_options_hash, {'subscribe' => 'Service[glance-api]'})