Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add custom options parameter to instance #431

Merged
merged 3 commits into from
Mar 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions REFERENCE.md
Original file line number Diff line number Diff line change
Expand Up @@ -2013,6 +2013,7 @@ The following parameters are available in the `redis::instance` defined type:
* [`acls`](#-redis--instance--acls)
* [`output_buffer_limit_slave`](#-redis--instance--output_buffer_limit_slave)
* [`output_buffer_limit_pubsub`](#-redis--instance--output_buffer_limit_pubsub)
* [`custom_options`](#-redis--instance--custom_options)

##### <a name="-redis--instance--activerehashing"></a>`activerehashing`

Expand Down Expand Up @@ -3025,6 +3026,14 @@ Value of client-output-buffer-limit-pubsub in redis config

Default value: `$redis::output_buffer_limit_pubsub`

##### <a name="-redis--instance--custom_options"></a>`custom_options`

Data type: `Hash[String[1],Variant[String[1], Integer]]`

hash of custom options, not available as direct parameter.

Default value: `{}`

## Functions

### <a name="redis--get"></a>`redis::get`
Expand Down
5 changes: 5 additions & 0 deletions manifests/instance.pp
Original file line number Diff line number Diff line change
Expand Up @@ -289,6 +289,9 @@
# @param output_buffer_limit_pubsub
# Value of client-output-buffer-limit-pubsub in redis config
#
# @param custom_options
# hash of custom options, not available as direct parameter.
#
define redis::instance (
Boolean $activerehashing = $redis::activerehashing,
Boolean $aof_load_truncated = $redis::aof_load_truncated,
Expand Down Expand Up @@ -412,6 +415,7 @@
Optional[Boolean] $jemalloc_bg_thread = $redis::jemalloc_bg_thread,
Optional[Boolean] $rdb_save_incremental_fsync = $redis::rdb_save_incremental_fsync,
Array[String[1]] $acls = $redis::acls,
Hash[String[1],Variant[String[1], Integer]] $custom_options = {},
) {
if $title == 'default' {
$redis_file_name_orig = $config_file_orig
Expand Down Expand Up @@ -604,6 +608,7 @@
jemalloc_bg_thread => $jemalloc_bg_thread,
rdb_save_incremental_fsync => $rdb_save_incremental_fsync,
acls => $acls,
custom_options => $custom_options,
}
),
}
Expand Down
17 changes: 17 additions & 0 deletions spec/defines/instance_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,23 @@ class { 'redis':

it { is_expected.to contain_service('redis-server-app2.service').with_ensure(true).with_enable(true) }
end

context 'with custom options' do
let(:title) { 'default' }
let(:params) do
{
config_file_orig: '/tmp/myorig.conf',
custom_options: { 'myoption' => 'avalue', 'anotheroption' => 'anothervalue' },
}
end

it do
is_expected.to contain_file('/tmp/myorig.conf').
with_content(%r{^bind 127.0.0.1}).
with_content(%r{^myoption avalue}).
with_content(%r{^anotheroption anothervalue})
end
end
end
end
end
4 changes: 4 additions & 0 deletions templates/redis.conf.epp
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,7 @@
Optional[Boolean] $jemalloc_bg_thread,
Optional[Boolean] $rdb_save_incremental_fsync,
Array[String[1]] $acls,
Hash[String[1],Variant[String[1], Integer]] $custom_options,
| -%>
# Redis configuration file example

Expand Down Expand Up @@ -1178,6 +1179,9 @@ active-defrag-max-scan-fields <%= $active_defrag_max_scan_fields %>

# Jemalloc background thread for purging will be enabled by default
<% if $jemalloc_bg_thread { -%>jemalloc-bg-thread <%= $jemalloc_bg_thread ? {true => 'yes', default => 'no'} %><% } -%>
<% $custom_options.each |String $k, String $v| { -%>
<%= $k %> <%= $v %>
<% } -%>

################################## MODULES #####################################

Expand Down