Showing with 149 additions and 93 deletions.
  1. +21 −13 manifests/init.pp
  2. +77 −51 manifests/params.pp
  3. +36 −24 manifests/sentinel.pp
  4. +1 −1 metadata.json
  5. +8 −4 spec/classes/redis_sentinel_spec.rb
  6. +6 −0 templates/redis-sentinel.conf.erb
34 changes: 21 additions & 13 deletions manifests/init.pp
Original file line number Diff line number Diff line change
Expand Up @@ -417,21 +417,29 @@
$zset_max_ziplist_entries = $::redis::params::zset_max_ziplist_entries,
$zset_max_ziplist_value = $::redis::params::zset_max_ziplist_value,
) inherits redis::params {
include preinstall
include install
include config
include service

anchor { 'redis::begin': }
anchor { 'redis::end': }

include redis::preinstall
include redis::install
include redis::config
include redis::service

if $::redis::notify_service {
Class['preinstall'] ->
Class['install'] ->
Class['config'] ~>
Class['service']
Anchor['redis::begin'] ->
Class['redis::preinstall'] ->
Class['redis::install'] ->
Class['redis::config'] ~>
Class['redis::service'] ->
Anchor['redis::end']
} else {
Class['preinstall'] ->
Class['install'] ->
Class['config'] ->
Class['service']
Anchor['redis::begin'] ->
Class['redis::preinstall'] ->
Class['redis::install'] ->
Class['redis::config'] ->
Class['redis::service'] ->
Anchor['redis::end']
}

# Sanity check
Expand All @@ -440,5 +448,5 @@
fail "Replication is not possible when binding to ${::redis::bind}."
}
}
}

}
128 changes: 77 additions & 51 deletions manifests/params.pp
Original file line number Diff line number Diff line change
Expand Up @@ -7,57 +7,59 @@
$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_auth_pass = 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 Expand Up @@ -117,6 +119,30 @@
$service_user = 'redis'
}

'FreeBSD': {
$config_dir = '/usr/local/etc/redis'
$config_dir_mode = '0755'
$config_file = '/usr/local/etc/redis.conf'
$config_file_mode = '0644'
$config_group = 'wheel'
$config_owner = 'root'
$daemonize = true
$package_ensure = 'present'
$package_name = 'redis'
$sentinel_config_file = '/usr/local/etc/redis-sentinel.conf'
$sentinel_config_file_orig = '/usr/local/etc/redis-sentinel.conf.puppet'
$sentinel_init_script = undef
$sentinel_package_name = 'redis'
$sentinel_package_ensure = 'present'
$service_enable = true
$service_ensure = 'running'
$service_group = 'redis'
$service_hasrestart = true
$service_hasstatus = true
$service_name = 'redis'
$service_user = 'redis'
}

default: {
fail "Operating system ${::operatingsystem} is not supported yet."
}
Expand Down
60 changes: 36 additions & 24 deletions manifests/sentinel.pp
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,12 @@
#
# == Parameters:
#
#
# [*auth_pass*]
# The password to use to authenticate with the master and slaves.
#
# Default: undef
#
# [*config_file*]
# The location and name of the sentinel config file.
#
Expand Down Expand Up @@ -121,6 +127,10 @@
#
# Default: /tmp
#
# [*notification_script*]
# Path to the notification script
#
# Default: undef
# == Actions:
# - Install and configure Redis Sentinel
#
Expand All @@ -134,28 +144,30 @@
# }
#
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,
$auth_pass = $::redis::params::sentinel_auth_pass,
$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 Expand Up @@ -192,8 +204,8 @@
require => Package[$package_name];
}
exec {
"/usr/sbin/update-rc.d redis-sentinel defaults":
require => File[$init_script];
'/usr/sbin/update-rc.d redis-sentinel defaults':
require => File[$init_script];
}
}

Expand Down
2 changes: 1 addition & 1 deletion metadata.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "arioch-redis",
"version": "1.0.4",
"version": "1.0.5",
"author": "Tom De Vylder",
"summary": "Redis module",
"license": "Apache License, Version 2.0",
Expand Down
12 changes: 8 additions & 4 deletions spec/classes/redis_sentinel_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@
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 bar.sh
logfile /tmp/barn-sentinel.log
EOF
Expand Down Expand Up @@ -62,10 +64,12 @@
describe 'with custom parameters' do
let (:params) {
{
:master_name => 'cow',
:down_after => 6000,
:log_file => '/tmp/barn-sentinel.log',
:failover_timeout => 28000
:auth_pass => 'password',
:master_name => 'cow',
:down_after => 6000,
:log_file => '/tmp/barn-sentinel.log',
:failover_timeout => 28000,
:notification_script => 'bar.sh'
}
}

Expand Down
6 changes: 6 additions & 0 deletions templates/redis-sentinel.conf.erb
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,11 @@ 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 @auth_pass -%>
sentinel auth-pass <%= @master_name %> <%= @auth_pass %>
<% end -%>
<% if @notification_script -%>
sentinel notification-script <%= @master_name %> <%= @notification_script %>
<% end -%>

logfile <%= @log_file %>