File: api.pp

package info (click to toggle)
puppet-module-mistral 25.0.0-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 1,004 kB
  • sloc: ruby: 2,093; python: 38; makefile: 11; sh: 10
file content (134 lines) | stat: -rw-r--r-- 4,534 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
# == Class: mistral::api
#
# Installs & configure the Mistral API service
#
# === Parameters
#
# [*allow_action_execution_deletion*]
#   (Optional) Enables the ability to delete action_execution
#   which has no relationship with workflows. (boolean value).
#   Defaults to $facts['os_service_default'].
#
# [*api_workers*]
#   (Optional) Number of workers for Mistral API service
#   default is equal to the number of CPUs available if that can
#   be determined, else a default worker count of 1 is returned.
#   Defaults to $facts['os_workers']
#
# [*bind_host*]
#   (Optional) Address to bind the server. Useful when
#   selecting a particular network interface.
#   Defaults to $facts['os_service_default'].
#
# [*bind_port*]
#   (Optional) The port on which the server will listen.
#   Defaults to $facts['os_service_default'].
#
# [*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 mistral-api.
#   If the value is 'httpd', this means mistral-api will be a web
#   service, and you must use another class to configure that
#   web service. For example, use class { 'mistral::wsgi::apache'...}
#   to make mistral-api be a web app using apache mod_wsgi.
#   Defaults to '$::mistral::params::api_service_name'
#
# [*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'].
#
# [*auth_strategy*]
#   (optional) Type of authentication to be used.
#   Defaults to 'keystone'
#
class mistral::api (
  $allow_action_execution_deletion = $facts['os_service_default'],
  $api_workers                     = $facts['os_workers'],
  $bind_host                       = $facts['os_service_default'],
  $bind_port                       = $facts['os_service_default'],
  Boolean $enabled                 = true,
  Boolean $manage_service          = true,
  $package_ensure                  = present,
  $service_name                    = $::mistral::params::api_service_name,
  $enable_proxy_headers_parsing    = $facts['os_service_default'],
  $max_request_body_size           = $facts['os_service_default'],
  $auth_strategy                   = 'keystone',
) inherits mistral::params {

  include mistral::deps
  include mistral::params
  include mistral::policy

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

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

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

    if $service_name == $::mistral::params::api_service_name {
      service { 'mistral-api':
        ensure     => $service_ensure,
        name       => $::mistral::params::api_service_name,
        enable     => $enabled,
        hasstatus  => true,
        hasrestart => true,
        tag        => 'mistral-service',
      }
    } elsif $service_name == 'httpd' {
      service { 'mistral-api':
        ensure => 'stopped',
        name   => $::mistral::params::api_service_name,
        enable => false,
        tag    => 'mistral-service',
      }
      Service <| title == 'httpd' |> { tag +> 'mistral-service' }

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

  mistral_config {
    'api/api_workers'                      : value => $api_workers;
    'api/host'                             : value => $bind_host;
    'api/port'                             : value => $bind_port;
    'api/allow_action_execution_deletion'  : value => $allow_action_execution_deletion;
  }

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

}