Clayton O'Neill dca9fe942b Move deps & external hooks into a standalone class
Previously the anchors and dependencies that allow external hooks were
all in the main ::heat class.  However, if you wanted to include just
::heat::db::mysql, then it would fail, since it assumed the main heat
class was included.  This moves all of those resources and relationships
into a new class, ::heat::deps.  All of the classes will now include
this class so that the anchors and deps are always evaluated even if
only a portion of the classes are used, and even if ::heat isn't pulled
in.

Change-Id: I4297df160a7afae2b66c1ac76e37de313fa4fb09
Closes-Bug: #1507934
2015-10-20 09:57:36 -04:00

118 lines
2.7 KiB
Puppet

# == Class: heat::api
#
# Installs & configure the heat 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'.
#
# [*bind_host*]
# (Optional) Address to bind the server. Useful when
# selecting a particular network interface.
# Defaults to '0.0.0.0'.
#
# [*bind_port*]
# (Optional) The port on which the server will listen.
# Defaults to '8004'.
#
# [*workers*]
# (Optional) The port on which the server will listen.
# Defaults to '0'.
#
# [*use_ssl*]
# (Optional) Whether to use ssl or not.
# Defaults to 'false'.
#
# [*cert_file*]
# (Optional) Location of the SSL certificate file to use for SSL mode.
# Required when $use_ssl is set to 'true'.
# Defaults to 'false'.
#
# [*key_file*]
# (Optional) Location of the SSL key file to use for enabling SSL mode.
# Required when $use_ssl is set to 'true'.
# Defaults to 'false'.
#
# === Deprecated Parameters
#
# No Deprecated Parameters.
#
class heat::api (
$package_ensure = 'present',
$manage_service = true,
$enabled = true,
$bind_host = '0.0.0.0',
$bind_port = '8004',
$workers = '0',
$use_ssl = false,
$cert_file = false,
$key_file = false,
) {
include ::heat
include ::heat::deps
include ::heat::params
include ::heat::policy
if $use_ssl {
if !$cert_file {
fail('The cert_file parameter is required when use_ssl is set to true')
}
if !$key_file {
fail('The key_file parameter is required when use_ssl is set to true')
}
}
package { 'heat-api':
ensure => $package_ensure,
name => $::heat::params::api_package_name,
tag => ['openstack', 'heat-package'],
}
if $manage_service {
if $enabled {
$service_ensure = 'running'
} else {
$service_ensure = 'stopped'
}
}
service { 'heat-api':
ensure => $service_ensure,
name => $::heat::params::api_service_name,
enable => $enabled,
hasstatus => true,
hasrestart => true,
tag => 'heat-service',
}
heat_config {
'heat_api/bind_host' : value => $bind_host;
'heat_api/bind_port' : value => $bind_port;
'heat_api/workers' : value => $workers;
}
# SSL Options
if $use_ssl {
heat_config {
'heat_api/cert_file' : value => $cert_file;
'heat_api/key_file' : value => $key_file;
}
} else {
heat_config {
'heat_api/cert_file' : ensure => absent;
'heat_api/key_file' : ensure => absent;
}
}
}