Skip to content

Commit

Permalink
Merge pull request #431 from cirrax/fix_add_custom_options
Browse files Browse the repository at this point in the history
add custom options parameter to instance
  • Loading branch information
bastelfreak authored Mar 12, 2024
2 parents e8ca35a + f5f2c61 commit 95a834d
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 0 deletions.
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

0 comments on commit 95a834d

Please sign in to comment.