Skip to content

Commit 47be9d0

Browse files
authored
Merge pull request #1013 from SpinEternel/master
Add support for cowboy_opts config in rabbitmq.config
2 parents 1826818 + dd64088 commit 47be9d0

File tree

5 files changed

+68
-1
lines changed

5 files changed

+68
-1
lines changed

REFERENCE.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -207,6 +207,7 @@ The following parameters are available in the `rabbitmq` class:
207207
* [`config`](#-rabbitmq--config)
208208
* [`config_additional_variables`](#-rabbitmq--config_additional_variables)
209209
* [`config_cluster`](#-rabbitmq--config_cluster)
210+
* [`config_cowboy_opts`](#-rabbitmq--config_cowboy_opts)
210211
* [`config_kernel_variables`](#-rabbitmq--config_kernel_variables)
211212
* [`config_path`](#-rabbitmq--config_path)
212213
* [`config_ranch`](#-rabbitmq--config_ranch)
@@ -411,6 +412,14 @@ Enable or disable clustering support.
411412

412413
Default value: `false`
413414

415+
##### <a name="-rabbitmq--config_cowboy_opts"></a>`config_cowboy_opts`
416+
417+
Data type: `Hash`
418+
419+
Hash of additional configs (key / value) for `cowboy_opts` in rabbitmq.config.
420+
421+
Default value: `{}`
422+
414423
##### <a name="-rabbitmq--config_kernel_variables"></a>`config_kernel_variables`
415424

416425
Data type: `Hash`

manifests/config.pp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
$cluster_nodes = $rabbitmq::cluster_nodes
1212
$config = $rabbitmq::config
1313
$config_cluster = $rabbitmq::config_cluster
14+
$config_cowboy_opts = $rabbitmq::config_cowboy_opts
1415
$config_path = $rabbitmq::config_path
1516
$config_ranch = $rabbitmq::config_ranch
1617
$config_stomp = $rabbitmq::config_stomp

manifests/init.pp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,8 @@
137137
# Additional config variables in rabbitmq.config
138138
# @param config_cluster
139139
# Enable or disable clustering support.
140+
# @param config_cowboy_opts
141+
# Hash of additional configs (key / value) for `cowboy_opts` in rabbitmq.config.
140142
# @param config_kernel_variables
141143
# Hash of Erlang kernel configuration variables to set (see [Variables Configurable in rabbitmq.config](#variables-configurable-in-rabbitmq.config)).
142144
# @param config_path
@@ -357,6 +359,7 @@
357359
Enum['ram', 'disc'] $cluster_node_type = 'disc',
358360
Array $cluster_nodes = [],
359361
String $config = 'rabbitmq/rabbitmq.config.epp',
362+
Hash $config_cowboy_opts = {},
360363
Boolean $config_cluster = false,
361364
Stdlib::Absolutepath $config_path = '/etc/rabbitmq/rabbitmq.config',
362365
Boolean $config_ranch = true,

spec/classes/rabbitmq_spec.rb

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -429,6 +429,50 @@
429429
end
430430
end
431431

432+
describe 'with config_cowboy_opts' do
433+
context 'without SSL' do
434+
let(:params) do
435+
{
436+
config_cowboy_opts: {
437+
'max_request_line_length' => 16_000,
438+
'max_keepalive' => 1000,
439+
},
440+
}
441+
end
442+
443+
it 'sets expected cowboy config variables' do
444+
is_expected.to contain_file('rabbitmq.config'). \
445+
with_content(
446+
%r{\{cowboy_opts, \[\n\s+\{max_keepalive, 1000\},\n\s+\{max_request_line_length, 16000\}}
447+
)
448+
end
449+
end
450+
451+
context 'withSSL' do
452+
let(:params) do
453+
{
454+
config_cowboy_opts: {
455+
'max_request_line_length' => 16_003,
456+
'max_keepalive' => 1002,
457+
},
458+
ssl: true,
459+
ssl_port: 3141,
460+
ssl_cacert: '/path/to/cacert',
461+
ssl_cert: '/path/to/cert',
462+
ssl_key: '/path/to/key',
463+
ssl_versions: ['tlsv1.2', 'tlsv1.1'],
464+
}
465+
end
466+
467+
it 'sets expected cowboy config variables' do
468+
is_expected.to contain_file('rabbitmq.config'). \
469+
with_content(
470+
%r{\{cowboy_opts, \[\n\s+\{max_keepalive, 1002\},\n\s+\{max_request_line_length, 16003\}}
471+
)
472+
end
473+
end
474+
end
475+
432476
describe 'rabbitmq-env configuration' do
433477
context 'with default params' do
434478
it 'sets environment variables' do

templates/rabbitmq.config.epp

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,13 @@
136136
{ip, "<%= $rabbitmq::config::management_ip_address %>"},
137137
<%- } -%>
138138
{port, <%= $rabbitmq::config::ssl_management_port %>},
139+
<%- if !$rabbitmq::config::config_cowboy_opts.empty {-%>
140+
{cowboy_opts, [
141+
<%- $rabbitmq::config::config_cowboy_opts.keys.sort.each |$k| { -%>
142+
{<%= $k %>, <%= $rabbitmq::config::config_cowboy_opts[$k] %>}<% if $k != $rabbitmq::config::config_cowboy_opts.keys.sort[-1] { %>,<%- } %>
143+
<%- } -%>
144+
]},
145+
<%- } -%>
139146
{ssl, true},
140147
{ssl_opts, [
141148
<%- if $rabbitmq::config::ssl_management_cacert {-%>
@@ -164,7 +171,10 @@
164171
<%- if $rabbitmq::config::management_ip_address {-%>
165172
{ip, "<%= $rabbitmq::config::management_ip_address %>"},
166173
<%- } -%>
167-
{port, <%= $rabbitmq::config::management_port %>}
174+
{port, <%= $rabbitmq::config::management_port %>}<% if !$rabbitmq::config::config_cowboy_opts.empty {%>,
175+
{cowboy_opts, [<%- $rabbitmq::config::config_cowboy_opts.keys.sort.each |$k| { %>
176+
{<%= $k %>, <%= $rabbitmq::config::config_cowboy_opts[$k] %>}<% if $k != $rabbitmq::config::config_cowboy_opts.keys.sort[-1] { %>,<%- }} %>
177+
]}<%- } %>
168178
<%- } -%>
169179
]}
170180
<%- } -%>

0 commit comments

Comments
 (0)