Skip to content

Commit

Permalink
add replicaof parameter
Browse files Browse the repository at this point in the history
  • Loading branch information
Jonas Bartholomé committed Feb 2, 2023
1 parent 20d943a commit 35be44b
Show file tree
Hide file tree
Showing 4 changed files with 41 additions and 0 deletions.
3 changes: 3 additions & 0 deletions manifests/init.pp
Original file line number Diff line number Diff line change
Expand Up @@ -198,6 +198,8 @@
# but to INFO and SLAVEOF.
# @param slaveof
# Use slaveof to make a Redis instance a copy of another Redis server.
# @param replicaof
# Use replicaof to make a Redis instance a copy of another Redis server.
# @param slowlog_log_slower_than
# Tells Redis what is the execution time, in microseconds, to exceed in order
# for the command to get logged.
Expand Down Expand Up @@ -410,6 +412,7 @@
Boolean $slave_read_only = true,
Boolean $slave_serve_stale_data = true,
Optional[String[1]] $slaveof = undef,
Optional[String[1]] $replicaof = undef,
Integer[-1] $slowlog_log_slower_than = 10000,
Integer[0] $slowlog_max_len = 1024,
Boolean $stop_writes_on_bgsave_error = true,
Expand Down
4 changes: 4 additions & 0 deletions manifests/instance.pp
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,8 @@
# but to INFO and SLAVEOF.
# @param slaveof
# Use slaveof to make a Redis instance a copy of another Redis server.
# @param replicaof
# Use replicaof to make a Redis instance a copy of another Redis server.
# @param slowlog_log_slower_than
# Tells Redis what is the execution time, in microseconds, to exceed in order
# for the command to get logged.
Expand Down Expand Up @@ -336,6 +338,7 @@
Boolean $slave_read_only = $redis::slave_read_only,
Boolean $slave_serve_stale_data = $redis::slave_serve_stale_data,
Optional[String[1]] $slaveof = $redis::slaveof,
Optional[String[1]] $replicaof = $redis::replicaof,
Integer[-1] $slowlog_log_slower_than = $redis::slowlog_log_slower_than,
Integer[0] $slowlog_max_len = $redis::slowlog_max_len,
Boolean $stop_writes_on_bgsave_error = $redis::stop_writes_on_bgsave_error,
Expand Down Expand Up @@ -506,6 +509,7 @@
dbfilename => $dbfilename,
workdir => $workdir,
slaveof => $slaveof,
replicaof => $replicaof,
masterauth => $masterauth,
slave_serve_stale_data => $slave_serve_stale_data,
slave_read_only => $slave_read_only,
Expand Down
32 changes: 32 additions & 0 deletions spec/classes/redis_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -1148,6 +1148,38 @@ class { 'redis':
end
end

describe 'with parameter: replicaof' do
context 'binding to localhost' do
let(:params) do
{
bind: '127.0.0.1',
replicaof: '_VALUE_'
}
end

it {
is_expected.to contain_file(config_file_orig).with(
'content' => %r{^replicaof _VALUE_}
)
}
end

context 'binding to external ip' do
let(:params) do
{
bind: '10.0.0.1',
replicaof: '_VALUE_'
}
end

it {
is_expected.to contain_file(config_file_orig).with(
'content' => %r{^replicaof _VALUE_}
)
}
end
end

describe 'with parameter slowlog_log_slower_than' do
context 'set to a value great or equal to zero' do
let(:params) do
Expand Down
2 changes: 2 additions & 0 deletions templates/redis.conf.epp
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
Variant[String[1], Boolean] $dbfilename,
Stdlib::Absolutepath $workdir,
Optional[String[1]] $slaveof,
Optional[String[1]] $replicaof,
Optional[Variant[String[1], Sensitive[String[1]]]] $masterauth,
Boolean $slave_serve_stale_data,
Boolean $slave_read_only,
Expand Down Expand Up @@ -396,6 +397,7 @@ dir <%= $workdir %>
#
# slaveof <masterip> <masterport>
<% if $slaveof { -%>slaveof <%= $slaveof %><% } -%>
<% if $replicaof { -%>replicaof <%= $replicaof %><% } -%>

# If the master is password protected (using the "requirepass" configuration
# directive below) it is possible to tell the slave to authenticate before
Expand Down

0 comments on commit 35be44b

Please sign in to comment.