summaryrefslogtreecommitdiffstats
path: root/components/congress/install/puppet/manifests/init.pp
blob: a1367c3f3597dc8907dd83c80045ad634cbe0b8b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
# == Class: congress
#
# Module for managing congress config
#
# === Parameters
#
# [*keystone_password*]
#   (required) Password used to authentication.
#
# [*package_ensure*]
#   (optional) Desired ensure state of packages.
#   accepts latest or specific versions.
#   Defaults to present.
#
# [*client_package_ensure*]
#   (optional) Desired ensure state of the client package.
#   accepts latest or specific versions.
#   Defaults to present.
#
# [*bind_host*]
#   (optional) The IP address that congress binds to.
#   Default to '0.0.0.0'.
#
# [*bind_port*]
#   (optional) Port that congress binds to.
#   Defaults to '1789'
#
# [*verbose*]
#   (optional) Rather congress should log at verbose level.
#   Defaults to undef.
#
# [*debug*]
#   (optional) Rather congress should log at debug level.
#   Defaults to undef.
#
# [*auth_type*]
#   (optional) Type is authorization being used.
#   Defaults to 'keystone'
#
# [*auth_uri*]
#   (optional) Complete public Identity API endpoint.
#   Defaults to false.
#
# [*identity_uri*]
#   (optional) Complete admin Identity API endpoint.
#   Defaults to: false
#
# [*keystone_tenant*]
#   (optional) Tenant to authenticate to.
#   Defaults to services.
#
# [*keystone_user*]
#   (optional) User to authenticate as with keystone.
#   Defaults to 'congress'.
#
# [*manage_service*]
#   (Optional) If Puppet should manage service startup / shutdown.
#   Defaults to true.
#
# [*enabled*]
#  (optional) If the congress services should be enabled.
#   Default to true.
#
# [*database_connection*]
#   (optional) Url used to connect to database.
#   Defaults to undef.
#
# [*database_idle_timeout*]
#   (optional) Timeout when db connections should be reaped.
#   Defaults to undef.
#
# [*database_max_retries*]
#   (optional) Maximum number of database connection retries during startup.
#   Setting -1 implies an infinite retry count.
#   (Defaults to undef)
#
# [*database_retry_interval*]
#   (optional) Interval between retries of opening a database connection.
#   (Defaults to undef)
#
# [*database_min_pool_size*]
#   (optional) Minimum number of SQL connections to keep open in a pool.
#   Defaults to: undef
#
# [*database_max_pool_size*]
#   (optional) Maximum number of SQL connections to keep open in a pool.
#   Defaults to: undef
#
# [*database_max_overflow*]
#   (optional) If set, use this value for max_overflow with sqlalchemy.
#   Defaults to: undef
#
# [*rpc_backend*]
#   (Optional) Use these options to configure the RabbitMQ message system.
#   Defaults to 'rabbit'
#
# [*control_exchange*]
#   (Optional)
#   Defaults to 'openstack'.
#
# [*rabbit_host*]
#   (Optional) IP or hostname of the rabbit server.
#   Defaults to '127.0.0.1'
#
# [*rabbit_port*]
#   (Optional) Port of the rabbit server.
#   Defaults to 5672.
#
# [*rabbit_hosts*]
#   (Optional) Array of host:port (used with HA queues).
#   If defined, will remove rabbit_host & rabbit_port parameters from config
#   Defaults to undef.
#
# [*rabbit_userid*]
#   (Optional) User to connect to the rabbit server.
#   Defaults to 'guest'
#
# [*rabbit_password*]
#   (Required) Password to connect to the rabbit_server.
#   Defaults to empty. Required if using the Rabbit (kombu)
#   backend.
#
# [*rabbit_virtual_host*]
#   (Optional) Virtual_host to use.
#   Defaults to '/'
#
# [*rabbit_heartbeat_timeout_threshold*]
#   (optional) Number of seconds after which the RabbitMQ broker is considered
#   down if the heartbeat keepalive fails.  Any value >0 enables heartbeats.
#   Heartbeating helps to ensure the TCP connection to RabbitMQ isn't silently
#   closed, resulting in missed or lost messages from the queue.
#   (Requires kombu >= 3.0.7 and amqp >= 1.4.0)
#   Defaults to 0
#
# [*rabbit_heartbeat_rate*]
#   (optional) How often during the rabbit_heartbeat_timeout_threshold period to
#   check the heartbeat on RabbitMQ connection.  (i.e. rabbit_heartbeat_rate=2
#   when rabbit_heartbeat_timeout_threshold=60, the heartbeat will be checked
#   every 30 seconds.
#   Defaults to 2
#
# [*rabbit_use_ssl*]
#   (optional) Connect over SSL for RabbitMQ
#   Defaults to false
#
# [*kombu_ssl_ca_certs*]
#   (optional) SSL certification authority file (valid only if SSL enabled).
#   Defaults to $::os_service_default
#
# [*kombu_ssl_certfile*]
#   (optional) SSL cert file (valid only if SSL enabled).
#   Defaults to $::os_service_default
#
# [*kombu_ssl_keyfile*]
#   (optional) SSL key file (valid only if SSL enabled).
#   Defaults to $::os_service_default
#
# [*kombu_ssl_version*]
#   (optional) SSL version to use (valid only if SSL enabled).
#   Valid values are TLSv1, SSLv23 and SSLv3. SSLv2 may be
#   available on some distributions.
#   Defaults to $::os_service_default
#
# [*kombu_reconnect_delay*]
#   (optional) How long to wait before reconnecting in response to an AMQP
#   consumer cancel notification.
#   Defaults to $::os_service_default
#
# [*amqp_durable_queues*]
#   Use durable queues in amqp.
#   (Optional) Defaults to false.
#
# [*service_provider*]
#   (optional) Provider, that can be used for congress service.
#   Default value defined in congress::params for given operation system.
#   If you use Pacemaker or another Cluster Resource Manager, you can make
#   custom service provider for changing start/stop/status behavior of service,
#   and set it here.
#
# [*service_name*]
#   (optional) Name of the service that will be providing the
#   server functionality of congress.
#   Defaults to '$::congress::params::service_name'
#
# [*sync_db*]
#   (Optional) Run db sync on the node.
#   Defaults to true
#
# == Dependencies
#  None
#
# == Examples
#
#   class { 'congress':
#     keystone_password   => 'congress',
#     keystone_tenant     => 'service',
#     auth_uri            => 'http://192.168.122.6:5000/',
#     identity_uri        => 'http://192.168.122.6:35357/',
#     database_connection => 'mysql://congress:password@192.168.122.6/congress',
#     rabbit_host         => '192.168.122.6',
#     rabbit_password     => 'guest',
#   }
#   
#   class { 'congress::db::mysql':
#       password => 'password',
#       host => '192.168.122.6',
#   } 
#   
#   class { 'congress::keystone::auth':
#     password            => 'congress',
#     tenant              => 'service',
#     admin_url           => 'http://192.168.122.6:1789',
#     internal_url        => 'http://192.168.122.6:1789',
#     public_url          => 'http://192.168.122.6:1789',
#     region              => 'regionOne',
#   }
#
# == Authors
#
#   Dan Radez <dradez@redhat.com>
#
# == Copyright
#
# Copyright 2015 Red Hat Inc, unless otherwise noted.
#

class congress(
  $keystone_password,
  $package_ensure                     = 'present',
  $client_package_ensure              = 'present',
  $bind_host                          = '0.0.0.0',
  $bind_port                          = '1789',
  $verbose                            = undef,
  $debug                              = undef,
  $auth_type                          = 'keystone',
  $auth_uri                           = false,
  $identity_uri                       = false,
  $keystone_tenant                    = 'services',
  $keystone_user                      = 'congress',
  $manage_service                     = true,
  $enabled                            = true,
  $database_connection                = undef,
  $database_idle_timeout              = undef,
  $database_max_retries               = undef,
  $database_retry_interval            = undef,
  $database_min_pool_size             = undef,
  $database_max_pool_size             = undef,
  $database_max_overflow              = undef,
  $rpc_backend                        = 'rabbit',
  $control_exchange                   = 'congress',
  $rabbit_host                        = '127.0.0.1',
  $rabbit_port                        = 5672,
  $rabbit_hosts                       = false,
  $rabbit_virtual_host                = '/',
  $rabbit_heartbeat_timeout_threshold = 0,
  $rabbit_heartbeat_rate              = 2,
  $rabbit_userid                      = 'guest',
  $rabbit_password                    = false,
  $rabbit_use_ssl                     = false,
  $kombu_ssl_ca_certs                 = $::os_service_default,
  $kombu_ssl_certfile                 = $::os_service_default,
  $kombu_ssl_keyfile                  = $::os_service_default,
  $kombu_ssl_version                  = $::os_service_default,
  $kombu_reconnect_delay              = $::os_service_default,
  $amqp_durable_queues                = false,
  $service_provider                   = $::congress::params::service_provider,
  $service_name                       = $::congress::params::service_name,
) inherits congress::params {
  congress_config {
    'DEFAULT/drivers'         : value => 'congress.datasources.neutronv2_driver.NeutronV2Driver,congress.datasources.glancev2_driver.GlanceV2Driver,congress.datasources.nova_driver.NovaDriver,congress.datasources. keystone_driver.KeystoneDriver,congress.datasources.ceilometer_driver.CeilometerDriver,congress.datasources.cinder_driver.CinderDriver';
  }

  if $identity_uri {
    congress_config { 'keystone_authtoken/identity_uri': value => $identity_uri; }
    congress_config { 'keystone_authtoken/auth_url'    : value => $identity_uri; }
  } else {
    congress_config { 'keystone_authtoken/identity_uri': ensure => absent; }
  }

  if $auth_uri {
    congress_config { 'keystone_authtoken/auth_uri': value => $auth_uri; }
  } else {
    congress_config { 'keystone_authtoken/auth_uri': ensure => absent; }
  }

  if $auth_type == 'keystone' {
    congress_config {
      'keystone_authtoken/project_name' : value => $keystone_tenant;
      'keystone_authtoken/username'     : value => $keystone_user;
      'keystone_authtoken/password'     : value => $keystone_password, secret => true;
    }
  }

  congress_config<||> ~> Service[$service_name]
  congress_config<||> ~> Exec<| title == 'congress-manage db_sync'|>

  include ::congress::db
  include ::congress::params

  if $sync_db {
    include ::congress::db::sync
    Class['::congress::db::sync'] ~> Service[$service_name]
  }
  if $rpc_backend == 'rabbit' {

    if ! $rabbit_password {
      fail('Please specify a rabbit_password parameter.')
    }

    congress_config {
      'DEFAULT/rabbit_password':              value => $rabbit_password, secret => true;
      'DEFAULT/rabbit_userid':                value => $rabbit_userid;
      'DEFAULT/rabbit_virtual_host':          value => $rabbit_virtual_host;
      'DEFAULT/control_exchange':             value => $control_exchange;
      #'DEFAULT/rabbit_use_ssl':               value => $rabbit_use_ssl;
      #'DEFAULT/kombu_reconnect_delay':        value => $kombu_reconnect_delay;
      #'DEFAULT/heartbeat_timeout_threshold':  value => $rabbit_heartbeat_timeout_threshold;
      #'DEFAULT/heartbeat_rate':               value => $rabbit_heartbeat_rate;
      #'DEFAULT/amqp_durable_queues':          value => $amqp_durable_queues;
    }

    if $rabbit_use_ssl {
      congress_config {
        'DEFAULT/kombu_ssl_version'  : value => $kombu_ssl_version;
        'DEFAULT/kombu_ssl_ca_certs' : value => $kombu_ssl_ca_certs;
        'DEFAULT/kombu_ssl_certfile' : value => $kombu_ssl_certfile;
        'DEFAULT/kombu_ssl_keyfile'  : value => $kombu_ssl_keyfile;
      }
    }

    if $rabbit_hosts {
      congress_config { 'DEFAULT/rabbit_hosts':     value => join($rabbit_hosts, ',') }
      congress_config { 'DEFAULT/rabbit_ha_queues': value => true }
      congress_config { 'DEFAULT/rabbit_host':      ensure => absent }
      congress_config { 'DEFAULT/rabbit_port':      ensure => absent }
    } else {
      congress_config { 'DEFAULT/rabbit_host':      value => $rabbit_host }
      congress_config { 'DEFAULT/rabbit_port':      value => $rabbit_port }
      congress_config { 'DEFAULT/rabbit_hosts':     value => "${rabbit_host}:${rabbit_port}" }
      congress_config { 'DEFAULT/rabbit_ha_queues': value => false }
    }

  }

  package { 'congress':
    ensure => $package_ensure,
    name   => $::congress::params::package_name,
    tag    => ['openstack', 'congress-package'],
  }
  if $client_package_ensure == 'present' {
    include '::congress::client'
  } else {
    class { '::congress::client':
      ensure => $client_package_ensure,
    }
  }

  group { 'congress':
    ensure  => present,
    system  => true,
    require => Package['congress'],
  }

  user { 'congress':
    ensure  => 'present',
    gid     => 'congress',
    system  => true,
    require => Package['congress'],
  }

  file { ['/etc/congress', '/var/log/congress', '/var/lib/congress']:
    ensure  => directory,
    mode    => '0750',
    owner   => 'congress',
    group   => 'congress',
    require => Package['congress'],
    notify  => Service[$service_name],
  }

  file { '/etc/congress/congress.conf':
    ensure  => present,
    mode    => '0600',
    owner   => 'congress',
    group   => 'congress',
    require => Package['congress'],
    notify  => Service[$service_name],
  }

  congress_config {
    'DEFAULT/bind_host': value => $bind_host;
    'DEFAULT/bind_port': value => $bind_port;
  }

  if $manage_service {
    if $enabled {
      $service_ensure = 'running'
    } else {
      $service_ensure = 'stopped'
    }
  }

  class { '::congress::service':
    ensure       => $service_ensure,
    service_name => $service_name,
    enable       => $enabled,
    hasstatus    => true,
    hasrestart   => true,
    provider     => $service_provider,
  }
}