From 4c1eb9db404859a1534a7d2c6490fff8c2b7d8c0 Mon Sep 17 00:00:00 2001 From: Jordan MARTIN Date: Wed, 4 Sep 2024 20:59:02 +0200 Subject: [PATCH 1/3] Add support for cowboy_opts config --- manifests/config.pp | 1 + manifests/init.pp | 5 ++++- templates/rabbitmq.config.epp | 12 +++++++++++- 3 files changed, 16 insertions(+), 2 deletions(-) diff --git a/manifests/config.pp b/manifests/config.pp index 2258a33d2..05b9aa4c2 100644 --- a/manifests/config.pp +++ b/manifests/config.pp @@ -10,6 +10,7 @@ $cluster_node_type = $rabbitmq::cluster_node_type $cluster_nodes = $rabbitmq::cluster_nodes $config = $rabbitmq::config + $config_cowboy_opts = $rabbitmq::config_cowboy_opts $config_cluster = $rabbitmq::config_cluster $config_path = $rabbitmq::config_path $config_ranch = $rabbitmq::config_ranch diff --git a/manifests/init.pp b/manifests/init.pp index aa942b982..ae19e58fc 100644 --- a/manifests/init.pp +++ b/manifests/init.pp @@ -137,6 +137,8 @@ # Additional config variables in rabbitmq.config # @param config_cluster # Enable or disable clustering support. +# @param config_cowboy_opts +# Additional config variables 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 @@ -356,7 +358,8 @@ Hash $cluster = $rabbitmq::cluster, Enum['ram', 'disc'] $cluster_node_type = 'disc', Array $cluster_nodes = [], - String $config = 'rabbitmq/rabbitmq.config.epp', + String $config + Hash $config_cowboy_opts = {}, = 'rabbitmq/rabbitmq.config.epp', Boolean $config_cluster = false, Stdlib::Absolutepath $config_path = '/etc/rabbitmq/rabbitmq.config', Boolean $config_ranch = true, diff --git a/templates/rabbitmq.config.epp b/templates/rabbitmq.config.epp index 3e9c40f70..c70c6b865 100644 --- a/templates/rabbitmq.config.epp +++ b/templates/rabbitmq.config.epp @@ -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 {-%> @@ -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] { %>,<%- }} %> + ]}<%- } %> <%- } -%> ]} <%- } -%> From 64cd92c66f69d430c9ebb9363af82f5f080093fd Mon Sep 17 00:00:00 2001 From: Jordan MARTIN Date: Wed, 4 Sep 2024 21:04:39 +0200 Subject: [PATCH 2/3] fix --- manifests/init.pp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/manifests/init.pp b/manifests/init.pp index ae19e58fc..a2c0c2815 100644 --- a/manifests/init.pp +++ b/manifests/init.pp @@ -358,8 +358,8 @@ Hash $cluster = $rabbitmq::cluster, Enum['ram', 'disc'] $cluster_node_type = 'disc', Array $cluster_nodes = [], - String $config - Hash $config_cowboy_opts = {}, = 'rabbitmq/rabbitmq.config.epp', + 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, From 00ef9a4640fd963699a0163552fd1b1f9976c129 Mon Sep 17 00:00:00 2001 From: William Yardley Date: Thu, 5 Sep 2024 21:08:51 -0700 Subject: [PATCH 3/3] updates for PR #1013 --- REFERENCE.md | 9 +++++++ manifests/config.pp | 2 +- manifests/init.pp | 2 +- spec/classes/rabbitmq_spec.rb | 44 +++++++++++++++++++++++++++++++++++ 4 files changed, 55 insertions(+), 2 deletions(-) diff --git a/REFERENCE.md b/REFERENCE.md index 5766cbb24..6edb6d4bc 100644 --- a/REFERENCE.md +++ b/REFERENCE.md @@ -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) @@ -411,6 +412,14 @@ Enable or disable clustering support. Default value: `false` +##### `config_cowboy_opts` + +Data type: `Hash` + +Hash of additional configs (key / value) for `cowboy_opts` in rabbitmq.config. + +Default value: `{}` + ##### `config_kernel_variables` Data type: `Hash` diff --git a/manifests/config.pp b/manifests/config.pp index 05b9aa4c2..3eef82ef7 100644 --- a/manifests/config.pp +++ b/manifests/config.pp @@ -10,8 +10,8 @@ $cluster_node_type = $rabbitmq::cluster_node_type $cluster_nodes = $rabbitmq::cluster_nodes $config = $rabbitmq::config - $config_cowboy_opts = $rabbitmq::config_cowboy_opts $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 diff --git a/manifests/init.pp b/manifests/init.pp index a2c0c2815..d27a681f3 100644 --- a/manifests/init.pp +++ b/manifests/init.pp @@ -138,7 +138,7 @@ # @param config_cluster # Enable or disable clustering support. # @param config_cowboy_opts -# Additional config variables for cowboy_opts in rabbitmq.config. +# 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 diff --git a/spec/classes/rabbitmq_spec.rb b/spec/classes/rabbitmq_spec.rb index 56d1c2cca..f2799420d 100644 --- a/spec/classes/rabbitmq_spec.rb +++ b/spec/classes/rabbitmq_spec.rb @@ -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