Skip to content

Commit 95a834d

Browse files
authored
Merge pull request voxpupuli#431 from cirrax/fix_add_custom_options
add custom options parameter to instance
2 parents e8ca35a + f5f2c61 commit 95a834d

File tree

4 files changed

+35
-0
lines changed

4 files changed

+35
-0
lines changed

REFERENCE.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2013,6 +2013,7 @@ The following parameters are available in the `redis::instance` defined type:
20132013
* [`acls`](#-redis--instance--acls)
20142014
* [`output_buffer_limit_slave`](#-redis--instance--output_buffer_limit_slave)
20152015
* [`output_buffer_limit_pubsub`](#-redis--instance--output_buffer_limit_pubsub)
2016+
* [`custom_options`](#-redis--instance--custom_options)
20162017

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

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

30263027
Default value: `$redis::output_buffer_limit_pubsub`
30273028

3029+
##### <a name="-redis--instance--custom_options"></a>`custom_options`
3030+
3031+
Data type: `Hash[String[1],Variant[String[1], Integer]]`
3032+
3033+
hash of custom options, not available as direct parameter.
3034+
3035+
Default value: `{}`
3036+
30283037
## Functions
30293038

30303039
### <a name="redis--get"></a>`redis::get`

manifests/instance.pp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -289,6 +289,9 @@
289289
# @param output_buffer_limit_pubsub
290290
# Value of client-output-buffer-limit-pubsub in redis config
291291
#
292+
# @param custom_options
293+
# hash of custom options, not available as direct parameter.
294+
#
292295
define redis::instance (
293296
Boolean $activerehashing = $redis::activerehashing,
294297
Boolean $aof_load_truncated = $redis::aof_load_truncated,
@@ -412,6 +415,7 @@
412415
Optional[Boolean] $jemalloc_bg_thread = $redis::jemalloc_bg_thread,
413416
Optional[Boolean] $rdb_save_incremental_fsync = $redis::rdb_save_incremental_fsync,
414417
Array[String[1]] $acls = $redis::acls,
418+
Hash[String[1],Variant[String[1], Integer]] $custom_options = {},
415419
) {
416420
if $title == 'default' {
417421
$redis_file_name_orig = $config_file_orig
@@ -604,6 +608,7 @@
604608
jemalloc_bg_thread => $jemalloc_bg_thread,
605609
rdb_save_incremental_fsync => $rdb_save_incremental_fsync,
606610
acls => $acls,
611+
custom_options => $custom_options,
607612
}
608613
),
609614
}

spec/defines/instance_spec.rb

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,23 @@ class { 'redis':
4949

5050
it { is_expected.to contain_service('redis-server-app2.service').with_ensure(true).with_enable(true) }
5151
end
52+
53+
context 'with custom options' do
54+
let(:title) { 'default' }
55+
let(:params) do
56+
{
57+
config_file_orig: '/tmp/myorig.conf',
58+
custom_options: { 'myoption' => 'avalue', 'anotheroption' => 'anothervalue' },
59+
}
60+
end
61+
62+
it do
63+
is_expected.to contain_file('/tmp/myorig.conf').
64+
with_content(%r{^bind 127.0.0.1}).
65+
with_content(%r{^myoption avalue}).
66+
with_content(%r{^anotheroption anothervalue})
67+
end
68+
end
5269
end
5370
end
5471
end

templates/redis.conf.epp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,7 @@
100100
Optional[Boolean] $jemalloc_bg_thread,
101101
Optional[Boolean] $rdb_save_incremental_fsync,
102102
Array[String[1]] $acls,
103+
Hash[String[1],Variant[String[1], Integer]] $custom_options,
103104
| -%>
104105
# Redis configuration file example
105106

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

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

11821186
################################## MODULES #####################################
11831187

0 commit comments

Comments
 (0)