Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add loopback_users parameter (adds ability to allow guest user to login remotely) #699

Merged
merged 13 commits into from
Apr 24, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions manifests/config.pp
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@
$inetrc_config = $rabbitmq::inetrc_config
$inetrc_config_path = $rabbitmq::inetrc_config_path
$ssl_erl_dist = $rabbitmq::ssl_erl_dist
$loopback_users = $rabbitmq::loopback_users

if $ssl_only {
$default_ssl_env_variables = {}
Expand Down
2 changes: 2 additions & 0 deletions manifests/init.pp
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,7 @@
# @param rabbitmq_home OS dependent. default defined in param.pp. The home directory of the rabbitmq deamon.
# @param $rabbitmqadmin_package OS dependent. default defined in param.pp. If undef: install rabbitmqadmin via archive, otherwise via package
# @param $archive_options. default defined in param.pp. Extra options to Archive resource to download rabbitmqadmin file
# @param $loopback_users. default defined in param.pp. This option configures a list of users to allow access via the loopback interfaces
class rabbitmq(
Boolean $admin_enable = $rabbitmq::params::admin_enable,
Enum['ram', 'disk', 'disc'] $cluster_node_type = $rabbitmq::params::cluster_node_type,
Expand Down Expand Up @@ -278,6 +279,7 @@
Boolean $ssl_erl_dist = $rabbitmq::params::ssl_erl_dist,
Optional[String] $rabbitmqadmin_package = $rabbitmq::params::rabbitmqadmin_package,
Array $archive_options = $rabbitmq::params::archive_options,
Array $loopback_users = $rabbitmq::params::loopback_users,
) inherits rabbitmq::params {

if $ssl_only and ! $ssl {
Expand Down
1 change: 1 addition & 0 deletions manifests/params.pp
Original file line number Diff line number Diff line change
Expand Up @@ -145,4 +145,5 @@
$inetrc_config = 'rabbitmq/inetrc.erb'
$inetrc_config_path = '/etc/rabbitmq/inetrc'
$archive_options = []
$loopback_users = ['guest']
}
25 changes: 25 additions & 0 deletions spec/classes/rabbitmq_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -1411,6 +1411,31 @@
end
end

describe 'rabbitmq-loopback_users by default' do
it 'sets the loopback_users parameter in the config file' do
is_expected.to contain_file('rabbitmq.config'). \
with_content(%r{\{loopback_users, \[<<"guest">>\]\}})
end
end

describe 'rabbitmq-loopback_users allow connections via loopback interfaces' do
let(:params) { { loopback_users: [] } }

it 'sets the loopback_users parameter in the config file' do
is_expected.to contain_file('rabbitmq.config'). \
with_content(%r{\{loopback_users, \[\]\}})
end
end

describe 'rabbitmq-loopback_users allow connections via loopback interfaces to a group of users' do
let(:params) { { loopback_users: %w[user1 user2] } }

it 'sets the loopback_users parameter in the config file' do
is_expected.to contain_file('rabbitmq.config'). \
with_content(%r{\{loopback_users, \[<<\"user1\">>, <<\"user2\">>\]\}})
end
end

##
## rabbitmq::service
##
Expand Down
1 change: 1 addition & 0 deletions templates/rabbitmq.config.erb
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
<%- if @heartbeat -%>
{heartbeat, <%=@heartbeat%>},
<% end -%>
{loopback_users, [<%= @loopback_users.map { |u| "<<\"#{u}\">>" }.join(', ') %>]},
<% if @auth_backends -%>
{auth_backends, [<%= @auth_backends.map { |v| "#{v}" }.join(', ') %>]},
<% elsif @ldap_auth -%>
Expand Down