Skip to content

Commit

Permalink
Merge pull request #307 from daniel-gadd/feature/interfaces
Browse files Browse the repository at this point in the history
Added interfaces option to set what interfaces rabbitmq binds to.
  • Loading branch information
cmurphy committed Feb 22, 2015
2 parents c90c707 + de6fed2 commit 2f955e1
Show file tree
Hide file tree
Showing 4 changed files with 61 additions and 0 deletions.
2 changes: 2 additions & 0 deletions manifests/init.pp
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
$env_config = $rabbitmq::params::env_config,
$env_config_path = $rabbitmq::params::env_config_path,
$erlang_cookie = $rabbitmq::params::erlang_cookie,
$interface = $rabbitmq::params::interface,
$management_port = $rabbitmq::params::management_port,
$node_ip_address = $rabbitmq::params::node_ip_address,
$package_apt_pin = $rabbitmq::params::package_apt_pin,
Expand All @@ -35,6 +36,7 @@
$ssl_cert = $rabbitmq::params::ssl_cert,
$ssl_key = $rabbitmq::params::ssl_key,
$ssl_port = $rabbitmq::params::ssl_port,
$ssl_interface = $rabbitmq::params::ssl_interface,
$ssl_management_port = $rabbitmq::params::ssl_management_port,
$ssl_stomp_port = $rabbitmq::params::ssl_stomp_port,
$ssl_verify = $rabbitmq::params::ssl_verify,
Expand Down
2 changes: 2 additions & 0 deletions manifests/params.pp
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@
$env_config = 'rabbitmq/rabbitmq-env.conf.erb'
$env_config_path = '/etc/rabbitmq/rabbitmq-env.conf'
$erlang_cookie = undef
$interface = 'UNSET'
$node_ip_address = 'UNSET'
$plugin_dir = "/usr/lib/rabbitmq/lib/rabbitmq_server-${version}/plugins"
$port = '5672'
Expand All @@ -69,6 +70,7 @@
$ssl_cert = 'UNSET'
$ssl_key = 'UNSET'
$ssl_port = '5671'
$ssl_interface = 'UNSET'
$ssl_management_port = '15671'
$ssl_stomp_port = '6164'
$ssl_verify = 'verify_none'
Expand Down
51 changes: 51 additions & 0 deletions spec/classes/rabbitmq_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -459,6 +459,16 @@
end
end

describe 'interfaces option with no ssl' do
let(:params) {
{ :interface => '0.0.0.0',
} }

it 'should set ssl options to specified values' do
should contain_file('rabbitmq.config').with_content(%r{tcp_listeners, \[\{"0.0.0.0", 5672\}\]})
end
end

describe 'ssl options' do
let(:params) {
{ :ssl => true,
Expand All @@ -484,6 +494,27 @@
end
end


describe 'ssl options with ssl_interfaces' do
let(:params) {
{ :ssl => true,
:ssl_port => 3141,
:ssl_interface => '0.0.0.0',
:ssl_cacert => '/path/to/cacert',
:ssl_cert => '/path/to/cert',
:ssl_key => '/path/to/key'
} }

it 'should set ssl options to specified values' do
should contain_file('rabbitmq.config').with_content(%r{ssl_listeners, \[\{"0.0.0.0", 3141\}\]})
should contain_file('rabbitmq.config').with_content(%r{ssl_options, \[\{cacertfile,"/path/to/cacert"})
should contain_file('rabbitmq.config').with_content(%r{certfile,"/path/to/cert"})
should contain_file('rabbitmq.config').with_content(%r{keyfile,"/path/to/key})
end
end



describe 'ssl options with ssl_only' do
let(:params) {
{ :ssl => true,
Expand All @@ -503,6 +534,26 @@
end
end

describe 'ssl options with ssl_only and ssl_interfaces' do
let(:params) {
{ :ssl => true,
:ssl_only => true,
:ssl_port => 3141,
:ssl_interface => '0.0.0.0',
:ssl_cacert => '/path/to/cacert',
:ssl_cert => '/path/to/cert',
:ssl_key => '/path/to/key'
} }

it 'should set ssl options to specified values' do
should contain_file('rabbitmq.config').with_content(%r{tcp_listeners, \[\]})
should contain_file('rabbitmq.config').with_content(%r{ssl_listeners, \[\{"0.0.0.0", 3141\}\]})
should contain_file('rabbitmq.config').with_content(%r{ssl_options, \[\{cacertfile,"/path/to/cacert"})
should contain_file('rabbitmq.config').with_content(%r{certfile,"/path/to/cert"})
should contain_file('rabbitmq.config').with_content(%r{keyfile,"/path/to/key})
end
end

describe 'ssl options with specific ssl versions' do
let(:params) {
{ :ssl => true,
Expand Down
6 changes: 6 additions & 0 deletions templates/rabbitmq.config.erb
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,15 @@
<%- end -%>
<%- if @ssl_only -%>
{tcp_listeners, []},
<%- elsif @interface != 'UNSET' -%>
{tcp_listeners, [{"<%= @interface%>", <%= @port %>}]},
<%- end -%>
<%- if @ssl -%>
<%- if @ssl_interface != 'UNSET' -%>
{ssl_listeners, [{"<%= @ssl_interface%>", <%= @ssl_port %>}]},
<%- else -%>
{ssl_listeners, [<%= @ssl_port %>]},
<%- end -%>
{ssl_options, [<%- if @ssl_cacert != 'UNSET' -%>{cacertfile,"<%= @ssl_cacert %>"},<%- end -%>
{certfile,"<%= @ssl_cert %>"},
{keyfile,"<%= @ssl_key %>"},
Expand Down

0 comments on commit 2f955e1

Please sign in to comment.