diff --git a/manifests/config.pp b/manifests/config.pp index 064c9dbde..ae712a5ec 100644 --- a/manifests/config.pp +++ b/manifests/config.pp @@ -67,6 +67,11 @@ # Handle env variables. $environment_variables = merge($default_env_variables, $rabbitmq::environment_variables) + # Try to get version from fact, otherwise use init class variable, + # then detect ranch (socket acceptor pool) availability. + $version = pick($::rabbitmq_version, $rabbitmq::version) + $ranch = versioncmp($version, '3.6') >= 0 + file { '/etc/rabbitmq': ensure => directory, owner => '0', diff --git a/spec/classes/rabbitmq_spec.rb b/spec/classes/rabbitmq_spec.rb index fabd061f2..21a3ecf60 100644 --- a/spec/classes/rabbitmq_spec.rb +++ b/spec/classes/rabbitmq_spec.rb @@ -398,7 +398,8 @@ ['Debian', 'RedHat', 'SUSE', 'Archlinux'].each do |distro| osfacts = { :osfamily => distro, - :staging_http_get => '' + :staging_http_get => '', + :rabbitmq_version => '3.6.1' } case distro @@ -1340,7 +1341,14 @@ end context "on Archlinux" do - let(:facts) {{ :osfamily => 'Archlinux', :staging_http_get => ''}} + let(:facts) do + { + :osfamily => 'Archlinux', + :staging_http_get => '', + :rabbitmq_version => '3.6.1' + } + end + it 'installs the rabbitmq package' do should contain_package('rabbitmq-server').with( 'ensure' => 'installed', @@ -1401,7 +1409,8 @@ ['RedHat', 'SuSE'].each do |distro| osfacts = { :osfamily => distro, - :staging_http_get => '' + :staging_http_get => '', + :rabbitmq_version => '3.6.1' } case distro diff --git a/spec/spec_helper_local.rb b/spec/spec_helper_local.rb index b7ed25b5e..0c0e7fce5 100644 --- a/spec/spec_helper_local.rb +++ b/spec/spec_helper_local.rb @@ -4,7 +4,8 @@ def with_debian_facts :lsbdistid => 'Debian', :lsbdistcodename => 'squeeze', :osfamily => 'Debian', - :staging_http_get => '' + :staging_http_get => '', + :rabbitmq_version => '3.6.1' } end end @@ -17,7 +18,8 @@ def with_openbsd_facts { :osfamily => 'OpenBSD', :kernelversion => '5.9', - :staging_http_get => '' + :staging_http_get => '', + :rabbitmq_version => '3.6.1' } end end @@ -27,7 +29,8 @@ def with_redhat_facts { :osfamily => 'Redhat', :operatingsystemmajrelease => '7', - :staging_http_get => '' + :staging_http_get => '', + :rabbitmq_version => '3.6.1' } end end diff --git a/templates/rabbitmq.config.erb b/templates/rabbitmq.config.erb index bece53494..bc1536436 100644 --- a/templates/rabbitmq.config.erb +++ b/templates/rabbitmq.config.erb @@ -17,17 +17,19 @@ {cluster_nodes, {[<%= @cluster_nodes.map { |n| "\'rabbit@#{n}\'" }.join(', ') %>], <%= @cluster_node_type %>}}, {cluster_partition_handling, <%= @cluster_partition_handling %>}, <% end -%> - {tcp_listen_options, - [binary, + {tcp_listen_options, [ + <%- unless @ranch -%> + binary, + {packet, raw}, + {reuseaddr, true}, + <%- end -%> <%- if @tcp_keepalive -%> {keepalive, true}, <%- end -%> - {packet, raw}, - {reuseaddr, true}, {backlog, 128}, {nodelay, true}, - {exit_on_close, false}] - }, + {exit_on_close, false} + ]}, <%- if @ssl_only -%> {tcp_listeners, []}, <%- elsif @interface != 'UNSET' -%>