Skip to content

Commit

Permalink
Support enabling rabbitmq_management without rabbitmqadmin
Browse files Browse the repository at this point in the history
Enabling the rabbitmq_managemnt interface and installing the
rabbitmqadmin client was both controlled by the admin_enable
parameter.

Adds option enable_management (default: false). When this is
set to true, and admin_enable is false the rabbitmq_management
plugin is enabled, but the rabbitmqadmin client is not
installed.

For backward compatiblity the rabbitmq_management plugin is
also enabled when admin_enable is set to true.

Related voxpupuli#775
  • Loading branch information
hjensas committed Feb 13, 2019
1 parent 5283ed8 commit d062abe
Show file tree
Hide file tree
Showing 5 changed files with 58 additions and 5 deletions.
1 change: 1 addition & 0 deletions manifests/config.pp
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
class rabbitmq::config {

$admin_enable = $rabbitmq::admin_enable
$management_enable = $rabbitmq::management_enable
$cluster_node_type = $rabbitmq::cluster_node_type
$cluster_nodes = $rabbitmq::cluster_nodes
$config = $rabbitmq::config
Expand Down
13 changes: 10 additions & 3 deletions manifests/init.pp
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,10 @@
#
# @param admin_enable
# If enabled sets up the management interface/plugin for RabbitMQ.
# This also install the rabbitmqadmin command line tool.
# @param management_enable
# If enabled sets up the management interface/plugin for RabbitMQ.
# NOTE: This does not install the rabbitmqadmin command line tool.
# @param auth_backends
# An array specifying authorization/authentication backend to use. Single quotes should be placed around array entries,
# ex. `['{foo, baz}', 'baz']` Defaults to [rabbit_auth_backend_internal], and if using LDAP defaults to [rabbit_auth_backend_internal,
Expand Down Expand Up @@ -280,6 +284,7 @@
#
class rabbitmq(
Boolean $admin_enable = $rabbitmq::params::admin_enable,
Boolean $management_enable = $rabbitmq::params::management_enable,
Enum['ram', 'disk', 'disc'] $cluster_node_type = $rabbitmq::params::cluster_node_type,
Array $cluster_nodes = $rabbitmq::params::cluster_nodes,
String $config = $rabbitmq::params::config,
Expand Down Expand Up @@ -408,14 +413,16 @@
contain rabbitmq::service
contain rabbitmq::management

if $admin_enable and $service_manage {
include 'rabbitmq::install::rabbitmqadmin'

if ($management_enable or $admin_enable) and $service_manage {
rabbitmq_plugin { 'rabbitmq_management':
ensure => present,
notify => Class['rabbitmq::service'],
provider => 'rabbitmqplugins',
}
}

if $admin_enable and $service_manage {
include 'rabbitmq::install::rabbitmqadmin'

Class['rabbitmq::service'] -> Class['rabbitmq::install::rabbitmqadmin']
Class['rabbitmq::install::rabbitmqadmin'] -> Rabbitmq_exchange<| |>
Expand Down
1 change: 1 addition & 0 deletions manifests/params.pp
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@

#install
$admin_enable = true
$management_enable = false
$management_port = 15672
$management_ssl = true
$repos_ensure = false
Expand Down
44 changes: 44 additions & 0 deletions spec/classes/rabbitmq_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -615,6 +615,50 @@
end
end

describe 'configure management plugin' do
let :params do
{
admin_enable: true,
management_enable: false
}
end

it { is_expected.to contain_rabbitmq_plugin('rabbitmq_management') }
it 'sets rabbitmq_managment opts to specified values' do
is_expected.to contain_file('rabbitmq.config').with_content(%r{rabbitmq_management, \[})
is_expected.to contain_file('rabbitmq.config').with_content(%r{listener, \[})
is_expected.to contain_file('rabbitmq.config').with_content(%r{port, 15672\}})
end

describe 'with admin_enable false' do
let :params do
{
admin_enable: false,
management_enable: false
}
end

it { is_expected.not_to contain_rabbitmq_plugin('rabbitmq_management') }
end

describe 'with admin_enable false and management_enable true' do
let :params do
{
admin_enable: false,
management_enable: true
}
end

it { is_expected.to contain_rabbitmq_plugin('rabbitmq_management') }
it 'sets rabbitmq_managment opts to specified values' do
is_expected.to contain_file('rabbitmq.config').with_content(%r{rabbitmq_management, \[})
is_expected.to contain_file('rabbitmq.config').with_content(%r{listener, \[})
is_expected.to contain_file('rabbitmq.config').with_content(%r{port, 15672\}})
end
end
end


describe 'configuring shovel plugin' do
let :params do
{
Expand Down
4 changes: 2 additions & 2 deletions templates/rabbitmq.config.erb
Original file line number Diff line number Diff line change
Expand Up @@ -96,12 +96,12 @@
<%= @config_kernel_variables.sort.map{|k,v| "{#{k}, #{v}}"}.join(",\n ") %>
]}
<%- end -%>
<%- if @admin_enable or !@config_management_variables.empty? -%>,
<%- if @admin_enable or @management_enable or !@config_management_variables.empty? -%>,
{rabbitmq_management, [
<%- if !@config_management_variables.empty? -%>
<%= @config_management_variables.sort.map{|k,v| "{#{k}, #{v}}"}.join(",\n ") %>
<%- end -%>
<%- if @admin_enable -%>
<%- if @admin_enable or @management_enable -%>
<%- if !@config_management_variables.empty? -%>,<%-end-%>
{listener, [
<%- if @ssl && @management_ssl -%>
Expand Down

0 comments on commit d062abe

Please sign in to comment.