Skip to content

Commit

Permalink
Stricter data types
Browse files Browse the repository at this point in the history
This sets data types for most parameters that previously had none. It
also moves static defaults from params.pp to inline. While this
duplicates a few between Redis and the sentinel, the user would already
need to know these were linked. The benefit is a much more readable
reference documentation.
  • Loading branch information
ekohl committed Nov 21, 2019
1 parent 3973808 commit 502ff38
Show file tree
Hide file tree
Showing 11 changed files with 982 additions and 977 deletions.
678 changes: 332 additions & 346 deletions REFERENCE.md

Large diffs are not rendered by default.

18 changes: 11 additions & 7 deletions manifests/administration.pp
Original file line number Diff line number Diff line change
Expand Up @@ -9,16 +9,20 @@
# disable_thp => false,
# }
#
# @param [Boolean] enable_overcommit_memory Enable the overcommit memory setting (Defaults to true)
# @param [Boolean] disable_thp Disable Transparent Huge Pages (Defaults to true)
# @param [String] somaxconn Set somaxconn value (Defaults to '65535')
# @param enable_overcommit_memory
# Enable the overcommit memory setting
# @param disable_thp
# Disable Transparent Huge Pages
# @param somaxconn
# Set somaxconn value
#
# @author - Peter Souter
# @see https://redis.io/topics/admin
#
class redis::administration(
$enable_overcommit_memory = true,
$disable_thp = true,
$somaxconn = '65535',
Boolean $enable_overcommit_memory = true,
Boolean $disable_thp = true,
Integer[0] $somaxconn = 65535,
) {

if $enable_overcommit_memory {
Expand All @@ -37,7 +41,7 @@
}
}

if $somaxconn {
if $somaxconn > 0 {
sysctl { 'net.core.somaxconn':
ensure => 'present',
value => $somaxconn,
Expand Down
514 changes: 295 additions & 219 deletions manifests/init.pp

Large diffs are not rendered by default.

437 changes: 251 additions & 186 deletions manifests/instance.pp

Large diffs are not rendered by default.

134 changes: 0 additions & 134 deletions manifests/params.pp
Original file line number Diff line number Diff line change
@@ -1,120 +1,26 @@
# @summary This class provides a number of parameters.
# @api private
class redis::params {
# Generic
$manage_repo = false
$manage_package = true
$managed_by_cluster_manager = false

# redis.conf.erb
$activerehashing = true
$aof_load_truncated = true
$aof_rewrite_incremental_fsync = true
$appendfilename = 'appendonly.aof'
$appendfsync = 'everysec'
$appendonly = false
$auto_aof_rewrite_min_size = '64mb'
$auto_aof_rewrite_percentage = 100
$bind = ['127.0.0.1']
$output_buffer_limit_slave = '256mb 64mb 60'
$output_buffer_limit_pubsub = '32mb 8mb 60'
$conf_template = 'redis/redis.conf.erb'
$default_install = true
$databases = 16
$dbfilename = 'dump.rdb'
$extra_config_file = undef
$hash_max_ziplist_entries = 512
$hash_max_ziplist_value = 64
$hll_sparse_max_bytes = 3000
$hz = 10
$latency_monitor_threshold = 0
$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'
$manage_service_file = false
$maxclients = 10000
$maxmemory = undef
$maxmemory_policy = undef
$maxmemory_samples = undef
$no_appendfsync_on_rewrite = false
$notify_keyspace_events = undef
$notify_service = true
$port = 6379
$protected_mode = 'yes'
$rdbcompression = true
$requirepass = undef
$save_db_to_disk = true
$save_db_to_disk_interval = {'900' =>'1', '300' => '10', '60' => '10000'}
$service_provider = undef
$set_max_intset_entries = 512
$slave_priority = 100
$slowlog_log_slower_than = 10000
$slowlog_max_len = 1024
$stop_writes_on_bgsave_error = true
$syslog_enabled = undef
$syslog_facility = undef
$tcp_backlog = 511
$tcp_keepalive = 0
$timeout = 0
$ulimit = 65536
$unixsocket = '/var/run/redis/redis.sock'
$unixsocketperm = 755
$zset_max_ziplist_entries = 128
$zset_max_ziplist_value = 64

# redis.conf.erb - replication
$masterauth = undef
$min_slaves_to_write = 0
$min_slaves_max_lag = 10
$repl_backlog_size = '1mb'
$repl_backlog_ttl = 3600
$repl_disable_tcp_nodelay = false
$repl_ping_slave_period = 10
$repl_timeout = 60
$slave_read_only = true
$slave_serve_stale_data = true
$slaveof = undef

# redis.conf.erb - redis 3.0 clustering
$cluster_enabled = false
$cluster_config_file = 'nodes.conf'
$cluster_node_timeout = 5000
$cluster_slave_validity_factor = 0
$cluster_require_full_coverage = true
$cluster_migration_barrier = 1

case $::osfamily {
'Debian': {
$config_dir = '/etc/redis'
$config_dir_mode = '0755'
$config_file = '/etc/redis/redis.conf'
$config_file_mode = '0644'
$config_file_orig = '/etc/redis/redis.conf.puppet'

$config_owner = 'redis'
$daemonize = true
$log_dir_mode = '0755'
$package_ensure = 'present'
$package_name = 'redis-server'
$pid_file = '/var/run/redis/redis-server.pid'
$sentinel_config_file = '/etc/redis/sentinel.conf'
$sentinel_config_file_orig = '/etc/redis/redis-sentinel.conf.puppet'
$sentinel_daemonize = true
$sentinel_init_script = '/etc/init.d/redis-sentinel'
$sentinel_package_name = 'redis-sentinel'
$service_manage = true
$service_enable = true
$service_ensure = 'running'
$service_group = 'redis'
$service_hasrestart = true
$service_hasstatus = true
$service_name = 'redis-server'
$service_user = 'redis'
$ppa_repo = 'ppa:chris-lea/redis-server'
$workdir = '/var/lib/redis'
$workdir_mode = '0750'

case $facts['os']['name'] {
'Ubuntu': {
Expand All @@ -136,30 +42,20 @@
$config_dir = '/etc/redis'
$config_dir_mode = '0755'
$config_file = '/etc/redis.conf'
$config_file_mode = '0644'
$config_file_orig = '/etc/redis.conf.puppet'
$config_group = 'root'
$config_owner = 'redis'
$daemonize = true
$log_dir_mode = '0755'
$package_ensure = 'present'
$package_name = 'redis'
$pid_file = '/var/run/redis/redis.pid'
$sentinel_config_file = '/etc/redis-sentinel.conf'
$sentinel_config_file_orig = '/etc/redis-sentinel.conf.puppet'
$sentinel_daemonize = false
$sentinel_init_script = undef
$sentinel_package_name = 'redis'
$service_manage = true
$service_enable = true
$service_ensure = 'running'
$service_hasrestart = true
$service_hasstatus = true
$service_name = 'redis'
$service_user = 'redis'
$ppa_repo = undef
$workdir = '/var/lib/redis'
$workdir_mode = '0755'

# EPEL 6 and newer have 3.2 so we can assume all EL is 3.2+
$minimum_version = '3.2.10'
Expand All @@ -174,31 +70,21 @@
$config_dir = '/usr/local/etc/redis'
$config_dir_mode = '0755'
$config_file = '/usr/local/etc/redis.conf'
$config_file_mode = '0644'
$config_file_orig = '/usr/local/etc/redis.conf.puppet'
$config_group = 'wheel'
$config_owner = 'redis'
$daemonize = true
$log_dir_mode = '0755'
$package_ensure = 'present'
$package_name = 'redis'
$pid_file = '/var/run/redis/redis.pid'
$sentinel_config_file = '/usr/local/etc/redis-sentinel.conf'
$sentinel_config_file_orig = '/usr/local/etc/redis-sentinel.conf.puppet'
$sentinel_daemonize = true
$sentinel_init_script = undef
$sentinel_package_name = 'redis'
$service_manage = true
$service_enable = true
$service_ensure = 'running'
$service_group = 'redis'
$service_hasrestart = true
$service_hasstatus = true
$service_name = 'redis'
$service_user = 'redis'
$ppa_repo = undef
$workdir = '/var/db/redis'
$workdir_mode = '0750'

# pkg version
$minimum_version = '3.2.4'
Expand All @@ -208,30 +94,20 @@
$config_dir = '/etc/redis'
$config_dir_mode = '0750'
$config_file = '/etc/redis/redis-server.conf'
$config_file_mode = '0644'
$config_group = 'redis'
$config_owner = 'redis'
$daemonize = true
$log_dir_mode = '0750'
$package_ensure = 'present'
$package_name = 'redis'
$pid_file = '/var/run/redis/redis-server.pid'
$sentinel_config_file = '/etc/redis/redis-sentinel.conf'
$sentinel_config_file_orig = '/etc/redis/redis-sentinel.conf.puppet'
$sentinel_daemonize = true
$sentinel_init_script = undef
$sentinel_package_name = 'redis'
$service_manage = true
$service_enable = true
$service_ensure = 'running'
$service_group = 'redis'
$service_hasrestart = true
$service_hasstatus = true
$service_name = 'redis'
$service_user = 'redis'
$ppa_repo = undef
$workdir = '/var/lib/redis'
$workdir_mode = '0750'

# suse package version
$minimum_version = '3.0.5'
Expand All @@ -241,31 +117,21 @@
$config_dir = '/etc/redis'
$config_dir_mode = '0755'
$config_file = '/etc/redis/redis.conf'
$config_file_mode = '0644'
$config_file_orig = '/etc/redis/redis.conf.puppet'
$config_group = 'root'
$config_owner = 'root'
$daemonize = true
$log_dir_mode = '0755'
$package_ensure = 'present'
$package_name = 'redis'
$pid_file = '/var/run/redis.pid'
$sentinel_config_file = '/etc/redis/redis-sentinel.conf'
$sentinel_config_file_orig = '/etc/redis/redis-sentinel.conf.puppet'
$sentinel_daemonize = true
$sentinel_init_script = undef
$sentinel_package_name = 'redis'
$service_manage = true
$service_enable = true
$service_ensure = 'running'
$service_group = 'redis'
$service_hasrestart = true
$service_hasstatus = true
$service_name = 'redis'
$service_user = 'redis'
$ppa_repo = undef
$workdir = '/var/lib/redis'
$workdir_mode = '0750'

# pkg version
$minimum_version = '3.2.4'
Expand Down
42 changes: 21 additions & 21 deletions manifests/sentinel.pp
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@
# @param service_name
# The name of the service (for puppet to manage).
#
# @param service_owner
# @param service_user
# The owner of the config file.
#
# @param service_enable
Expand All @@ -105,36 +105,36 @@
# }
#
class redis::sentinel (
$auth_pass = undef,
$config_file = $redis::params::sentinel_config_file,
$config_file_orig = $redis::params::sentinel_config_file_orig,
Optional[String[1]] $auth_pass = undef,
Stdlib::Absolutepath $config_file = $redis::params::sentinel_config_file,
Stdlib::Absolutepath $config_file_orig = $redis::params::sentinel_config_file_orig,
Stdlib::Filemode $config_file_mode = '0644',
String[1] $conf_template = 'redis/redis-sentinel.conf.erb',
$daemonize = $redis::params::sentinel_daemonize,
$down_after = 30000,
$failover_timeout = 180000,
$init_script = $redis::params::sentinel_init_script,
Boolean $daemonize = $redis::params::sentinel_daemonize,
Integer[1] $down_after = 30000,
Integer[1] $failover_timeout = 180000,
Optional[Stdlib::Absolutepath] $init_script = $redis::params::sentinel_init_script,
String[1] $init_template = 'redis/redis-sentinel.init.erb',
$log_level = $redis::params::log_level,
$log_file = $redis::params::log_file,
Redis::LogLevel $log_level = 'notice',
Stdlib::Absolutepath $log_file = '/var/log/redis/redis.log',
String[1] $master_name = 'mymaster',
Stdlib::Host $redis_host = '127.0.0.1',
Stdlib::Port $redis_port = $redis::params::port,
$package_name = $redis::params::sentinel_package_name,
Stdlib::Port::Unprivileged $redis_port = 6379,
String[1] $package_name = $redis::params::sentinel_package_name,
String[1] $package_ensure = 'present',
Integer[0] $parallel_sync = 1,
Stdlib::Absolutepath $pid_file = '/var/run/redis/redis-sentinel.pid',
Integer[0] $quorum = 2,
$sentinel_bind = undef,
Stdlib::Port $sentinel_port = 26379,
$service_group = $redis::params::service_group,
Integer[1] $quorum = 2,
Variant[Undef, Stdlib::IP::Address, Array[Stdlib::IP::Address]] $sentinel_bind = undef,
Stdlib::Port::Unprivileged $sentinel_port = 26379,
String[1] $service_group = $redis::params::service_group,
String[1] $service_name = 'redis-sentinel',
$service_ensure = $redis::params::service_ensure,
Boolean $service_enable = $redis::params::service_enable,
$service_user = $redis::params::service_user,
Stdlib::Ensure::Service $service_ensure = 'running',
Boolean $service_enable = true,
String[1] $service_user = 'redis',
Stdlib::Absolutepath $working_dir = '/tmp',
$notification_script = undef,
$client_reconfig_script = undef,
Optional[Stdlib::Absolutepath] $notification_script = undef,
Optional[Stdlib::Absolutepath] $client_reconfig_script = undef,
) inherits redis::params {

require 'redis'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
$master_name = 'mymaster'
$redis_master = '127.0.0.1'
$failover_timeout = '10000'
$failover_timeout = 10000
# We're testing with `manage_repo` true. In redis-sentinel 5, the daemon has its own rundir
if $::operatingsystem == 'Ubuntu' {
Expand Down
8 changes: 4 additions & 4 deletions spec/classes/redis_sentinel_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -69,8 +69,8 @@
down_after: 6000,
log_file: '/tmp/barn-sentinel.log',
failover_timeout: 28_000,
notification_script: 'bar.sh',
client_reconfig_script: 'foo.sh'
notification_script: '/path/to/bar.sh',
client_reconfig_script: '/path/to/foo.sh'
}
end

Expand All @@ -87,8 +87,8 @@
sentinel parallel-syncs cow 1
sentinel failover-timeout cow 28000
sentinel auth-pass cow password
sentinel notification-script cow bar.sh
sentinel client-reconfig-script cow foo.sh
sentinel notification-script cow /path/to/bar.sh
sentinel client-reconfig-script cow /path/to/foo.sh
loglevel notice
logfile /tmp/barn-sentinel.log
Expand Down
Loading

0 comments on commit 502ff38

Please sign in to comment.