Skip to content

Commit

Permalink
first commit
Browse files Browse the repository at this point in the history
  • Loading branch information
fsalum committed Feb 25, 2013
0 parents commit fa38754
Show file tree
Hide file tree
Showing 8 changed files with 762 additions and 0 deletions.
10 changes: 10 additions & 0 deletions Modulefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
name 'fsalum-redis'
version '0.0.1'
source 'git://github.com/fsalum/puppet-redis.git'
author 'Felipe Salum'
license 'Apache License, Version 2.0'
summary 'Puppet module for Redis Server'
description 'Module to install and configure a Redis server'
project_page 'https://github.com/fsalum/puppet-redis'

## Add dependencies, if any:
28 changes: 28 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
Redis Module for Puppet
=======================

This module install and maneges the Redis server. All redis.conf options are
accepted in the parameterized class.

Quick Start
-----------

Use the default parameters:

class { 'redis': }

To change the port and listening network interface:

class { 'redis':
conf_port => '6379',
conf_bind => '0.0.0.0',
}

Parameters
----------

Check the init.pp file for a list of parameters accepted.

Author
------
Felipe Salum <[email protected]>
116 changes: 116 additions & 0 deletions manifests/init.pp
Original file line number Diff line number Diff line change
@@ -0,0 +1,116 @@
# == Class: redis
#
# Install and configure a Redis server
#
# === Parameters
#
# All the redis.conf parameters can be passed to the class.
# Check the README.md file
#
# === Variables
#
# Here you should define a list of variables that this module would require.
#
# === Examples
#
# class { redis:
# $conf_port => '6380',
# $conf_bind => '0.0.0.0',
# }
#
# === Authors
#
# Felipe Salum <[email protected]>
#
# === Copyright
#
# Copyright 2013 Felipe Salum, unless otherwise noted.
#
class redis (
$package_ensure = 'present',
$service_ensure = 'running',
$service_enable = true,
$conf_daemonize = 'yes',
$conf_pidfile = '/var/run/redis/redis.pid',
$conf_port = '6379',
$conf_bind = '127.0.0.1',
$conf_timeout = '0',
$conf_loglevel = 'notice',
$conf_logfile = '/var/log/redis/redis.log',
$conf_syslog_enabled = UNSET,
$conf_syslog_ident = UNSET,
$conf_syslog_facility = UNSET,
$conf_databases = '16',
$conf_save = UNSET,
$conf_rdbcompression = 'yes',
$conf_dbfilename = 'dump.rdb',
$conf_dir = '/var/lib/redis/',
$conf_slaveof = UNSET,
$conf_masterauth = UNSET,
$conf_slave_server_stale_data = 'yes',
$conf_repl_ping_slave_period = '10',
$conf_repl_timeout = '60',
$conf_requirepass = UNSET,
$conf_maxclients = UNSET,
$conf_maxmemory = UNSET,
$conf_maxmemory_policy = UNSET,
$conf_maxmemory_samples = UNSET,
$conf_appendonly = 'no',
$conf_appendfilename = UNSET,
$conf_appendfsync = 'everysec',
$conf_no_appendfsync_on_rewrite = 'no',
$conf_auto_aof_rewrite_percentage = '100',
$conf_auto_aof_rewrite_min_size = '64mb',
$conf_slowlog_log_slower_than = '10000',
$conf_slowlog_max_len = '1024',
$conf_vm_enabled = 'no',
$conf_vm_swap_file = '/tmp/redis.swap',
$conf_vm_max_memory = '0',
$conf_vm_page_size = '32',
$conf_vm_pages = '134217728',
$conf_vm_max_threads = '4',
$conf_hash_max_zipmap_entries = '512',
$conf_hash_max_zipmap_value = '64',
$conf_list_max_ziplist_entries = '512',
$conf_list_max_ziplist_value = '64',
$conf_set_max_intset_entries = '512',
$conf_zset_max_ziplist_entries = '128',
$conf_zset_max_ziplist_value = '64',
$conf_activerehashing = 'yes',
$conf_include = UNSET,
) {

include redis::params

package { 'redis':
ensure => $package_ensure,
name => $::redis::params::package,
}

service { 'redis':
ensure => $service_ensure,
name => $::redis::params::service,
enable => $service_enable,
hasrestart => true,
hasstatus => true,
require => Package['redis'],
}

file { $::redis::params::conf:
path => $::redis::params::conf,
content => template('redis/redis.conf.erb'),
owner => root,
group => root,
mode => '0644',
notify => Service['redis'],
}

file { '/etc/logrotate.d/redis':
path => '/etc/logrotate.d/redis',
content => template('redis/redis.logrotate.erb'),
owner => root,
group => root,
mode => '0644',
}

}
31 changes: 31 additions & 0 deletions manifests/params.pp
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
# Class: redis::params
#
# This class configures parameters for the puppet-redis module.
#
# Parameters:
#
# Actions:
#
# Requires:
#
# Sample Usage:
#
class redis::params {

case $::operatingsystem {
'centos', 'redhat', 'fedora': {
$package = 'redis'
$service = 'redis'
$conf = '/etc/redis.conf'
}
'ubuntu', 'debian': {
$package = 'redis-server'
$service = 'redis-server'
$conf = '/etc/redis.conf'
}
default: {
fail("Unsupported osfamily: ${::osfamily} operatingsystem: ${::operatingsystem}, module ${module_name} only support osfamily RedHat and Debian")
}
}

}
17 changes: 17 additions & 0 deletions spec/spec_helper.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
dir = File.expand_path(File.dirname(__FILE__))
$LOAD_PATH.unshift File.join(dir, 'lib')

require 'mocha'
require 'puppet'
require 'rspec'
require 'spec/autorun'

Spec::Runner.configure do |config|
config.mock_with :mocha
end

# We need this because the RAL uses 'should' as a method. This
# allows us the same behaviour but with a different method name.
class Object
alias :must :should
end
Loading

0 comments on commit fa38754

Please sign in to comment.