Puppet Class: aodh::api

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

Overview

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

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

enable_proxy_headers_parsing

(Optional) Enable paste middleware to handle SSL requests through HTTPProxyToWSGI middleware. Defaults to $facts.

max_request_body_size

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

paste_config

(Optional) Configuration file for WSGI definition of API Defaults to $facts.

gnocchi_external_project_owner

(optional) Gnocchi external project owner (usually Ceilometer project name) Defaults to ‘services’

gnocchi_external_domain_name

(optional) Domain name of resources creator in Gnocchi. Defaults to ‘Default’

Parameters:

  • manage_service (Boolean) (defaults to: true)
  • enabled (Boolean) (defaults to: true)
  • package_ensure (Any) (defaults to: 'present')
  • service_name (Any) (defaults to: $::aodh::params::api_service_name)
  • sync_db (Boolean) (defaults to: false)
  • auth_strategy (Any) (defaults to: 'keystone')
  • enable_proxy_headers_parsing (Any) (defaults to: $facts['os_service_default'])
  • max_request_body_size (Any) (defaults to: $facts['os_service_default'])
  • paste_config (Any) (defaults to: $facts['os_service_default'])
  • gnocchi_external_project_owner (Any) (defaults to: 'services')
  • gnocchi_external_domain_name (Any) (defaults to: 'Default')


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

class aodh::api (
  Boolean $manage_service         = true,
  Boolean $enabled                = true,
  $package_ensure                 = 'present',
  $service_name                   = $::aodh::params::api_service_name,
  Boolean $sync_db                = false,
  $auth_strategy                  = 'keystone',
  $enable_proxy_headers_parsing   = $facts['os_service_default'],
  $max_request_body_size          = $facts['os_service_default'],
  $paste_config                   = $facts['os_service_default'],
  $gnocchi_external_project_owner = 'services',
  $gnocchi_external_domain_name   = 'Default',
) inherits aodh::params {

  include aodh::deps
  include aodh::params
  include aodh::policy

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

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

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

  if $manage_service {
    $api_service_name = $::aodh::params::api_service_name
    if $api_service_name != 'httpd' and $service_name == $api_service_name {
      if $enabled {
        $service_ensure = 'running'
      } else {
        $service_ensure = 'stopped'
      }

      service { 'aodh-api':
        ensure     => $service_ensure,
        name       => $api_service_name,
        enable     => $enabled,
        hasstatus  => true,
        hasrestart => true,
        tag        => 'aodh-service',
      }
      # On any paste-api.ini config change, we must restart Aodh API.
      Aodh_api_paste_ini<||> ~> Service['aodh-api']
      # On any uwsgi config change, we must restart Aodh API.
      Aodh_api_uwsgi_config<||> ~> Service['aodh-api']

    } elsif $service_name == 'httpd' {
      Service <| title == 'httpd' |> { tag +> 'aodh-service' }

      if $api_service_name != 'httpd' {
        service { 'aodh-api':
          ensure => 'stopped',
          name   => $api_service_name,
          enable => false,
          tag    => 'aodh-service',
        }
        # we need to make sure aodh-api/eventlet is stopped before trying to start apache
        Service['aodh-api'] -> Service[$service_name]
      }

      # On any paste-api.ini config change, we must restart Aodh API.
      Aodh_api_paste_ini<||> ~> Service[$service_name]
    } else {
      fail('Invalid service_name.')
    }
  }

  aodh_config {
    'api/gnocchi_external_project_owner': value => $gnocchi_external_project_owner;
    'api/gnocchi_external_domain_name':   value => $gnocchi_external_domain_name;
    'api/paste_config':                   value => $paste_config;
  }

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