Skip to content

Commit ac048e0

Browse files
committed
List both implicitly and explicitly enabled plugins so that rabbitmq_plugin is idempotent irregardless of install ordering
1 parent 7e5c9a7 commit ac048e0

File tree

2 files changed

+11
-3
lines changed

2 files changed

+11
-3
lines changed

lib/puppet/provider/rabbitmq_plugin/rabbitmqplugins.rb

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,15 @@
66

77
def self.instances
88
plugin_list = run_with_retries do
9-
rabbitmqplugins('list', '-E', '-m')
9+
# Pass in -E for explicitly enabled plugins as well as -e for implicitly enabled plugins
10+
# Implicitly enabled plugins are those that were enabled as a dependency of another plugin/
11+
# If we do not pass in -e then the order if plugin installation matters within the puppet
12+
# code. Example, if Plugin A depends on Plugin B and we install Plugin B first it will
13+
# implicitly enable Plugin A. Then when we go to run Puppet a second time without the
14+
# -e parameter, we won't see Plugin A as being enabled so we'll try to install it again.
15+
# To preserve idempotency we should get all enabled plugins regardless of implicitly or
16+
# explicitly enabled.
17+
rabbitmqplugins('list', '-E', '-e', '-m')
1018
end
1119

1220
plugin_list.split(%r{\n}).map do |line|
@@ -32,6 +40,6 @@ def destroy
3240
end
3341

3442
def exists?
35-
run_with_retries { rabbitmqplugins('list', '-E', '-m') }.split(%r{\n}).include? resource[:name]
43+
run_with_retries { rabbitmqplugins('list', '-E', '-e', '-m') }.split(%r{\n}).include? resource[:name]
3644
end
3745
end

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
let(:provider) { provider_class.new(resource) }
1111

1212
it 'matches plugins' do
13-
provider.expects(:rabbitmqplugins).with('list', '-E', '-m').returns("foo\n")
13+
provider.expects(:rabbitmqplugins).with('list', '-E', '-e', '-m').returns("foo\n")
1414
expect(provider.exists?).to eq(true)
1515
end
1616

0 commit comments

Comments
 (0)