Skip to content

Commit f7037f6

Browse files
authored
Merge pull request echocat#89 from obliadp/protected_mode
Protected mode
2 parents f29acea + 7b4c3f6 commit f7037f6

File tree

4 files changed

+24
-0
lines changed

4 files changed

+24
-0
lines changed

manifests/sentinel.pp

+10
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,11 @@
1515
# Path for pid file. Full pid path is <sentinel_pid_dir>/redis-sentinel_<redis_name>.pid. Default: /var/run
1616
# [*monitors*]
1717
# Default is
18+
#
19+
# [*protected_mode*]
20+
# If no password and/or no bind address is set, sentinel defaults to being reachable only
21+
# on the loopback interface. Turn this behaviour off by setting protected mode to 'no'.
22+
#
1823
# {
1924
# 'mymaster' => {
2025
# master_host => '127.0.0.1',
@@ -50,6 +55,7 @@
5055
$sentinel_log_dir = '/var/log',
5156
$sentinel_pid_dir = '/var/run',
5257
$sentinel_run_dir = '/var/run/redis',
58+
$protected_mode = undef,
5359
$monitors = {
5460
'mymaster' => {
5561
master_host => '127.0.0.1',
@@ -80,6 +86,10 @@
8086
validate_bool($enabled)
8187
validate_bool($manage_logrotate)
8288

89+
if $protected_mode {
90+
validate_re($protected_mode,['^no$', '^yes$'])
91+
}
92+
8393
$redis_install_dir = $::redis::install::redis_install_dir
8494
$sentinel_init_script = $::operatingsystem ? {
8595
/(Debian|Ubuntu)/ => 'redis/etc/init.d/debian_redis-sentinel.erb',

manifests/server.pp

+5
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,10 @@
7878
# [*hash_max_ziplist_value*]
7979
# Threshold for ziplist value. Default: 64
8080
#
81+
# [*protected_mode*]
82+
# If no password and/or no bind address is set, redis defaults to being reachable only
83+
# on the loopback interface. Turn this behaviour off by setting protected mode to 'no'.
84+
#
8185
# [*redis_run_dir*]
8286
#
8387
# Default: `/var/run/redis`
@@ -159,6 +163,7 @@
159163
$cluster_slave_validity_factor = undef,
160164
$cluster_migration_barrier = undef,
161165
$cluster_require_full_coverage = true,
166+
$protected_mode = undef,
162167
) {
163168
$redis_user = $::redis::install::redis_user
164169
$redis_group = $::redis::install::redis_group

templates/etc/redis.conf.erb

+4
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,10 @@ daemonize no
2222
daemonize yes
2323
<% end -%>
2424

25+
<% if @protected_mode then -%>
26+
protected-mode <%= @protected_mode %>
27+
<% end -%>
28+
2529
# When running daemonized, Redis writes a pid file in <%= @redis_pid_dir %>/redis.pid by
2630
# default. You can specify a custom pid file location here.
2731
pidfile <%= @redis_pid_dir %>/redis_<%= @redis_name %>.pid

templates/etc/sentinel.conf.erb

+5
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,11 @@ bind <%= @sentinel_ip %>
1818
<% end -%>
1919
port <%= @sentinel_port %>
2020

21+
<% if @protected_mode then -%>
22+
protected-mode <%= @protected_mode %>
23+
24+
<% end -%>
25+
2126
<%
2227
#rules = scope.lookupvar('redis::sentinel::monitors')
2328
@monitors.sort.each do |name, rule| -%>

0 commit comments

Comments
 (0)