Skip to content

Commit

Permalink
Merge pull request voxpupuli#1013 from SpinEternel/master
Browse files Browse the repository at this point in the history
Add support for cowboy_opts config in rabbitmq.config
  • Loading branch information
wyardley authored Sep 6, 2024
2 parents 1826818 + dd64088 commit 47be9d0
Show file tree
Hide file tree
Showing 5 changed files with 68 additions and 1 deletion.
9 changes: 9 additions & 0 deletions REFERENCE.md
Original file line number Diff line number Diff line change
Expand Up @@ -207,6 +207,7 @@ The following parameters are available in the `rabbitmq` class:
* [`config`](#-rabbitmq--config)
* [`config_additional_variables`](#-rabbitmq--config_additional_variables)
* [`config_cluster`](#-rabbitmq--config_cluster)
* [`config_cowboy_opts`](#-rabbitmq--config_cowboy_opts)
* [`config_kernel_variables`](#-rabbitmq--config_kernel_variables)
* [`config_path`](#-rabbitmq--config_path)
* [`config_ranch`](#-rabbitmq--config_ranch)
Expand Down Expand Up @@ -411,6 +412,14 @@ Enable or disable clustering support.

Default value: `false`

##### <a name="-rabbitmq--config_cowboy_opts"></a>`config_cowboy_opts`

Data type: `Hash`

Hash of additional configs (key / value) for `cowboy_opts` in rabbitmq.config.

Default value: `{}`

##### <a name="-rabbitmq--config_kernel_variables"></a>`config_kernel_variables`

Data type: `Hash`
Expand Down
1 change: 1 addition & 0 deletions manifests/config.pp
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
$cluster_nodes = $rabbitmq::cluster_nodes
$config = $rabbitmq::config
$config_cluster = $rabbitmq::config_cluster
$config_cowboy_opts = $rabbitmq::config_cowboy_opts
$config_path = $rabbitmq::config_path
$config_ranch = $rabbitmq::config_ranch
$config_stomp = $rabbitmq::config_stomp
Expand Down
3 changes: 3 additions & 0 deletions manifests/init.pp
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,8 @@
# Additional config variables in rabbitmq.config
# @param config_cluster
# Enable or disable clustering support.
# @param config_cowboy_opts
# Hash of additional configs (key / value) for `cowboy_opts` in rabbitmq.config.
# @param config_kernel_variables
# Hash of Erlang kernel configuration variables to set (see [Variables Configurable in rabbitmq.config](#variables-configurable-in-rabbitmq.config)).
# @param config_path
Expand Down Expand Up @@ -357,6 +359,7 @@
Enum['ram', 'disc'] $cluster_node_type = 'disc',
Array $cluster_nodes = [],
String $config = 'rabbitmq/rabbitmq.config.epp',
Hash $config_cowboy_opts = {},
Boolean $config_cluster = false,
Stdlib::Absolutepath $config_path = '/etc/rabbitmq/rabbitmq.config',
Boolean $config_ranch = true,
Expand Down
44 changes: 44 additions & 0 deletions spec/classes/rabbitmq_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -429,6 +429,50 @@
end
end

describe 'with config_cowboy_opts' do
context 'without SSL' do
let(:params) do
{
config_cowboy_opts: {
'max_request_line_length' => 16_000,
'max_keepalive' => 1000,
},
}
end

it 'sets expected cowboy config variables' do
is_expected.to contain_file('rabbitmq.config'). \
with_content(
%r{\{cowboy_opts, \[\n\s+\{max_keepalive, 1000\},\n\s+\{max_request_line_length, 16000\}}
)
end
end

context 'withSSL' do
let(:params) do
{
config_cowboy_opts: {
'max_request_line_length' => 16_003,
'max_keepalive' => 1002,
},
ssl: true,
ssl_port: 3141,
ssl_cacert: '/path/to/cacert',
ssl_cert: '/path/to/cert',
ssl_key: '/path/to/key',
ssl_versions: ['tlsv1.2', 'tlsv1.1'],
}
end

it 'sets expected cowboy config variables' do
is_expected.to contain_file('rabbitmq.config'). \
with_content(
%r{\{cowboy_opts, \[\n\s+\{max_keepalive, 1002\},\n\s+\{max_request_line_length, 16003\}}
)
end
end
end

describe 'rabbitmq-env configuration' do
context 'with default params' do
it 'sets environment variables' do
Expand Down
12 changes: 11 additions & 1 deletion templates/rabbitmq.config.epp
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,13 @@
{ip, "<%= $rabbitmq::config::management_ip_address %>"},
<%- } -%>
{port, <%= $rabbitmq::config::ssl_management_port %>},
<%- if !$rabbitmq::config::config_cowboy_opts.empty {-%>
{cowboy_opts, [
<%- $rabbitmq::config::config_cowboy_opts.keys.sort.each |$k| { -%>
{<%= $k %>, <%= $rabbitmq::config::config_cowboy_opts[$k] %>}<% if $k != $rabbitmq::config::config_cowboy_opts.keys.sort[-1] { %>,<%- } %>
<%- } -%>
]},
<%- } -%>
{ssl, true},
{ssl_opts, [
<%- if $rabbitmq::config::ssl_management_cacert {-%>
Expand Down Expand Up @@ -164,7 +171,10 @@
<%- if $rabbitmq::config::management_ip_address {-%>
{ip, "<%= $rabbitmq::config::management_ip_address %>"},
<%- } -%>
{port, <%= $rabbitmq::config::management_port %>}
{port, <%= $rabbitmq::config::management_port %>}<% if !$rabbitmq::config::config_cowboy_opts.empty {%>,
{cowboy_opts, [<%- $rabbitmq::config::config_cowboy_opts.keys.sort.each |$k| { %>
{<%= $k %>, <%= $rabbitmq::config::config_cowboy_opts[$k] %>}<% if $k != $rabbitmq::config::config_cowboy_opts.keys.sort[-1] { %>,<%- }} %>
]}<%- } %>
<%- } -%>
]}
<%- } -%>
Expand Down

0 comments on commit 47be9d0

Please sign in to comment.