-
Notifications
You must be signed in to change notification settings - Fork 50
Expand file tree
/
Copy pathapi.pp
More file actions
229 lines (213 loc) · 7.24 KB
/
api.pp
File metadata and controls
229 lines (213 loc) · 7.24 KB
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
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
# Installs & configure the ceilometer 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.
#
# [*keystone_user*]
# (optional) The name of the auth user
# Defaults to ceilometer
#
# [*keystone_host*]
# (optional) DEPRECATED. Keystone's admin endpoint IP/Host.
# Defaults to '127.0.0.1'
#
# [*keystone_port*]
# (optional) DEPRECATED. Keystone's admin endpoint port.
# Defaults to 35357
#
# [*keystone_auth_admin_prefix*]
# (optional) DEPRECATED. 'path' to the keystone admin endpoint.
# Define to a path starting with a '/' and without trailing '/'.
# Eg.: '/keystone/admin' to match keystone::wsgi::apache default.
# Defaults to false (empty)
#
# [*keystone_protocol*]
# (optional) DEPRECATED. 'http' or 'https'
# Defaults to 'https'.
#
# [*keytone_user*]
# (optional) User to authenticate with.
# Defaults to 'ceilometer'.
#
# [*keystone_tenant*]
# (optional) Tenant to authenticate with.
# Defaults to 'services'.
#
# [*keystone_password*]
# Password to authenticate with.
# Mandatory.
#
# [*keystone_auth_uri*]
# (optional) Public Identity API endpoint.
# Defaults to 'false'.
#
# [*keystone_identity_uri*]
# (optional) Complete admin Identity API endpoint.
# Defaults to: false
#
# [*host*]
# (optional) The ceilometer api bind address.
# Defaults to 0.0.0.0
#
# [*port*]
# (optional) The ceilometer api port.
# Defaults to 8777
#
# [*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 ceilometer-api.
# If the value is 'httpd', this means ceilometer-api will be a web
# service, and you must use another class to configure that
# web service. For example, use class { 'ceilometer::wsgi::apache'...}
# to make keystone be a web app using apache mod_wsgi.
# Defaults to '$::ceilometer::params::api_service_name'
#
class ceilometer::api (
$manage_service = true,
$enabled = true,
$package_ensure = 'present',
$keystone_user = 'ceilometer',
$keystone_tenant = 'services',
$keystone_password = false,
$keystone_auth_uri = false,
$keystone_identity_uri = false,
$host = '0.0.0.0',
$port = '8777',
$service_name = $::ceilometer::params::api_service_name,
# DEPRECATED PARAMETERS
$keystone_host = '127.0.0.1',
$keystone_port = '35357',
$keystone_auth_admin_prefix = false,
$keystone_protocol = 'http',
) inherits ceilometer::params {
include ::ceilometer::params
include ::ceilometer::policy
validate_string($keystone_password)
Ceilometer_config<||> ~> Service[$service_name]
Class['ceilometer::policy'] ~> Service[$service_name]
Package['ceilometer-api'] -> Ceilometer_config<||>
Package['ceilometer-api'] -> Service[$service_name]
Package['ceilometer-api'] -> Class['ceilometer::policy']
package { 'ceilometer-api':
ensure => $package_ensure,
name => $::ceilometer::params::api_package_name,
tag => 'openstack',
}
if $manage_service {
if $enabled {
$service_ensure = 'running'
} else {
$service_ensure = 'stopped'
}
}
Package['ceilometer-common'] -> Service[$service_name]
if $service_name == $::ceilometer::params::api_service_name {
service { 'ceilometer-api':
ensure => $service_ensure,
name => $::ceilometer::params::api_service_name,
enable => $enabled,
hasstatus => true,
hasrestart => true,
require => Class['ceilometer::db'],
subscribe => Exec['ceilometer-dbsync'],
tag => 'ceilometer-service',
}
} elsif $service_name == 'httpd' {
include ::apache::params
service { 'ceilometer-api':
ensure => 'stopped',
name => $::ceilometer::params::api_service_name,
enable => false,
tag => 'ceilometer-service',
}
Class['ceilometer::db'] -> Service[$service_name]
} else {
fail('Invalid service_name. Either keystone/openstack-ceilometer-api for running as a standalone service, or httpd for being run by a httpd server')
}
ceilometer_config {
'keystone_authtoken/admin_tenant_name' : value => $keystone_tenant;
'keystone_authtoken/admin_user' : value => $keystone_user;
'keystone_authtoken/admin_password' : value => $keystone_password, secret => true;
'api/host' : value => $host;
'api/port' : value => $port;
}
# if both auth_uri and identity_uri are set we skip these deprecated settings entirely
if !$keystone_auth_uri or !$keystone_identity_uri {
if $keystone_auth_admin_prefix {
validate_re($keystone_auth_admin_prefix, '^(/.+[^/])?$')
warning('The keystone_auth_admin_prefix parameter is deprecated. Please use keystone_auth_uri and keystone_identity_uri instead.')
ceilometer_config {
'keystone_authtoken/auth_admin_prefix': value => $keystone_auth_admin_prefix;
}
} else {
ceilometer_config {
'keystone_authtoken/auth_admin_prefix': ensure => absent;
}
}
if $keystone_host {
warning('The keystone_host parameter is deprecated. Please use keystone_auth_uri and keystone_identity_uri instead.')
ceilometer_config {
'keystone_authtoken/auth_host': value => $keystone_host;
}
} else {
ceilometer_config {
'keystone_authtoken/auth_host': ensure => absent;
}
}
if $keystone_port {
warning('The keystone_port parameter is deprecated. Please use keystone_auth_uri and keystone_identity_uri instead.')
ceilometer_config {
'keystone_authtoken/auth_port': value => $keystone_port;
}
} else {
ceilometer_config {
'keystone_authtoken/auth_port': ensure => absent;
}
}
if $keystone_protocol {
warning('The keystone_protocol parameter is deprecated. Please use keystone_auth_uri and keystone_identity_uri instead.')
ceilometer_config {
'keystone_authtoken/auth_protocol': value => $keystone_protocol;
}
} else {
ceilometer_config {
'keystone_authtoken/auth_protocol': ensure => absent;
}
}
} else {
ceilometer_config {
'keystone_authtoken/auth_host' : ensure => absent;
'keystone_authtoken/auth_port' : ensure => absent;
'keystone_authtoken/auth_protocol' : ensure => absent;
'keystone_authtoken/auth_admin_prefix' : ensure => absent;
}
}
if $keystone_auth_uri {
$keystone_auth_uri_real = $keystone_auth_uri
} elsif $keystone_host and $keystone_protocol {
$keystone_auth_uri_real = "${keystone_protocol}://${keystone_host}:5000/"
}
ceilometer_config {
'keystone_authtoken/auth_uri': value => $keystone_auth_uri_real;
}
if $keystone_identity_uri {
ceilometer_config {
'keystone_authtoken/identity_uri': value => $keystone_identity_uri;
}
} else {
ceilometer_config {
'keystone_authtoken/identity_uri': ensure => absent;
}
}
}