Skip to content

Commit

Permalink
Add support for notification-script in sentinel
Browse files Browse the repository at this point in the history
This commit add support for the configuration of a notification-script
in a redis-sentinel.
  • Loading branch information
Spredzy committed Feb 9, 2015
1 parent 821f596 commit 14df360
Show file tree
Hide file tree
Showing 4 changed files with 88 additions and 77 deletions.
103 changes: 52 additions & 51 deletions manifests/params.pp
Original file line number Diff line number Diff line change
Expand Up @@ -7,57 +7,58 @@
$manage_repo = false

# redis.conf.erb
$activerehashing = true
$appendfsync = 'everysec'
$appendonly = false
$auto_aof_rewrite_min_size = '64min'
$auto_aof_rewrite_percentage = 100
$bind = '127.0.0.1'
$conf_template = 'redis/redis.conf.erb'
$databases = 16
$dbfilename = 'dump.rdb'
$extra_config_file = undef
$hash_max_ziplist_entries = 512
$hash_max_ziplist_value = 64
$list_max_ziplist_entries = 512
$list_max_ziplist_value = 64
$log_dir = '/var/log/redis'
$log_file = '/var/log/redis/redis.log'
$log_level = 'notice'
$maxclients = 10000
$maxmemory = undef
$maxmemory_policy = undef
$maxmemory_samples = undef
$no_appendfsync_on_rewrite = false
$notify_service = true
$pid_file = '/var/run/redis/redis-server.pid'
$port = 6379
$rdbcompression = true
$requirepass = undef
$sentinel_config_file_mode = '0644'
$sentinel_config_group = 'root'
$sentinel_config_owner = 'redis'
$sentinel_conf_template = 'redis/redis-sentinel.conf.erb'
$sentinel_down_after = 30000
$sentinel_failover_timeout = 180000
$sentinel_master_name = 'mymaster'
$sentinel_parallel_sync = 1
$sentinel_port = 26379
$sentinel_quorum = 2
$sentinel_service_name = 'redis-sentinel'
$sentinel_working_dir = '/tmp'
$sentinel_init_template = 'redis/redis-sentinel.init.erb'
$sentinel_pid_file = '/var/run/redis/redis-sentinel.pid'
$set_max_intset_entries = 512
$slowlog_log_slower_than = 10000
$slowlog_max_len = 1024
$syslog_enabled = undef
$syslog_facility = undef
$timeout = 0
$ulimit = 65536
$workdir = '/var/lib/redis/'
$zset_max_ziplist_entries = 128
$zset_max_ziplist_value = 64
$activerehashing = true
$appendfsync = 'everysec'
$appendonly = false
$auto_aof_rewrite_min_size = '64min'
$auto_aof_rewrite_percentage = 100
$bind = '127.0.0.1'
$conf_template = 'redis/redis.conf.erb'
$databases = 16
$dbfilename = 'dump.rdb'
$extra_config_file = undef
$hash_max_ziplist_entries = 512
$hash_max_ziplist_value = 64
$list_max_ziplist_entries = 512
$list_max_ziplist_value = 64
$log_dir = '/var/log/redis'
$log_file = '/var/log/redis/redis.log'
$log_level = 'notice'
$maxclients = 10000
$maxmemory = undef
$maxmemory_policy = undef
$maxmemory_samples = undef
$no_appendfsync_on_rewrite = false
$notify_service = true
$pid_file = '/var/run/redis/redis-server.pid'
$port = 6379
$rdbcompression = true
$requirepass = undef
$sentinel_config_file_mode = '0644'
$sentinel_config_group = 'root'
$sentinel_config_owner = 'redis'
$sentinel_conf_template = 'redis/redis-sentinel.conf.erb'
$sentinel_down_after = 30000
$sentinel_failover_timeout = 180000
$sentinel_master_name = 'mymaster'
$sentinel_parallel_sync = 1
$sentinel_port = 26379
$sentinel_quorum = 2
$sentinel_service_name = 'redis-sentinel'
$sentinel_working_dir = '/tmp'
$sentinel_init_template = 'redis/redis-sentinel.init.erb'
$sentinel_pid_file = '/var/run/redis/redis-sentinel.pid'
$sentinel_notification_script = undef
$set_max_intset_entries = 512
$slowlog_log_slower_than = 10000
$slowlog_max_len = 1024
$syslog_enabled = undef
$syslog_facility = undef
$timeout = 0
$ulimit = 65536
$workdir = '/var/lib/redis/'
$zset_max_ziplist_entries = 128
$zset_max_ziplist_value = 64

# redis.conf.erb - replication
$masterauth = undef
Expand Down
49 changes: 27 additions & 22 deletions manifests/sentinel.pp
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,10 @@
#
# Default: /tmp
#
# [*notification_script*]
# Path to the notification script
#
# Default: undef
# == Actions:
# - Install and configure Redis Sentinel
#
Expand All @@ -134,28 +138,29 @@
# }
#
class redis::sentinel (
$config_file = $::redis::params::sentinel_config_file,
$config_file_orig = $::redis::params::sentinel_config_file_orig,
$config_file_mode = $::redis::params::sentinel_config_file_mode,
$conf_template = $::redis::params::sentinel_conf_template,
$down_after = $::redis::params::sentinel_down_after,
$failover_timeout = $::redis::params::sentinel_failover_timeout,
$init_script = $::redis::params::sentinel_init_script,
$init_template = $::redis::params::sentinel_init_template,
$log_file = $::redis::params::log_file,
$master_name = $::redis::params::sentinel_master_name,
$redis_host = $::redis::params::bind,
$redis_port = $::redis::params::port,
$package_name = $::redis::params::sentinel_package_name,
$package_ensure = $::redis::params::sentinel_package_ensure,
$parallel_sync = $::redis::params::sentinel_parallel_sync,
$pid_file = $::redis::params::sentinel_pid_file,
$quorum = $::redis::params::sentinel_quorum,
$sentinel_port = $::redis::params::sentinel_port,
$service_group = $::redis::params::service_group,
$service_name = $::redis::params::sentinel_service_name,
$service_user = $::redis::params::service_user,
$working_dir = $::redis::params::sentinel_working_dir,
$config_file = $::redis::params::sentinel_config_file,
$config_file_orig = $::redis::params::sentinel_config_file_orig,
$config_file_mode = $::redis::params::sentinel_config_file_mode,
$conf_template = $::redis::params::sentinel_conf_template,
$down_after = $::redis::params::sentinel_down_after,
$failover_timeout = $::redis::params::sentinel_failover_timeout,
$init_script = $::redis::params::sentinel_init_script,
$init_template = $::redis::params::sentinel_init_template,
$log_file = $::redis::params::log_file,
$master_name = $::redis::params::sentinel_master_name,
$redis_host = $::redis::params::bind,
$redis_port = $::redis::params::port,
$package_name = $::redis::params::sentinel_package_name,
$package_ensure = $::redis::params::sentinel_package_ensure,
$parallel_sync = $::redis::params::sentinel_parallel_sync,
$pid_file = $::redis::params::sentinel_pid_file,
$quorum = $::redis::params::sentinel_quorum,
$sentinel_port = $::redis::params::sentinel_port,
$service_group = $::redis::params::service_group,
$service_name = $::redis::params::sentinel_service_name,
$service_user = $::redis::params::service_user,
$working_dir = $::redis::params::sentinel_working_dir,
$notification_script = $::redis::params::sentinel_notification_script,
) inherits redis::params {


Expand Down
10 changes: 6 additions & 4 deletions spec/classes/redis_sentinel_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
sentinel down-after-milliseconds cow 6000
sentinel parallel-syncs cow 1
sentinel failover-timeout cow 28000
sentinel notification-script cow bar.sh
logfile /tmp/barn-sentinel.log
EOF
Expand Down Expand Up @@ -62,10 +63,11 @@
describe 'with custom parameters' do
let (:params) {
{
:master_name => 'cow',
:down_after => 6000,
:log_file => '/tmp/barn-sentinel.log',
:failover_timeout => 28000
:master_name => 'cow',
:down_after => 6000,
:log_file => '/tmp/barn-sentinel.log',
:failover_timeout => 28000,
:notification_script => 'bar.sh'
}
}

Expand Down
3 changes: 3 additions & 0 deletions templates/redis-sentinel.conf.erb
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,8 @@ sentinel monitor <%= @master_name %> <%= @redis_host %> <%= @redis_port %> <%= @
sentinel down-after-milliseconds <%= @master_name %> <%= @down_after %>
sentinel parallel-syncs <%= @master_name %> <%= @parallel_sync %>
sentinel failover-timeout <%= @master_name %> <%= @failover_timeout %>
<% if @notification_script -%>
sentinel notification-script <%= @master_name %> <%= @notification_script %>
<% end -%>

logfile <%= @log_file %>

0 comments on commit 14df360

Please sign in to comment.