Skip to content

Commit

Permalink
Merge pull request voxpupuli#365 from ragingdave/redis-sentinel-fix
Browse files Browse the repository at this point in the history
enable sentinel bind usage with multi ip
  • Loading branch information
bastelfreak committed Sep 22, 2020
2 parents b9f3e20 + 0adecdf commit 790755f
Show file tree
Hide file tree
Showing 3 changed files with 45 additions and 2 deletions.
2 changes: 2 additions & 0 deletions manifests/sentinel.pp
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,8 @@
}
}

$sentinel_bind_arr = delete_undef_values([$sentinel_bind].flatten)

file { $config_file_orig:
ensure => file,
owner => $service_user,
Expand Down
41 changes: 41 additions & 0 deletions spec/classes/redis_sentinel_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,47 @@
sentinel notification-script cow /path/to/bar.sh
sentinel client-reconfig-script cow /path/to/foo.sh
loglevel notice
logfile /tmp/barn-sentinel.log
CONFIG
end

it { is_expected.to compile.with_all_deps }
it { is_expected.to create_class('redis::sentinel') }
it { is_expected.to contain_file(config_file_orig).with_content(expected_content) }
end

describe 'with array sentinel bind' do
let(:params) do
{
auth_pass: 'password',
sentinel_bind: ['192.0.2.10', '192.168.1.1'],
master_name: 'cow',
down_after: 6000,
working_dir: '/tmp/redis',
log_file: '/tmp/barn-sentinel.log',
failover_timeout: 28_000,
notification_script: '/path/to/bar.sh',
client_reconfig_script: '/path/to/foo.sh'
}
end

let(:expected_content) do
<<CONFIG
bind 192.0.2.10 192.168.1.1
port 26379
dir /tmp/redis
daemonize #{facts[:osfamily] == 'RedHat' ? 'no' : 'yes'}
pidfile #{pidfile}
sentinel monitor cow 127.0.0.1 6379 2
sentinel down-after-milliseconds cow 6000
sentinel parallel-syncs cow 1
sentinel failover-timeout cow 28000
sentinel auth-pass cow password
sentinel notification-script cow /path/to/bar.sh
sentinel client-reconfig-script cow /path/to/foo.sh
loglevel notice
logfile /tmp/barn-sentinel.log
CONFIG
Expand Down
4 changes: 2 additions & 2 deletions templates/redis-sentinel.conf.erb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<% if @sentinel_bind -%>
bind <%= @sentinel_bind %>
<% unless @sentinel_bind_arr.empty? -%>
bind <%= @sentinel_bind_arr.join(' ') %>
<% end -%>
port <%= @sentinel_port %>
dir <%= @working_dir %>
Expand Down

0 comments on commit 790755f

Please sign in to comment.