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
|
# == Class: cloudkitty::api
#
# Installs & configure the cloudkitty API service
#
# === Parameters
# [*package_ensure*]
# (Optional) Ensure state for package.
# Defaults to 'present'.
#
# [*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_ip*]
# (Optional) Host serving the API.
# Defaults to $facts['os_service_default'].
#
# [*port*]
# (Optional) Host port serving the API.
# Defaults to $facts['os_service_default'].
#
# [*pecan_debug*]
# (Optional) Toggle Pecan Debug Middleware.
# Defaults to $facts['os_service_default'].
#
# [*sync_db*]
# (optional) Run cloudkitty-dbsync command on api nodes after installing the package.
# Defaults to true.
#
# [*service_name*]
# (optional) Name of the service that will be providing the
# server functionality of cloudkitty-api.
# If the value is 'httpd', this means cloudkitty-api will be a web
# service, and you must use another class to configure that
# web service. For example, use class { 'cloudkitty::wsgi::apache'...}
# to make cloudkitty-api be a web app using apache mod_wsgi.
# Defaults to 'httpd'
#
# [*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'].
#
class cloudkitty::api (
Stdlib::Ensure::Package $package_ensure = 'present',
Boolean $manage_service = true,
Boolean $enabled = true,
$host_ip = $facts['os_service_default'],
$port = $facts['os_service_default'],
$pecan_debug = $facts['os_service_default'],
Boolean $sync_db = true,
String[1] $service_name = $::cloudkitty::params::api_service_name,
$enable_proxy_headers_parsing = $facts['os_service_default'],
$max_request_body_size = $facts['os_service_default'],
) {
include cloudkitty
include cloudkitty::deps
include cloudkitty::params
include cloudkitty::policy
package { 'cloudkitty-api':
ensure => $package_ensure,
name => $cloudkitty::params::api_package_name,
tag => ['openstack', 'cloudkitty-package'],
}
if $sync_db {
include cloudkitty::db::sync
}
if $manage_service {
case $service_name {
'httpd': {
Service <| title == 'httpd' |> { tag +> 'cloudkitty-service' }
service { 'cloudkitty-api':
ensure => 'stopped',
name => $cloudkitty::params::api_service_name,
enable => false,
tag => 'cloudkitty-service',
}
# we need to make sure cloudkitty-api/eventlet is stopped before trying to start apache
Service['cloudkitty-api'] -> Service['httpd']
Cloudkitty_api_paste_ini<||> ~> Service['httpd']
}
default: {
$service_ensure = $enabled ? {
true => 'running',
default => 'stopped',
}
service { 'cloudkitty-api':
ensure => $service_ensure,
name => $service_name,
enable => $enabled,
hasstatus => true,
hasrestart => true,
tag => 'cloudkitty-service',
}
Cloudkitty_api_paste_ini<||> ~> Service['cloudkitty-api']
}
}
}
cloudkitty_config {
'api/host_ip': value => $host_ip;
'api/port': value => $port;
'api/pecan_debug': value => $pecan_debug;
}
oslo::middleware { 'cloudkitty_config':
enable_proxy_headers_parsing => $enable_proxy_headers_parsing,
max_request_body_size => $max_request_body_size,
}
}
|