messaging: support HAproxy binding

As an option and disabled by default for backward compatibility, allow
to export a puppet resource to create HAproxy binding for RabbitMQ
service.
Also add an option to specify the RabbitMQ service TCP port.
This commit is contained in:
Emilien Macchi 2014-10-03 14:57:00 -04:00
parent 233119ebb2
commit f02268b75c
3 changed files with 37 additions and 5 deletions

View File

@ -28,14 +28,30 @@
# Defaults to 'rabbitpassword'
#
# [*cluster_node_type*]
# (optionnal) Store the queues on the disc or in the RAM.
# (optional) Store the queues on the disc or in the RAM.
# Could be set to 'disk' or 'ram'.
# Defaults to 'disc'
#
# [*haproxy_binding*]
# (optional) Enable or not HAproxy binding for load-balancing.
# Defaults to false
#
# [*rabbitmq_ip*]
# (optional) IP address of RabbitMQ interface.
# Required when using HAproxy binding.
# Defaults to $::ipaddress
#
# [*rabbitmq_port*]
# (optional) Port of RabbitMQ service.
# Defaults to '5672'
#
class cloud::messaging(
$cluster_node_type = 'disc',
$rabbit_names = $::hostname,
$rabbit_password = 'rabbitpassword'
$rabbit_password = 'rabbitpassword',
$haproxy_binding = false,
$rabbitmq_ip = $::ipaddress,
$rabbitmq_port = '5672',
){
# we ensure having an array
@ -63,7 +79,8 @@ class cloud::messaging(
config_cluster => true,
cluster_nodes => $array_rabbit_names,
wipe_db_on_cookie_change => true,
cluster_node_type => $cluster_node_type
cluster_node_type => $cluster_node_type,
port => $rabbitmq_port,
}
rabbitmq_vhost { '/':
@ -91,4 +108,14 @@ class cloud::messaging(
provider => 'rabbitmqctl',
}
if $haproxy_binding {
@@haproxy::balancermember{"${::fqdn}-rabbitmq":
listening_service => 'rabbitmq_cluster',
server_names => $::hostname,
ipaddresses => $rabbitmq_ip,
ports => $rabbitmq_port,
options => 'check inter 5s rise 2 fall 3'
}
}
}

View File

@ -36,7 +36,8 @@ describe 'cloud::messaging' do
:config_cluster => true,
:cluster_nodes => params[:rabbit_names],
:wipe_db_on_cookie_change => true,
:cluster_node_type => 'disc'
:cluster_node_type => 'disc',
:port => '5672',
)
end

View File

@ -38,6 +38,10 @@ monitor fail if metadata_api_dead
acl spice_dead nbsrv(spice_cluster) lt 1
monitor fail if spice_dead
<%- end -%>
<%- if @rabbitmq -%>
acl rabbitmq_dead nbsrv(rabbitmq_cluster) lt 1
monitor fail if rabbitmq_dead
<%- end -%>
<%- if @glance_api -%>
acl glance_api_dead nbsrv(glance_api_cluster) lt 1
monitor fail if glance_api_dead