Skip to content
This repository has been archived by the owner on Mar 8, 2023. It is now read-only.

Sentinel config rewrite restart fix #22

Merged
merged 3 commits into from
May 7, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -362,6 +362,12 @@ Listen port of Redis. Default: 6379
Default is '/var/log' (string).
Path for log. Full log path is `sentinel_log_dir`/sentinel_`sentinel_name`.log.

#####`sentinel_pid_dir`

Default is '/var/run' (string).
Path for pid file. Full pid file path is `sentinel_pid_dir`/sentinel_`sentinel_name`.pid.


#####`monitors`

Default is
Expand Down Expand Up @@ -391,6 +397,15 @@ Configure if Redis should be running or not. Default: true (boolean)

Configure if Redis is started at boot. Default: true (boolean)

#####`force_rewrite`

Boolean. Default: `false`

Configure if the sentinels config is overwritten by puppet followed by a
sentinel restart. Since sentinels automatically rewrite their config since
version 2.8 setting this to `true` will trigger a sentinel restart on each puppet
run with redis 2.8 or later.

##Requirements

###Modules needed:
Expand Down
19 changes: 18 additions & 1 deletion manifests/sentinel.pp
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@
# Listen port of Redis. Default: 26379
# [*sentinel_log_dir*]
# Path for log. Full log path is <sentinel_log_dir>/redis-sentinel_<redis_name>.log. Default: /var/log
# [*sentinel_pid_dir*]
# Path for pid file. Full pid path is <sentinel_pid_dir>/redis-sentinel_<redis_name>.pid. Default: /var/run
# [*monitors*]
# Default is
# {
Expand All @@ -30,12 +32,21 @@
# Configure if Sentinel should be running or not. Default: true
# [*enabled*]
# Configure if Sentinel is started at boot. Default: true
# [*force_rewrite*]
#
# Boolean. Default: `false`
#
# Configure if the sentinels config is overwritten by puppet followed by a
# sentinel restart. Since sentinels automatically rewrite their config since
# version 2.8 setting this to `true` will trigger a sentinel restart on each puppet
# run with redis 2.8 or later.
#
define redis::sentinel (
$ensure = 'present',
$sentinel_name = $name,
$sentinel_port = 26379,
$sentinel_log_dir = '/var/log',
$sentinel_pid_dir = '/var/run',
$monitors = {
'mymaster' => {
master_host => '127.0.0.1',
Expand All @@ -51,9 +62,13 @@
}
},
$running = true,
$enabled = true
$enabled = true,
$force_rewrite = false,
) {

# validate parameters
validate_bool($force_rewrite)

$redis_install_dir = $::redis::install::redis_install_dir
$sentinel_init_script = $::operatingsystem ? {
/(Debian|Ubuntu)/ => 'redis/etc/init.d/debian_redis-sentinel.erb',
Expand All @@ -66,7 +81,9 @@
"/etc/redis-sentinel_${sentinel_name}.conf":
ensure => file,
content => template('redis/etc/sentinel.conf.erb'),
replace => $force_rewrite,
require => Class['redis::install'];

}->

# startup script
Expand Down
4 changes: 2 additions & 2 deletions templates/etc/init.d/debian_redis-sentinel.erb
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,14 @@
# description: Redis Sentinel is a monitor for redis servers
# processname: redis-sentinel
# config: /etc/redis-sentinel_<%= @sentinel_name %>.conf
# pidfile: <%= @redis_pid_dir %>/redis-sentinel_<%= @sentinel_name %>.pid
# pidfile: <%= @sentinel_pid_dir %>/redis-sentinel_<%= @sentinel_name %>.pid

# Source function library.
. /lib/lsb/init-functions

REDIS_EXEC="<%= @redis_install_dir %>/redis-sentinel"
REDIS_NAME="redis-sentinel_<%= @sentinel_name %>"
REDIS_PID="<%= @redis_pid_dir %>/redis-sentinel_<%= @sentinel_name %>.pid"
REDIS_PID="<%= @sentinel_pid_dir %>/redis-sentinel_<%= @sentinel_name %>.pid"
REDIS_LOCKFILE="/var/lock/redis-sentinel_<%= @sentinel_name %>"
REDIS_CONF_FILE="/etc/redis-sentinel_<%= @sentinel_name %>.conf"

Expand Down
6 changes: 3 additions & 3 deletions templates/etc/init.d/redhat_redis-sentinel.erb
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
# processname: redis-server
# config: /etc/redis-sentinel_<%= @sentinel_name %>.conf
# config: /etc/sysconfig/redis
# pidfile: <%= @redis_pid_dir %>/redis-sentinel_<%= @sentinel_name %>.pid
# pidfile: <%= @sentinel_pid_dir %>/redis-sentinel_<%= @sentinel_name %>.pid

# Source function library.
. /etc/rc.d/init.d/functions
Expand All @@ -20,8 +20,8 @@

sentinel="<%= @redis_install_dir %>/redis-sentinel"
prog="redis-sentinel_<%= @sentinel_name %>"
pidfile="<%= @redis_pid_dir %>/redis-sentinel_<%= @sentinel_name %>.pid"
logfile="<%= @log_dir -%>/redis-sentinel_<%= @sentinel_name %>.log"
pidfile="<%= @sentinel_pid_dir %>/redis-sentinel_<%= @sentinel_name %>.pid"
logfile="<%= @sentinel_log_dir -%>/redis-sentinel_<%= @sentinel_name %>.log"

SENTINEL_CONF_FILE="/etc/redis-sentinel_<%= @sentinel_name %>.conf"

Expand Down