6 changes: 4 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
*.swp
.DS_Store
.vagrant/
.yardoc
Gemfile.lock
doc
log/
pkg
spec/fixtures
.yardoc
doc
9 changes: 9 additions & 0 deletions Gemfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
source 'https://rubygems.org'

# special dependencies for Ruby 1.8
# since there are still several OSes with it
if RUBY_VERSION =~ /^1\.8\./
gem 'rspec-core', '~> 3.1.7'
gem 'nokogiri', '~> 1.5.0'
end

puppetversion = ENV.key?('PUPPET_VERSION') ? "~> #{ENV['PUPPET_VERSION']}" : ['>= 3.2.1']
gem 'puppet', puppetversion

Expand All @@ -18,3 +25,5 @@ gem 'puppet-lint', '>=0.3.2'
gem 'rspec-puppet', '>=0.1.6'
gem 'puppetlabs_spec_helper', '>=0.4.1'

gem 'beaker-rspec'
gem 'vagrant-wrapper'
64 changes: 33 additions & 31 deletions manifests/config.pp
Original file line number Diff line number Diff line change
Expand Up @@ -3,50 +3,52 @@
# This class provides configuration for Redis.
#
class redis::config {
$daemonize = $::redis::daemonize
$pid_file = $::redis::pid_file
$port = $::redis::port
$activerehashing = $::redis::activerehashing
$appendfsync = $::redis::appendfsync
$appendonly = $::redis::appendonly
$auto_aof_rewrite_min_size = $::redis::auto_aof_rewrite_min_size
$auto_aof_rewrite_percentage = $::redis::auto_aof_rewrite_percentage
$bind = $::redis::bind
$timeout = $::redis::timeout
$log_level = $::redis::log_level
$log_file = $::redis::log_file
$syslog_enabled = $::redis::syslog_enabled
$syslog_facility = $::redis::syslog_facility
$cluster_config_file = $::redis::cluster_config_file
$cluster_enabled = $::redis::cluster_enabled
$cluster_node_timeout = $::redis::cluster_node_timeout
$daemonize = $::redis::daemonize
$databases = $::redis::databases
$rdbcompression = $::redis::rdbcompression
$dbfilename = $::redis::dbfilename
$workdir = $::redis::workdir
$slaveof = $::redis::slaveof
$extra_config_file = $::redis::extra_config_file
$hash_max_ziplist_entries = $::redis::hash_max_ziplist_entries
$hash_max_ziplist_value = $::redis::hash_max_ziplist_value
$hz = $::redis::hz
$list_max_ziplist_entries = $::redis::list_max_ziplist_entries
$list_max_ziplist_value = $::redis::list_max_ziplist_value
$log_file = $::redis::log_file
$log_level = $::redis::log_level
$masterauth = $::redis::masterauth
$slave_serve_stale_data = $::redis::slave_serve_stale_data
$slave_read_only = $::redis::slave_read_only
$repl_timeout = $::redis::repl_timeout
$requirepass = $::redis::requirepass
$save_db_to_disk = $::redis::save_db_to_disk
$maxclients = $::redis::maxclients
$maxmemory = $::redis::maxmemory
$maxmemory_policy = $::redis::maxmemory_policy
$maxmemory_samples = $::redis::maxmemory_samples
$appendonly = $::redis::appendonly
$appendfsync = $::redis::appendfsync
$no_appendfsync_on_rewrite = $::redis::no_appendfsync_on_rewrite
$auto_aof_rewrite_percentage = $::redis::auto_aof_rewrite_percentage
$auto_aof_rewrite_min_size = $::redis::auto_aof_rewrite_min_size
$pid_file = $::redis::pid_file
$port = $::redis::port
$rdbcompression = $::redis::rdbcompression
$repl_timeout = $::redis::repl_timeout
$requirepass = $::redis::requirepass
$save_db_to_disk = $::redis::save_db_to_disk
$set_max_intset_entries = $::redis::set_max_intset_entries
$slave_read_only = $::redis::slave_read_only
$slave_serve_stale_data = $::redis::slave_serve_stale_data
$slaveof = $::redis::slaveof
$slowlog_log_slower_than = $::redis::slowlog_log_slower_than
$slowlog_max_len = $::redis::slowlog_max_len
$hash_max_ziplist_entries = $::redis::hash_max_ziplist_entries
$hash_max_ziplist_value = $::redis::hash_max_ziplist_value
$hz = $::redis::hz
$list_max_ziplist_entries = $::redis::list_max_ziplist_entries
$list_max_ziplist_value = $::redis::list_max_ziplist_value
$set_max_intset_entries = $::redis::set_max_intset_entries
$stop_writes_on_bgsave_error = $::redis::stop_writes_on_bgsave_error
$syslog_enabled = $::redis::syslog_enabled
$syslog_facility = $::redis::syslog_facility
$tcp_keepalive = $::redis::tcp_keepalive
$timeout = $::redis::timeout
$workdir = $::redis::workdir
$zset_max_ziplist_entries = $::redis::zset_max_ziplist_entries
$zset_max_ziplist_value = $::redis::zset_max_ziplist_value
$activerehashing = $::redis::activerehashing
$extra_config_file = $::redis::extra_config_file
$cluster_enabled = $::redis::cluster_enabled
$cluster_config_file = $::redis::cluster_config_file
$cluster_node_timeout = $::redis::cluster_node_timeout

if $::redis::notify_service {
File {
Expand Down
26 changes: 25 additions & 1 deletion manifests/init.pp
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
# [*auto_aof_rewrite_min_size*]
# Adjust minimum size for auto-aof-rewrite.
#
# Default: 64min
# Default: 64mb
#
# [*auto_aof_rewrite_percentage*]
# Adjust percentatge for auto-aof-rewrite.
Expand Down Expand Up @@ -331,6 +331,12 @@
#
# Default: 1024
#
# [*stop_writes_on_bgsave_error*]
# If false then Redis will continue to work as usual even if there
# are problems with disk, permissions, and so forth.
#
# Default: true
#
# [*syslog_enabled*]
# Enable/disable logging to the system logger.
#
Expand All @@ -342,6 +348,22 @@
#
# Default: undef
#
# [*tcp_keepalive*]
# TCP keepalive.
#
# If non-zero, use SO_KEEPALIVE to send TCP ACKs to clients in absence
# of communication. This is useful for two reasons:
#
# 1) Detect dead peers.
# 2) Take the connection alive from the point of view of network
# equipment in the middle.
#
# On Linux, the specified value (in seconds) is the period used to send ACKs.
# Note that to close the connection the double of the time is needed.
# On other kernels the period depends on the kernel configuration.
#
# A reasonable value for this option is 60 seconds.
#
# [*timeout*]
# Close the connection after a client is idle for N seconds (0 to disable).
#
Expand Down Expand Up @@ -456,8 +478,10 @@
$slaveof = $::redis::params::slaveof,
$slowlog_log_slower_than = $::redis::params::slowlog_log_slower_than,
$slowlog_max_len = $::redis::params::slowlog_max_len,
$stop_writes_on_bgsave_error = $::redis::params::stop_writes_on_bgsave_error,
$syslog_enabled = $::redis::params::syslog_enabled,
$syslog_facility = $::redis::params::syslog_facility,
$tcp_keepalive = $::redis::params::tcp_keepalive,
$timeout = $::redis::params::timeout,
$ulimit = $::redis::params::ulimit,
$workdir = $::redis::params::workdir,
Expand Down
10 changes: 8 additions & 2 deletions manifests/params.pp
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
$activerehashing = true
$appendfsync = 'everysec'
$appendonly = false
$auto_aof_rewrite_min_size = '64min'
$auto_aof_rewrite_min_size = '64mb'
$auto_aof_rewrite_percentage = 100
$bind = '127.0.0.1'
$conf_template = 'redis/redis.conf.erb'
Expand Down Expand Up @@ -56,8 +56,10 @@
$set_max_intset_entries = 512
$slowlog_log_slower_than = 10000
$slowlog_max_len = 1024
$stop_writes_on_bgsave_error = true
$syslog_enabled = undef
$syslog_facility = undef
$tcp_keepalive = 0
$timeout = 0
$ulimit = 65536
$workdir = '/var/lib/redis/'
Expand Down Expand Up @@ -91,6 +93,7 @@
$package_name = 'redis-server'
$sentinel_config_file = '/etc/redis/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-server'
$sentinel_package_ensure = 'present'
Expand All @@ -112,12 +115,13 @@
$config_file_mode = '0644'
$config_group = 'root'
$config_owner = 'redis'
$daemonize = false
$daemonize = true
$log_dir_mode = '0755'
$package_ensure = 'present'
$package_name = 'redis'
$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'
$sentinel_package_ensure = 'present'
Expand Down Expand Up @@ -145,6 +149,7 @@
$package_name = 'redis'
$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'
$sentinel_package_ensure = 'present'
Expand Down Expand Up @@ -172,6 +177,7 @@
$package_name = 'redis'
$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'
$sentinel_package_ensure = 'present'
Expand Down
10 changes: 5 additions & 5 deletions manifests/preinstall.pp
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@
if $::redis::manage_repo {
case $::operatingsystem {
'RedHat', 'CentOS', 'Scientific', 'OEL': {
if $::operatingsystemmajrelease < '7' {
$rpm_url = $::operatingsystemmajrelease ? {
'5' => "http://download.powerstack.org/5/${::architecture}/",
'6' => "http://download.powerstack.org/6/${::architecture}/",
if (versioncmp($::operatingsystemrelease, '7.0') == -1) {
$rpm_url = $::operatingsystemrelease ? {
/^5/ => "http://download.powerstack.org/5/${::architecture}/",
/^6/ => "http://download.powerstack.org/6/${::architecture}/",
default => Fail['Operating system or release not supported.'],
}

Expand All @@ -29,7 +29,7 @@
}
}

if $::operatingsystemmajrelease == '7' {
if (versioncmp($::operatingsystemmajrelease, '7') >= 0) {
require ::epel
}
}
Expand Down
15 changes: 12 additions & 3 deletions manifests/sentinel.pp
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,11 @@
#
# Default: redis/redis-sentinel.conf.erb
#
# [*daemonize*]
# Have Redis sentinel run as a daemon.
#
# Default: true
#
# [*down_after*]
# Number of milliseconds the master (or any attached slave or sentinel)
# should be unreachable (as in, not acceptable reply to PING, continuously,
Expand Down Expand Up @@ -149,6 +154,7 @@
$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,
$daemonize = $::redis::params::sentinel_daemonize,
$down_after = $::redis::params::sentinel_down_after,
$failover_timeout = $::redis::params::sentinel_failover_timeout,
$init_script = $::redis::params::sentinel_init_script,
Expand All @@ -169,9 +175,8 @@
$working_dir = $::redis::params::sentinel_working_dir,
$notification_script = $::redis::params::sentinel_notification_script,
) inherits redis::params {
$daemonize = $::redis::daemonize

unless defined(Package['$package_name']) {
unless defined(Package[$package_name]) {
ensure_resource('package', $package_name, {
'ensure' => $package_ensure
})
Expand All @@ -196,6 +201,7 @@
}

if $init_script {

file {
$init_script:
ensure => present,
Expand All @@ -205,10 +211,13 @@
content => template($init_template),
require => Package[$package_name];
}

exec {
'/usr/sbin/update-rc.d redis-sentinel defaults':
require => File[$init_script];
subscribe => File[$init_script],
refreshonly => true;
}

}

service { $service_name:
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.2.1",
"version": "1.2.2",
"author": "Tom De Vylder",
"summary": "Redis module",
"license": "Apache-2.0",
Expand Down
11 changes: 11 additions & 0 deletions spec/acceptance/nodesets/default.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
HOSTS:
centos-65-x64:
roles:
- master
platform: el-6-x86_64
box : centos-65-x64-vbox436-nocm
box_url : http://puppet-vagrant-boxes.puppetlabs.com/centos-65-x64-virtualbox-nocm.box
hypervisor : vagrant

CONFIG:
type: foss
23 changes: 23 additions & 0 deletions spec/acceptance/redis_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
require 'spec_helper_acceptance'

describe 'redis' do
it 'should run successfully' do
pp = <<-EOS
Exec {
path => [ '/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin', ]
}
class { '::redis':
manage_repo => true,
}
EOS

# Apply twice to ensure no errors the second time.
apply_manifest(pp, :catch_failures => true)
apply_manifest(pp, :catch_changes => true)
end

describe package('redis') do
it { should be_installed }
end
end
Loading