File: api_cfn.pp

package info (click to toggle)
puppet-module-heat 27.0.0-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 1,520 kB
  • sloc: ruby: 3,790; python: 33; sh: 10; makefile: 10
file content (137 lines) | stat: -rw-r--r-- 4,162 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
135
136
137
# == Class: heat::api_cfn
#
# This class deprecates heat::api-cfn.
#
# Installs & configure the heat CloudFormation 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'.
#
# [*service_name*]
#   (optional) Name of the service that will be providing the
#   server functionality of heat-api-cfn.
#   If the value is 'httpd', this means heat-api-cfn will be a web
#   service, and you must use another class to configure that
#   web service. For example, use class { 'heat::wsgi::apache_api_cfn'...}
#   to make heat-api-cfn be a web app using apache mod_wsgi.
#   Defaults to '$heat::params::api_cfn_service_name'
#
# == Deprecated Parameters
#
# [*bind_host*]
#   (Optional) Address to bind the server. Useful when
#   selecting a particular network interface.
#   Defaults to undef.
#
# [*bind_port*]
#   (Optional) The port on which the server will listen.
#   Defaults to undef.
#
# [*workers*]
#   (Optional) The number of workers to spawn.
#   Defaults to undef.
#
# [*use_ssl*]
#   (Optional) Whether to use ssl or not.
#   Defaults to undef.
#
# [*cert_file*]
#   (Optional) Location of the SSL certificate file to use for SSL mode.
#   Defaults to undef
#
# [*key_file*]
#   (Optional) Location of the SSL key file to use for enabling SSL mode.
#   Defaults to undef
#
class heat::api_cfn (
  Stdlib::Ensure::Package $package_ensure = 'present',
  Boolean $manage_service                 = true,
  Boolean $enabled                        = true,
  String[1] $service_name                 = $heat::params::api_cfn_service_name,
  # DEPRECATED PARAMETERS
  $bind_host                              = undef,
  $bind_port                              = undef,
  $workers                                = undef,
  $use_ssl                                = undef,
  $cert_file                              = undef,
  $key_file                               = undef,
) inherits heat::params {
  include heat
  include heat::deps
  include heat::params
  include heat::policy

  [
    'bind_host', 'bind_port', 'workers',
    'use_ssl', 'cert_file', 'key_file',
  ].each |String $opt| {
    if getvar($opt) != undef {
      warning("The ${opt} parameter is deprecated and has no effect.")
    }
  }

  package { 'heat-api-cfn':
    ensure => $package_ensure,
    name   => $heat::params::api_cfn_package_name,
    tag    => ['openstack', 'heat-package'],
  }

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

        service { 'heat-api-cfn':
          ensure => 'stopped',
          name   => $heat::params::api_cfn_service_name,
          enable => false,
          tag    => ['heat-service'],
        }
        # we need to make sure heat-api-cfn/eventlet is stopped before trying to start apache
        Service['heat-api-cfn'] -> Service['httpd']

        # On any paste-api.ini config change, we must restart Heat API.
        Heat_api_paste_ini<||> ~> Service['httpd']
      }
      default: {
        $service_ensure = $enabled ? {
          true    => 'running',
          default => 'stopped',
        }

        service { 'heat-api-cfn':
          ensure     => $service_ensure,
          name       => $service_name,
          enable     => $enabled,
          hasstatus  => true,
          hasrestart => true,
          tag        => 'heat-service',
        }

        # On any paste-api.ini config change, we must restart Heat API.
        Heat_api_paste_ini<||> ~> Service['heat-api-cfn']
        # On any uwsgi config change, we must restart Heat API.
        Heat_api_cfn_uwsgi_config<||> ~> Service['heat-api-cfn']
      }
    }
  }

  heat_config {
    'heat_api_cfn/bind_host': ensure => absent;
    'heat_api_cfn/bind_port': ensure => absent;
    'heat_api_cfn/workers':   ensure => absent;
    'heat_api_cfn/cert_file': ensure => absent;
    'heat_api_cfn/key_file':  ensure => absent;
  }
}