File: api.pp

package info (click to toggle)
puppet-module-octavia 25.0.0-4
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 1,588 kB
  • sloc: ruby: 3,940; python: 38; makefile: 12; sh: 10
file content (238 lines) | stat: -rw-r--r-- 9,303 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
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
# Installs & configure the octavia 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.
#
# [*service_name*]
#   (Optional) Name of the service that will be providing the
#   server functionality of octavia-api.
#   If the value is 'httpd', this means octavia-api will be a web
#   service, and you must use another class to configure that
#   web service. For example, use class { 'octavia::wsgi::apache'...}
#   to make octavia-api be a web app using apache mod_wsgi.
#   Defaults to $::octavia::params::api_service_name
#
# [*host*]
#   (optional) The octavia api bind address.
#   Defaults to '0.0.0.0'
#
# [*port*]
#   (optional) The octavia api port.
#   Defaults to '9876'
#
# [*package_ensure*]
#   (optional) ensure state for package.
#   Defaults to 'present'
#
# [*auth_strategy*]
#   (optional) set authentication mechanism
#   Defaults to 'keystone'
#
# [*api_handler*]
#   (optional) The handler that the API communicates with
#   Defaults to $facts['os_service_default']
#
# [*api_v1_enabled*]
#   (optional) Boolean if V1 API should be enabled.
#   Defaults to $facts['os_service_default']
#
# [*api_v2_enabled*]
#   (optional) Boolean if V2 API should be enabled.
#   Defaults to $facts['os_service_default']
#
# [*allow_tls_terminated_listeners*]
#   (optional) Boolean if we allow creation of TLS terminated listeners.
#   Defaults to $facts['os_service_default']
#
# [*sync_db*]
#   (optional) Run octavia-db-manage upgrade head on api nodes after installing the package.
#   Defaults to false
#
# [*enable_proxy_headers_parsing*]
#   (Optional) Enable paste middleware to handle SSL requests through
#   HTTPProxyToWSGI middleware.
#   Defaults to $facts['os_service_default'].
#
# [*max_request_body_size*]
#   (Optional) Set max request body size
#   Defaults to $facts['os_service_default'].
#
# [*default_provider_driver*]
#   (optional) Configure the default provider driver.
#   Defaults to $facts['os_service_default']
#
# [*enabled_provider_drivers*]
#   (optional) Configure the loadbalancer provider drivers.
#   Defaults to $facts['os_service_default']
#
# [*pagination_max_limit*]
#   (optional) The maximum number of items returned in a single response.
#   Defaults to $facts['os_service_default']
#
# [*healthcheck_enabled*]
#   (optional) Enable the oslo middleware healthcheck endpoint.
#   Defaults to $facts['os_service_default']
#
# [*healthcheck_refresh_interval*]
#   (optional) The interval healthcheck plugin should cache results, in seconds.
#   Defaults to $facts['os_service_default']
#
# [*default_listener_ciphers*]
#   (optional) Default OpenSSL cipher string (colon-separated) for new
#   TLS-enabled pools.
#   Defaults to $facts['os_service_default']
#
# [*default_pool_ciphers*]
#   (optional) Default OpenSSL cipher string (colon-separated) for new
#   TLS-enabled pools.
#   Defaults to $facts['os_service_default']
#
# [*tls_cipher_prohibit_list*]
#   (optional) Colon separated list of OpenSSL ciphers. Usage of these ciphers
#   will be blocked.
#   Defaults to $facts['os_service_default']
#
# [*default_listener_tls_versions*]
#   (optional) List of TLS versions to use for new TLS-enabled listeners.
#   Defaults to $facts['os_service_default']
#
# [*default_pool_tls_versions*]
#   (optional) List of TLS versions to use for new TLS-enabled pools.
#   Defaults to $facts['os_service_default']
#
# [*minimum_tls_version*]
#   (optional) Minimum allowed TLS version for listeners and pools.
#   Defaults to $facts['os_service_default']
#
# [*allow_ping_health_monitors*]
#   (optional) Allow PING type Health Monitors.
#   Defaults to $facts['os_service_default']
#
# [*allow_prometheus_listeners*]
#   (optional) Allow PROMETHEUS type listeners.
#   Defaults to $facts['os_service_default']
#
class octavia::api (
  Boolean $enabled                = true,
  Boolean $manage_service         = true,
  $service_name                   = $::octavia::params::api_service_name,
  $host                           = '0.0.0.0',
  $port                           = '9876',
  $package_ensure                 = 'present',
  $auth_strategy                  = 'keystone',
  $api_handler                    = $facts['os_service_default'],
  $api_v1_enabled                 = $facts['os_service_default'],
  $api_v2_enabled                 = $facts['os_service_default'],
  $allow_tls_terminated_listeners = $facts['os_service_default'],
  Boolean $sync_db                = false,
  $enable_proxy_headers_parsing   = $facts['os_service_default'],
  $max_request_body_size          = $facts['os_service_default'],
  $default_provider_driver        = $facts['os_service_default'],
  $enabled_provider_drivers       = $facts['os_service_default'],
  $pagination_max_limit           = $facts['os_service_default'],
  $healthcheck_enabled            = $facts['os_service_default'],
  $healthcheck_refresh_interval   = $facts['os_service_default'],
  $default_listener_ciphers       = $facts['os_service_default'],
  $default_pool_ciphers           = $facts['os_service_default'],
  $tls_cipher_prohibit_list       = $facts['os_service_default'],
  $default_listener_tls_versions  = $facts['os_service_default'],
  $default_pool_tls_versions      = $facts['os_service_default'],
  $minimum_tls_version            = $facts['os_service_default'],
  $allow_ping_health_monitors     = $facts['os_service_default'],
  $allow_prometheus_listeners     = $facts['os_service_default'],
) inherits octavia::params {

  include octavia::deps
  include octavia::policy
  include octavia::db

  if $auth_strategy == 'keystone' {
    include octavia::keystone::authtoken
  }

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

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

    if $service_name == $::octavia::params::api_service_name {
      service { 'octavia-api':
        ensure     => $service_ensure,
        name       => $::octavia::params::api_service_name,
        enable     => $enabled,
        hasstatus  => true,
        hasrestart => true,
        tag        => 'octavia-service',
      }

      # On any uwsgi config change, we must restart Octavia API.
      Octavia_api_uwsgi_config<||> ~> Service['octavia-api']

    } elsif $service_name == 'httpd' {
      service { 'octavia-api':
        ensure => 'stopped',
        name   => $::octavia::params::api_service_name,
        enable => false,
        tag    => 'octavia-service',
      }
      Service['octavia-api'] -> Service[$service_name]
      Service<| title == 'httpd' |> { tag +> 'octavia-service' }
    } else {
    fail("Invalid service_name. Either octavia-api/openstack-octavia-api for \
running as a standalone service, or httpd for being run by a httpd server")
    }
  }

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

  if $enabled_provider_drivers =~ Hash {
    $enabled_provider_drivers_real = join(join_keys_to_values($enabled_provider_drivers, ':'), ',')
  } else {
    $enabled_provider_drivers_real = join(any2array($enabled_provider_drivers), ',')
  }

  octavia_config {
    'api_settings/bind_host':                      value => $host;
    'api_settings/bind_port':                      value => $port;
    'api_settings/auth_strategy':                  value => $auth_strategy;
    'api_settings/api_handler':                    value => $api_handler;
    'api_settings/api_v1_enabled':                 value => $api_v1_enabled;
    'api_settings/api_v2_enabled':                 value => $api_v2_enabled;
    'api_settings/allow_tls_terminated_listeners': value => $allow_tls_terminated_listeners;
    'api_settings/default_provider_driver':        value => $default_provider_driver;
    'api_settings/enabled_provider_drivers':       value => $enabled_provider_drivers_real;
    'api_settings/pagination_max_limit':           value => $pagination_max_limit;
    'api_settings/healthcheck_enabled':            value => $healthcheck_enabled;
    'api_settings/healthcheck_refresh_interval':   value => $healthcheck_refresh_interval;
    'api_settings/default_listener_ciphers':       value => join(any2array($default_listener_ciphers), ':');
    'api_settings/default_pool_ciphers':           value => join(any2array($default_pool_ciphers), ':');
    'api_settings/tls_cipher_prohibit_list':       value => join(any2array($tls_cipher_prohibit_list), ':');
    'api_settings/default_listener_tls_versions':  value => join(any2array($default_listener_tls_versions), ',');
    'api_settings/default_pool_tls_versions':      value => join(any2array($default_pool_tls_versions), ',');
    'api_settings/minimum_tls_version':            value => $minimum_tls_version;
    'api_settings/allow_ping_health_monitors':     value => $allow_ping_health_monitors;
    'api_settings/allow_prometheus_listeners':     value => $allow_prometheus_listeners;
  }

  oslo::middleware { 'octavia_config':
    enable_proxy_headers_parsing => $enable_proxy_headers_parsing,
    max_request_body_size        => $max_request_body_size,
  }
}