Skip to content

Commit 8355d4e

Browse files
committed
added param support for quorum_cluster_size and target-group-size
1 parent 5c77c91 commit 8355d4e

File tree

7 files changed

+48
-0
lines changed

7 files changed

+48
-0
lines changed

REFERENCE.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -277,6 +277,7 @@ The following parameters are available in the `rabbitmq` class:
277277
* [`package_name`](#-rabbitmq--package_name)
278278
* [`port`](#-rabbitmq--port)
279279
* [`python_package`](#-rabbitmq--python_package)
280+
* [`quorum_cluster_size`](#-rabbitmq--quorum_cluster_size)
280281
* [`quorum_membership_reconciliation_enabled`](#-rabbitmq--quorum_membership_reconciliation_enabled)
281282
* [`quorum_membership_reconciliation_auto_remove`](#-rabbitmq--quorum_membership_reconciliation_auto_remove)
282283
* [`quorum_membership_reconciliation_interval`](#-rabbitmq--quorum_membership_reconciliation_interval)
@@ -845,6 +846,15 @@ Name of the package required by rabbitmqadmin.
845846

846847
Default value: `'python'`
847848

849+
##### <a name="-rabbitmq--quorum_cluster_size"></a>`quorum_cluster_size`
850+
851+
Data type: `Optional[Integer]`
852+
853+
Sets the default quorum queue cluster size.
854+
More info can be found here: https://www.rabbitmq.com/docs/quorum-queues
855+
856+
Default value: `undef`
857+
848858
##### <a name="-rabbitmq--quorum_membership_reconciliation_enabled"></a>`quorum_membership_reconciliation_enabled`
849859

850860
Data type: `Optional[Boolean]`

lib/puppet/type/rabbitmq_policy.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
message-ttl
1414
queue-version
1515
shards-per-node
16+
target-group-size
1617
].freeze
1718

1819
Puppet::Type.newtype(:rabbitmq_policy) do

manifests/config.pp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
$management_ssl = $rabbitmq::management_ssl
2929
$management_hostname = $rabbitmq::management_hostname
3030
$node_ip_address = $rabbitmq::node_ip_address
31+
$quorum_cluster_size = $rabbitmq::quorum_cluster_size
3132
$quorum_membership_reconciliation_enabled = $rabbitmq::quorum_membership_reconciliation_enabled
3233
$quorum_membership_reconciliation_auto_remove = $rabbitmq::quorum_membership_reconciliation_auto_remove
3334
$quorum_membership_reconciliation_interval = $rabbitmq::quorum_membership_reconciliation_interval

manifests/init.pp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -260,6 +260,9 @@
260260
# The RabbitMQ port.
261261
# @param python_package
262262
# Name of the package required by rabbitmqadmin.
263+
# @param quorum_cluster_size
264+
# Sets the default quorum queue cluster size.
265+
# More info can be found here: https://www.rabbitmq.com/docs/quorum-queues
263266
# @param quorum_membership_reconciliation_enabled
264267
# Enables or disables continuous membership reconciliation.
265268
# This REQUIRES RabbitMQ 3.13 or higher to be set to true. More information on this configuration
@@ -421,6 +424,7 @@
421424
Optional[Variant[Numeric, String[1]]] $package_apt_pin = undef,
422425
String $package_ensure = 'installed',
423426
Optional[String] $package_gpg_key = undef,
427+
Optional[Integer] $quorum_cluster_size = undef,
424428
Optional[Boolean] $quorum_membership_reconciliation_enabled = undef,
425429
Optional[Boolean] $quorum_membership_reconciliation_auto_remove = undef,
426430
Optional[Integer] $quorum_membership_reconciliation_interval = undef,

spec/classes/rabbitmq_spec.rb

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1817,6 +1817,22 @@
18171817
end
18181818
end
18191819

1820+
describe 'quorum_cluster_size with default value' do
1821+
it 'does not set quorum_cluster_size' do
1822+
is_expected.to contain_file('rabbitmq.config'). \
1823+
without_content(%r{quorum_cluster_size, })
1824+
end
1825+
end
1826+
1827+
describe 'quorum_cluster_size with non-default value' do
1828+
let(:params) { { quorum_cluster_size: 7 } }
1829+
1830+
it 'does set quorum_cluster_size to 7' do
1831+
is_expected.to contain_file('rabbitmq.config'). \
1832+
with_content(%r{quorum_cluster_size, 7})
1833+
end
1834+
end
1835+
18201836
# Ensure that whenever Param quorum_membership_reconciliation_enabled is unset - none of the
18211837
# other quorum_membership_reconciliation paramaters are set at all
18221838
# This ensures full backward compatibility with PRE RabbitMQ 3.13

spec/unit/puppet/type/rabbitmq_policy_spec.rb

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -234,6 +234,19 @@
234234
end.to raise_error(Puppet::Error, %r{Invalid queue-version value.*oogabooga})
235235
end
236236

237+
it 'accepts and converts the target-group-size value' do
238+
definition = { 'target-group-size' => '7' }
239+
policy[:definition] = definition
240+
expect(policy[:definition]['target-group-size']).to eq(7)
241+
end
242+
243+
it 'does not accept non-numeric target-group-size value' do
244+
definition = { 'target-group-size' => 'notreal' }
245+
expect do
246+
policy[:definition] = definition
247+
end.to raise_error(Puppet::Error, %r{Invalid target-group-size value.*notreal})
248+
end
249+
237250
context 'accepts list value in ha-params when ha-mode = nodes' do
238251
before do
239252
policy[:definition] = definition

templates/rabbitmq.config.epp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,9 @@
2626
<%- } -%>
2727
{cluster_partition_handling, <%= $rabbitmq::config::cluster_partition_handling %>},
2828
<% } -%>
29+
<% if $rabbitmq::config::quorum_cluster_size {-%>
30+
{quorum_cluster_size, <%= $rabbitmq::config::quorum_cluster_size %>},
31+
<%- } -%>
2932
<% if $rabbitmq::config::quorum_membership_reconciliation_enabled {-%>
3033
{quorum_membership_reconciliation_enabled, <%= $rabbitmq::config::quorum_membership_reconciliation_enabled %>},
3134
<%- unless $rabbitmq::config::quorum_membership_reconciliation_auto_remove =~ Undef {-%>

0 commit comments

Comments
 (0)