diff --git a/manifests/init.pp b/manifests/init.pp index 1ac3f6d61..138515ee3 100644 --- a/manifests/init.pp +++ b/manifests/init.pp @@ -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, @@ -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, diff --git a/manifests/params.pp b/manifests/params.pp index 1ce18c3f8..f57b1f9c0 100644 --- a/manifests/params.pp +++ b/manifests/params.pp @@ -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' @@ -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' diff --git a/spec/classes/rabbitmq_spec.rb b/spec/classes/rabbitmq_spec.rb index 8429c98c4..56f632e38 100644 --- a/spec/classes/rabbitmq_spec.rb +++ b/spec/classes/rabbitmq_spec.rb @@ -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, @@ -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, @@ -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, diff --git a/templates/rabbitmq.config.erb b/templates/rabbitmq.config.erb index 591a1cb17..5681ec638 100644 --- a/templates/rabbitmq.config.erb +++ b/templates/rabbitmq.config.erb @@ -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 %>"},