Give possibility to pass IPs to Haproxy stats
* Give possibility to pass multiple IPs to Haproxy listen for internal communications * Add new function array_to_hash, that converts array to hash with custom value Change-Id: I47e9eace77cb2a8d061a225f0b45dc0059b5ae76 Closes-Bug: 1481342
This commit is contained in:
parent
8fee8a37f7
commit
0625329aac
@ -5,7 +5,7 @@
|
|||||||
# === Parameters
|
# === Parameters
|
||||||
#
|
#
|
||||||
# [*internal_virtual_ip*]
|
# [*internal_virtual_ip*]
|
||||||
# (required) String. This is the ipaddress to be used for the internal facing
|
# (required) Array or Single value. This is the ipaddress to be used for the internal facing
|
||||||
# vip
|
# vip
|
||||||
#
|
#
|
||||||
# [*ipaddresses*]
|
# [*ipaddresses*]
|
||||||
@ -17,7 +17,7 @@
|
|||||||
# vip
|
# vip
|
||||||
#
|
#
|
||||||
# [*public_virtual_ip*]
|
# [*public_virtual_ip*]
|
||||||
# (required) String. This is the ipaddress to be used for the external facing
|
# (optional) String. This is the ipaddress to be used for the external facing
|
||||||
# vip
|
# vip
|
||||||
#
|
#
|
||||||
# [*server_names*]
|
# [*server_names*]
|
||||||
@ -72,7 +72,7 @@ define openstack::ha::haproxy_service (
|
|||||||
$internal_virtual_ip,
|
$internal_virtual_ip,
|
||||||
$listen_port,
|
$listen_port,
|
||||||
$order,
|
$order,
|
||||||
$public_virtual_ip,
|
$public_virtual_ip = undef,
|
||||||
$balancermember_options = 'check',
|
$balancermember_options = 'check',
|
||||||
$balancermember_port = $listen_port,
|
$balancermember_port = $listen_port,
|
||||||
$before_start = false,
|
$before_start = false,
|
||||||
@ -96,41 +96,30 @@ define openstack::ha::haproxy_service (
|
|||||||
|
|
||||||
if $public and $internal {
|
if $public and $internal {
|
||||||
if $public_ssl {
|
if $public_ssl {
|
||||||
$bind = { "$public_virtual_ip:$listen_port" => ['ssl', 'crt', '/var/lib/astute/haproxy/public_haproxy.pem'],
|
$bind = merge({ "$public_virtual_ip:$listen_port" => ['ssl', 'crt', '/var/lib/astute/haproxy/public_haproxy.pem'] },
|
||||||
"$internal_virtual_ip:$listen_port" => "" }
|
array_to_hash(suffix(flatten([$internal_virtual_ip]), ":${listen_port}"), ""))
|
||||||
} else {
|
} else {
|
||||||
$virtual_ips = [$public_virtual_ip, $internal_virtual_ip]
|
$bind = array_to_hash(suffix(flatten([$internal_virtual_ip, $public_virtual_ip]), ":${listen_port}"), "")
|
||||||
}
|
}
|
||||||
} elsif $internal {
|
} elsif $internal {
|
||||||
$virtual_ips = [$internal_virtual_ip]
|
$bind = array_to_hash(suffix(flatten([$internal_virtual_ip]), ":${listen_port}"), "")
|
||||||
} elsif $public {
|
} elsif $public {
|
||||||
if $public_ssl {
|
if $public_ssl {
|
||||||
$bind = { "$public_virtual_ip:$listen_port" => ['ssl', 'crt', '/var/lib/astute/haproxy/public_haproxy.pem'] }
|
$bind = { "$public_virtual_ip:$listen_port" => ['ssl', 'crt', '/var/lib/astute/haproxy/public_haproxy.pem'] }
|
||||||
} else {
|
} else {
|
||||||
$virtual_ips = [$public_virtual_ip]
|
$bind = array_to_hash(suffix(flatten([$public_virtual_ip]), ":${listen_port}"), "")
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
fail('At least one of $public or $internal must be set to true')
|
fail('At least one of $public or $internal must be set to true')
|
||||||
}
|
}
|
||||||
|
|
||||||
# Configure HAProxy to listen
|
# Configure HAProxy to listen
|
||||||
if $public_ssl {
|
haproxy::listen { $name:
|
||||||
haproxy::listen { $name:
|
order => $order,
|
||||||
order => $order,
|
bind => $bind,
|
||||||
bind => $bind,
|
options => $haproxy_config_options,
|
||||||
options => $haproxy_config_options,
|
mode => $mode,
|
||||||
mode => $mode,
|
use_include => true,
|
||||||
use_include => true,
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
haproxy::listen { $name:
|
|
||||||
order => $order,
|
|
||||||
ipaddress => $virtual_ips,
|
|
||||||
ports => $listen_port,
|
|
||||||
options => $haproxy_config_options,
|
|
||||||
mode => $mode,
|
|
||||||
use_include => true,
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if $ipaddresses and $server_names {
|
if $ipaddresses and $server_names {
|
||||||
|
@ -0,0 +1,10 @@
|
|||||||
|
Puppet::Parser::Functions::newfunction(:array_to_hash, :type => :rvalue, :doc => <<-EOS
|
||||||
|
converts array to hash with custom value
|
||||||
|
EOS
|
||||||
|
) do |argv|
|
||||||
|
arr = argv[0]
|
||||||
|
value = argv[1]
|
||||||
|
|
||||||
|
return Hash[arr.collect { |v| [v, value] }]
|
||||||
|
end
|
||||||
|
|
@ -1,6 +1,6 @@
|
|||||||
notice('MODULAR: openstack-haproxy-stats.pp')
|
notice('MODULAR: openstack-haproxy-stats.pp')
|
||||||
|
|
||||||
$internal_virtual_ip = hiera('management_vip')
|
$internal_virtual_ip = unique([hiera('management_vip'), hiera('database_vip'), hiera('service_endpoint')])
|
||||||
|
|
||||||
class { '::openstack::ha::stats':
|
class { '::openstack::ha::stats':
|
||||||
internal_virtual_ip => $internal_virtual_ip,
|
internal_virtual_ip => $internal_virtual_ip,
|
||||||
|
Loading…
Reference in New Issue
Block a user