Add resource to create haproxy endpoints dynamically

With this resource we can add the values needed for haproxy via t-h-t,
instead of having everything in the haproxy manifest. Right now nothing
is using it, but subsequent and per-service changes will come.

Change-Id: I8ab49c0b8d8f42ce68c0c7fe3ef8067a7d0da3c0
This commit is contained in:
Juan Antonio Osorio Robles 2017-06-14 10:21:48 +03:00 committed by Cédric Jeanneret
parent a84bd09666
commit 7ff44712c1
3 changed files with 49 additions and 0 deletions

View File

@ -851,6 +851,9 @@ class tripleo::haproxy (
manage_firewall => $manage_firewall,
}
$service_names = hiera('enabled_services', [])
tripleo::haproxy::service_endpoints { $service_names: }
if $haproxy_stats {
if $haproxy_stats_certificate {
$haproxy_stats_certificate_real = $haproxy_stats_certificate

View File

@ -0,0 +1,38 @@
# Copyright 2017 Red Hat, Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
#
# == Define: tripleo::haproxy::service_endpoints
#
# Define used to create haproxyendpoints for composable services.
#
# === Parameters:
#
# [*service_name*]
# (optional) The service_name to create the service endpoint(s) for.
# Defaults to $title
#
define tripleo::haproxy::service_endpoints ($service_name = $title) {
$underscore_name = regsubst($service_name, '-', '_')
# This allows each composable service to load its own custom rules by
# creating its own flat hiera key named:
# tripleo.<service name with underscores>.haproxy_endpoints
$service_endpoints = hiera("tripleo.${underscore_name}.haproxy_endpoints", {})
if !empty($service_endpoints) {
create_resources('tripleo::haproxy::endpoint', $service_endpoints)
}
}

View File

@ -0,0 +1,8 @@
---
features:
- |
This change allows to dynamically create new service endpoints, either using hiera
in heat, or with some new service profile you can then include in the roles_data.yml
fixes:
- |
Allow to add custom backends in HAProxy (1721832)