Skip to content

Commit aa675b8

Browse files
authored
Merge pull request voxpupuli#917 from enothen/plugins
Enable usage of custom list of plugins when using static config file
2 parents 8f5a461 + 71222de commit aa675b8

File tree

4 files changed

+35
-3
lines changed

4 files changed

+35
-3
lines changed

manifests/config.pp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
$admin_enable = $rabbitmq::admin_enable
77
$management_enable = $rabbitmq::management_enable
88
$use_config_file_for_plugins = $rabbitmq::use_config_file_for_plugins
9+
$plugins = $rabbitmq::plugins
910
$cluster_node_type = $rabbitmq::cluster_node_type
1011
$cluster_nodes = $rabbitmq::cluster_nodes
1112
$config = $rabbitmq::config

manifests/init.pp

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,8 @@
116116
# @param use_config_file_for_plugins
117117
# If enabled the /etc/rabbitmq/enabled_plugins config file is created,
118118
# replacing the use of the rabbitmqplugins provider to enable plugins.
119+
# @param plugins
120+
# Additional list of plugins to start, or to add to /etc/rabbitmq/enabled_plugins, if use_config_file_for_plugins is enabled.
119121
# @param auth_backends
120122
# An array specifying authorization/authentication backend to use. Single quotes should be placed around array entries,
121123
# ex. `['{foo, baz}', 'baz']` Defaults to [rabbit_auth_backend_internal], and if using LDAP defaults to [rabbit_auth_backend_internal,
@@ -345,6 +347,7 @@
345347
Boolean $admin_enable = true,
346348
Boolean $management_enable = false,
347349
Boolean $use_config_file_for_plugins = false,
350+
Array $plugins = [],
348351
Hash $cluster = $rabbitmq::cluster,
349352
Enum['ram', 'disc'] $cluster_node_type = 'disc',
350353
Array $cluster_nodes = [],
@@ -550,6 +553,14 @@
550553
}
551554
}
552555
}
556+
# Start anything else listed on the plugins array, if it was not started already by the other booleans
557+
$plugins.each | $plugin | {
558+
rabbitmq_plugin { $plugin:
559+
ensure => present,
560+
notify => Class['rabbitmq::service'],
561+
provider => 'rabbitmqplugins',
562+
}
563+
}
553564
}
554565

555566
if $admin_enable and $service_manage {

spec/classes/rabbitmq_spec.rb

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -682,7 +682,7 @@
682682
end
683683

684684
context 'use config file for plugins' do
685-
describe 'config_plugins_file: true' do
685+
describe 'config_plugins_file: true and default list of enabled plugins' do
686686
let :params do
687687
{ use_config_file_for_plugins: true }
688688
end
@@ -700,6 +700,26 @@
700700
end
701701
end
702702

703+
describe 'config_plugins_file: true and custom list of enabled plugins' do
704+
let :params do
705+
{
706+
use_config_file_for_plugins: true,
707+
admin_enable: false,
708+
plugins: %w[rabbitmq_stomp rabbitmq_shovel rabbitmq_prometheus]
709+
}
710+
end
711+
712+
it 'does not use rabbitmqplugin provider' do
713+
is_expected.not_to contain_rabbitmq_plugin('rabbitmq_stomp')
714+
is_expected.not_to contain_rabbitmq_plugin('rabbitmq_shovel')
715+
is_expected.not_to contain_rabbitmq_plugin('rabbitmq_prometheus')
716+
end
717+
718+
it 'configures enabled_plugins' do
719+
is_expected.to contain_file('enabled_plugins').with_content(%r{\[rabbitmq_stomp,rabbitmq_shovel,rabbitmq_prometheus\]\.})
720+
end
721+
end
722+
703723
describe 'with all plugins enabled admin_enable: false, manamgent_enable: true' do
704724
let :params do
705725
{

templates/enabled_plugins.erb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
% This file managed by Puppet
22
% Template Path: <%= @module_name %>/templates/enabled_plugins
3-
<%- @_plugins = [] -%>
3+
<%- @_plugins = @plugins -%>
44
<%- if @admin_enable or @management_enable -%>
55
<%- @_plugins << 'rabbitmq_management' -%>
66
<%- end -%>
@@ -16,4 +16,4 @@
1616
<%- @_plugins << 'rabbitmq_shovel_management' -%>
1717
<%- end -%>
1818
<%- end -%>
19-
[<%= @_plugins.join(',')%>].
19+
[<%= (@_plugins.uniq).join(',')%>].

0 commit comments

Comments
 (0)