From: Xingchao Yu Date: Sat, 16 Jan 2016 07:35:12 +0000 (+0800) Subject: Add rabbit_ha_queues option X-Git-Tag: 8.0.0b1~2^2 X-Git-Url: https://review.fuel-infra.org/gitweb?a=commitdiff_plain;h=83e6993ab314073e6bcb2513a926eb49266f21d1;p=puppet-modules%2Fpuppet-ceilometer.git Add rabbit_ha_queues option There are two ways for setting up RabbitMQ HA: 1. Configure rabbit_hosts to multi rabbit hosts. 2. Set up a loadbalancer in front of RabbitMQ cluster, provide a unique address in rabbit_host But rabbit_ha_queues option is controled by rabbit_hosts if conditional statement. When users try the second method: changing rabbit_ha_queues to true. If they don't set rabbit_hosts, then current logic will not work. This patch aims to add an rabbit_ha_queues option, set to undef by default for backward compatbility. Change-Id: Id1245002dfbb6f314c6082f554221ee247be630c --- diff --git a/manifests/init.pp b/manifests/init.pp index 6df00b1..e5dca78 100644 --- a/manifests/init.pp +++ b/manifests/init.pp @@ -89,6 +89,10 @@ # (Optional) virtualhost to use. # Defaults to '/'. # +# [*rabbit_ha_queues*] +# (Optional) Use HA queues in RabbitMQ (x-ha-policy: all). +# Defaults to undef. +# # [*rabbit_heartbeat_timeout_threshold*] # (Optional) Number of seconds after which the RabbitMQ broker is considered # down if the heartbeat keepalive fails. Any value >0 enables heartbeats. @@ -167,6 +171,7 @@ class ceilometer( $rabbit_userid = 'guest', $rabbit_password = '', $rabbit_virtual_host = '/', + $rabbit_ha_queues = undef, $rabbit_heartbeat_timeout_threshold = 0, $rabbit_heartbeat_rate = 2, $rabbit_use_ssl = false, @@ -244,11 +249,15 @@ class ceilometer( } } + if $rabbit_ha_queues == undef { if size($rabbit_hosts) > 1 { ceilometer_config { 'oslo_messaging_rabbit/rabbit_ha_queues': value => true } } else { ceilometer_config { 'oslo_messaging_rabbit/rabbit_ha_queues': value => false } } + } else { + ceilometer_config { 'oslo_messaging_rabbit/rabbit_ha_queues': value => $rabbit_ha_queues } + } ceilometer_config { 'oslo_messaging_rabbit/rabbit_userid': value => $rabbit_userid; diff --git a/spec/classes/ceilometer_init_spec.rb b/spec/classes/ceilometer_init_spec.rb index eb8672a..9879325 100644 --- a/spec/classes/ceilometer_init_spec.rb +++ b/spec/classes/ceilometer_init_spec.rb @@ -45,6 +45,12 @@ describe 'ceilometer' do it_configures 'rabbit with SSL support' it_configures 'rabbit without HA support (with backward compatibility)' it_configures 'rabbit with connection heartbeats' + + context 'with rabbit_ha_queues' do + before { params.merge!( rabbit_params ).merge!( :rabbit_ha_queues => true ) } + it_configures 'rabbit with rabbit_ha_queues' + end + end context 'with rabbit_hosts parameter' do @@ -159,6 +165,13 @@ describe 'ceilometer' do end + shared_examples_for 'rabbit with rabbit_ha_queues' do + + it 'configures rabbit' do + is_expected.to contain_ceilometer_config('oslo_messaging_rabbit/rabbit_ha_queues').with_value( params[:rabbit_ha_queues] ) + end + end + shared_examples_for 'rabbit with HA support' do it 'configures rabbit' do