File: api.pp

package info (click to toggle)
puppet-module-placement 14.0.0-1
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 680 kB
  • sloc: ruby: 1,542; python: 33; makefile: 10; sh: 10
file content (105 lines) | stat: -rw-r--r-- 3,223 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
# Installs & configure the placement API service
#
# == Parameters
#
# [*enabled*]
#   (optional) Should the service be enabled.
#   Defaults to true
#
# [*manage_service*]
#   (optional) If Puppet should manage service startup / shutdown.
#   Defaults to true.
#
# [*api_service_name*]
#   (Optional) Name of the service that will be providing the
#   server functionality of placement-api.
#   If the value is 'httpd', this means placement-api will be a web
#   service, and you must use another class to configure that
#   web service. For example, use class { 'placement::wsgi::apache'...}
#   to make placement-api be a web app using apache mod_wsgi.
#   Defaults to $placement::params::service_name
#
# [*ensure_package*]
#   (optional) ensure state for package.
#   Defaults to 'present'
#
# [*sync_db*]
#   (optional) Run placement-manage db sync 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'].
#
# DEPRECATED PARAMETERS
#
# [*package_ensure*]
#   (optional) ensure state for package.
#   Defaults to undef
#
class placement::api (
  Boolean $enabled                        = true,
  Boolean $manage_service                 = true,
  String[1] $api_service_name             = $placement::params::service_name,
  Stdlib::Ensure::Package $ensure_package = 'present',
  Boolean $sync_db                        = false,
  $enable_proxy_headers_parsing           = $facts['os_service_default'],
  # DEPRECATED PARAMETERS
  Optional[Stdlib::Ensure::Package] $package_ensure = undef,
) inherits placement::params {
  include placement::deps
  include placement::policy

  if $package_ensure {
    warning('The package_ensure parameter is deprecated. Use the ensure_package parameter instead.')
  }
  $ensure_package_real = $package_ensure ? {
    undef   => $ensure_package,
    default => $package_ensure,
  }

  if $manage_service {
    case $api_service_name {
      'httpd': {
        Service <| title == 'httpd' |> { tag +> 'placement-service' }

        if $placement::params::service_name {
          service { 'placement-api':
            ensure => 'stopped',
            name   => $placement::params::service_name,
            enable => false,
            tag    => ['placement-service'],
          }
          Service['placement-api'] -> Service['httpd']
        }

        $api_service_name_real = undef
      }
      default: {
        $api_service_name_real = $api_service_name

        # On any uwsgi config change, we must restart Placement API.
        Placement_api_uwsgi_config<||> ~> Service['placement-api']
      }
    }
  } else {
    $api_service_name_real = undef
  }

  placement::generic_service { 'api':
    service_name   => $api_service_name_real,
    package_name   => $placement::params::package_name,
    manage_service => $manage_service,
    enabled        => $enabled,
    ensure_package => $ensure_package_real,
  }

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

  oslo::middleware { 'placement_config':
    enable_proxy_headers_parsing => $enable_proxy_headers_parsing,
  }
}