Skip to content

Commit 3436f22

Browse files
committed
Make rabbitmq_plugin resource functional on RabbitMQ 3.10.x
The rabbitmq_plugin resource use the "rabbitmq-plugins"-command when enumerating enabled plugins. Starting with rabbitmq 3.10, this command will output a informational message: 'Listing plugins with pattern ".*" ...' which can be hidden with the -s or -q parameter. However, this approach will break rabbitmq_plugin on older versions of RabbitMQ. This patch implements a workaround that simply ignores the outputted line if it exists. Fixes: voxpupuli#909
1 parent 277e3e8 commit 3436f22

File tree

2 files changed

+11
-0
lines changed

2 files changed

+11
-0
lines changed

lib/puppet/provider/rabbitmq_plugin/rabbitmqplugins.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ def self.instances
1212
end
1313

1414
plugin_list.split(%r{\n}).map do |line|
15+
next if line.start_with?('Listing plugins')
1516
raise Puppet::Error, "Cannot parse invalid plugins line: #{line}" unless line =~ %r{^(\S+)$}
1617

1718
new(name: Regexp.last_match(1))

spec/unit/puppet/provider/rabbitmq_plugin/rabbitmqctl_spec.rb

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,16 @@
2222
provider.create
2323
end
2424

25+
context 'with RabbitMQ version >=3.10.0' do
26+
it 'matches plugins' do
27+
provider.expects(:rabbitmqplugins).with('list', '-E', '-m').returns <<~EOT
28+
Listing plugins with pattern ".*" ...
29+
foo
30+
EOT
31+
expect(provider.exists?).to eq(true)
32+
end
33+
end
34+
2535
context 'with RabbitMQ version >=3.4.0' do
2636
it 'calls rabbitmqplugins to enable' do
2737
provider.class.expects(:rabbitmq_version).returns '3.4.0'

0 commit comments

Comments
 (0)