Puppet Class: gnocchi::api

Inherits:
gnocchi::params
Defined in:
manifests/api.pp

Overview

Installs & configure the gnocchi 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.

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 gnocchi-api. If the value is ‘httpd’, this means gnocchi-api will be a web service, and you must use another class to configure that web service. For example, use class { ‘gnocchi::wsgi::apache’…} to make gnocchi-api be a web app using apache mod_wsgi. Defaults to ‘$::gnocchi::params::api_service_name’

sync_db

(optional) Run gnocchi-upgrade db sync on api nodes after installing the package. Defaults to false

auth_strategy

(optional) Configure gnocchi 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_request_body_size

(Optional) Set max request body size Defaults to $::os_service_default.

middlewares

(optional) Middlewares to use. Defaults to $::os_service_default

Parameters:

  • manage_service (Any) (defaults to: true)
  • enabled (Any) (defaults to: true)
  • package_ensure (Any) (defaults to: 'present')
  • max_limit (Any) (defaults to: 1000)
  • service_name (Any) (defaults to: $::gnocchi::params::api_service_name)
  • sync_db (Any) (defaults to: false)
  • auth_strategy (Any) (defaults to: 'keystone')
  • enable_proxy_headers_parsing (Any) (defaults to: $::os_service_default)
  • max_request_body_size (Any) (defaults to: $::os_service_default)
  • middlewares (Any) (defaults to: $::os_service_default)


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
# File 'manifests/api.pp', line 53

class gnocchi::api (
  $manage_service               = true,
  $enabled                      = true,
  $package_ensure               = 'present',
  $max_limit                    = 1000,
  $service_name                 = $::gnocchi::params::api_service_name,
  $sync_db                      = false,
  $auth_strategy                = 'keystone',
  $enable_proxy_headers_parsing = $::os_service_default,
  $max_request_body_size        = $::os_service_default,
  $middlewares                  = $::os_service_default,
) inherits gnocchi::params {

  include gnocchi::deps
  include gnocchi::policy

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

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

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

  if $service_name == $::gnocchi::params::api_service_name {
    service { 'gnocchi-api':
      ensure     => $service_ensure,
      name       => $::gnocchi::params::api_service_name,
      enable     => $enabled,
      hasstatus  => true,
      hasrestart => true,
      tag        => ['gnocchi-service', 'gnocchi-db-sync-service'],
    }
  } elsif $service_name == 'httpd' {
    include apache::params

    service { 'gnocchi-api':
      ensure => 'stopped',
      name   => $::gnocchi::params::api_service_name,
      enable => false,
      tag    => ['gnocchi-service', 'gnocchi-db-sync-service'],
    }
    Service <| title == 'httpd' |> { tag +> 'gnocchi-service' }

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

  gnocchi_config {
    'api/max_limit': value   => $max_limit;
    'api/auth_mode': value   => $auth_strategy;
    'api/middlewares': value => $middlewares;
  }

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

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