File: api.pp

package info (click to toggle)
puppet-module-panko 13.3.1-1
  • links: PTS, VCS
  • area: main
  • in suites: buster
  • size: 508 kB
  • sloc: ruby: 1,366; python: 40; sh: 15; makefile: 8
file content (177 lines) | stat: -rw-r--r-- 5,625 bytes parent folder | download
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
# Installs & configure the panko api service
#
# == Parameters
#
# [*enabled*]
#   (optional) Should the service be enabled.
#   Defaults to true
#
# [*manage_service*]
#   (optional) Whether the service should be managed by Puppet.
#   Defaults to true.
#
# [*host*]
#   (optional) The panko api bind address.
#   Defaults to 0.0.0.0
#
# [*port*]
#   (optional) The panko api port.
#   Defaults to 8977
#
# [*workers*]
#   (optional) Number of workers for Panko API server.
#   Defaults to $::os_workers
#
# [*max_limit*]
#   (optional) The maximum number of items returned in a
#   single response from a collection resource.
#   Defaults to 1000
#
# [*package_ensure*]
#   (optional) ensure state for package.
#   Defaults to 'present'
#
# [*service_name*]
#   (optional) Name of the service that will be providing the
#   server functionality of panko-api.
#   If the value is 'httpd', this means panko-api will be a web
#   service, and you must use another class to configure that
#   web service. For example, use class { 'panko::wsgi::apache'...}
#   to make panko-api be a web app using apache mod_wsgi.
#   Defaults to '$::panko::params::api_service_name'
#
# [*sync_db*]
#   (optional) Run panko-upgrade db sync on api nodes after installing the package.
#   Defaults to false
#
# [*auth_strategy*]
#   (optional) Configure panko authentication.
#   Can be set to noauth and keystone.
#   Defaults to 'keystone'.
#
# [*enable_proxy_headers_parsing*]
#   (Optional) Enable paste middleware to handle SSL requests through
#   HTTPProxyToWSGI middleware.
#   Defaults to $::os_service_default.
#
# [*max_retries*]
#   (Optional) Maximum number of connection retries during startup.
#   Set to -1 to specify an infinite retry count. (integer value)
#   Defaults to $::os_service_default.
#
# [*retry_interval*]
#   (Optional) Interval between retries of connection.
#   Defaults to $::os_service_default.
#
# [*es_ssl_enabled*]
#   (Optional) Enable HTTPS connection in the Elasticsearch connection.
#   Defaults to $::os_service_default.
#
# [*es_index_name*]
#   (Optional) The name of the index in Elasticsearch (string value).
#   Defaults to $::os_service_default.
#
# [*event_time_to_live*]
#   (Optional) Number of seconds that events are kept in the database for
#   (<= 0 means forever)
#   Defaults to $::os_service_default.
#
class panko::api (
  $manage_service               = true,
  $enabled                      = true,
  $package_ensure               = 'present',
  $host                         = '0.0.0.0',
  $port                         = '8977',
  $workers                      = $::os_workers,
  $max_limit                    = 1000,
  $service_name                 = $::panko::params::api_service_name,
  $sync_db                      = false,
  $auth_strategy                = 'keystone',
  $enable_proxy_headers_parsing = $::os_service_default,
  $max_retries                  = $::os_service_default,
  $retry_interval               = $::os_service_default,
  $es_ssl_enabled               = $::os_service_default,
  $es_index_name                = $::os_service_default,
  $event_time_to_live           = $::os_service_default,
) inherits panko::params {

  warning('This Class is deprecated and will be removed in future releases.')

  include ::panko::deps
  include ::panko::policy

  package { 'panko-api':
    ensure => $package_ensure,
    name   => $::panko::params::api_package_name,
    tag    => ['openstack', 'panko-package'],
  }

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

  if $sync_db {
    include ::panko::db::sync
  }

  if $service_name == $::panko::params::api_service_name {
    service { 'panko-api':
      ensure     => $service_ensure,
      name       => $::panko::params::api_service_name,
      enable     => $enabled,
      hasstatus  => true,
      hasrestart => true,
      tag        => ['panko-service', 'panko-db-sync-service'],
    }
  } elsif $service_name == 'httpd' {
    include ::apache::params
    service { 'panko-api':
      ensure => 'stopped',
      name   => $::panko::params::api_service_name,
      enable => false,
      tag    => ['panko-service', 'panko-db-sync-service'],
    }
    Class['panko::db'] -> Service[$service_name]
    Service <| title == 'httpd' |> {
      tag +> ['panko-service', 'panko-db-sync-service']
    }

    # we need to make sure panko-api/eventlet is stopped before trying to start apache
    Service['panko-api'] -> Service[$service_name]
  } else {
    fail("Invalid service_name. Either panko/openstack-panko-api for \
running as a standalone service, or httpd for being run by a httpd server")
  }

  panko_config {
    'api/host':                    value => $host;
    'api/port':                    value => $port;
    'api/workers':                 value => $workers;
    'api/max_limit':               value => $max_limit;
    'storage/max_retries':         value => $max_retries;
    'storage/retry_interval':      value => $retry_interval;
    'storage/es_ssl_enabled':      value => $es_ssl_enabled;
    'storage/es_index_name':       value => $es_index_name;
    'database/event_time_to_live': value => $event_time_to_live;
  }

  if $auth_strategy == 'keystone' {
    include ::panko::keystone::authtoken
    panko_api_paste_ini {
      'pipeline:main/pipeline':  value => 'panko+auth',
    }
  } else {
    panko_api_paste_ini {
      'pipeline:main/pipeline':  value => 'panko+noauth',
    }
  }

  oslo::middleware { 'panko_config':
    enable_proxy_headers_parsing => $enable_proxy_headers_parsing,
  }

}