Skip to content

Commit bf59be0

Browse files
committed
Merge pull request #231 from misterdorm/tcpkeepalive
adding tcp_keepalive parameter
2 parents 76e742b + 30f3fe6 commit bf59be0

File tree

6 files changed

+38
-0
lines changed

6 files changed

+38
-0
lines changed

README.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -327,6 +327,10 @@ The port to use for Stomp.
327327

328328
Boolean to install the stomp plugin.
329329

330+
####`tcp_keepalive`
331+
332+
Boolean to enable TCP connection keepalive for RabbitMQ service.
333+
330334
####`version`
331335

332336
Sets the version to install.

manifests/config.pp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
$node_ip_address = $rabbitmq::node_ip_address
1818
$plugin_dir = $rabbitmq::plugin_dir
1919
$port = $rabbitmq::port
20+
$tcp_keepalive = $rabbitmq::tcp_keepalive
2021
$service_name = $rabbitmq::service_name
2122
$ssl = $rabbitmq::ssl
2223
$ssl_only = $rabbitmq::ssl_only

manifests/init.pp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
$manage_repos = $rabbitmq::params::manage_repos,
2626
$plugin_dir = $rabbitmq::params::plugin_dir,
2727
$port = $rabbitmq::params::port,
28+
$tcp_keepalive = $rabbitmq::params::tcp_keepalive,
2829
$service_ensure = $rabbitmq::params::service_ensure,
2930
$service_manage = $rabbitmq::params::service_manage,
3031
$service_name = $rabbitmq::params::service_name,
@@ -83,6 +84,7 @@
8384
validate_re($port, ['\d+','UNSET'])
8485
validate_re($stomp_port, '\d+')
8586
validate_bool($wipe_db_on_cookie_change)
87+
validate_bool($tcp_keepalive)
8688
# Validate service parameters.
8789
validate_re($service_ensure, '^(running|stopped)$')
8890
validate_bool($service_manage)

manifests/params.pp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,7 @@
7272
$node_ip_address = 'UNSET'
7373
$plugin_dir = "/usr/lib/rabbitmq/lib/rabbitmq_server-${version}/plugins"
7474
$port = '5672'
75+
$tcp_keepalive = false
7576
$ssl = false
7677
$ssl_only = false
7778
$ssl_cacert = 'UNSET'

spec/classes/rabbitmq_spec.rb

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -474,6 +474,33 @@
474474
end
475475
end
476476

477+
describe 'tcp_keepalive enabled' do
478+
let(:params) {{ :tcp_keepalive => true }}
479+
it 'should set tcp_listen_options keepalive true' do
480+
should contain_file('rabbitmq.config') \
481+
.with_content(/\{tcp_listen_options, \[\{keepalive, true\}\]\},/)
482+
end
483+
end
484+
485+
describe 'tcp_keepalive disabled (default)' do
486+
it 'should not set tcp_listen_options' do
487+
should contain_file('rabbitmq.config') \
488+
.without_content(/\{tcp_listen_options, \[\{keepalive, true\}\]\},/)
489+
end
490+
end
491+
492+
describe 'non-bool tcp_keepalive parameter' do
493+
let :params do
494+
{ :tcp_keepalive => 'string' }
495+
end
496+
497+
it 'should raise an error' do
498+
expect {
499+
should contain_file('rabbitmq.config')
500+
}.to raise_error(Puppet::Error, /is not a boolean/)
501+
end
502+
end
503+
477504
context 'delete_guest_user' do
478505
describe 'should do nothing by default' do
479506
it { should_not contain_rabbitmq_user('guest') }

templates/rabbitmq.config.erb

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,9 @@
99
{cluster_nodes, {[<%= @r_cluster_nodes.map { |n| "\'rabbit@#{n}\'" }.join(', ') %>], <%= @cluster_node_type %>}},
1010
{cluster_partition_handling, <%= @cluster_partition_handling %>},
1111
<% end -%>
12+
<%- if @tcp_keepalive -%>
13+
{tcp_listen_options, [{keepalive, true}]},
14+
<%- end -%>
1215
<%- if @ssl_only -%>
1316
{tcp_listeners, []},
1417
<%- end -%>

0 commit comments

Comments
 (0)