Skip to content
This repository has been archived by the owner on Mar 8, 2023. It is now read-only.

Commit

Permalink
Merge pull request #79 from echocat/develop
Browse files Browse the repository at this point in the history
backmerge for release 1.9.0
  • Loading branch information
dwerder authored Jun 24, 2016
2 parents 6e4bd03 + e4b1aa4 commit 3a076a7
Show file tree
Hide file tree
Showing 7 changed files with 249 additions and 33 deletions.
1 change: 1 addition & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
sudo: false
language: ruby
cache: bundler
env: BUNDLE_PATH=.bundle
bundler_args: --without system_tests
before_install: rm Gemfile.lock || true
script: bundle exec rake validate lint spec
Expand Down
10 changes: 10 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,13 @@
## 2016-06-24 - 1.9.0 (Feature/Bugfix release)

#### Bugfixes:

- (734defe) redis-check-dump was renamed to redis-check-rdb in redis version 3.2

#### Features:

- (123f474) Add initial cluster support to redis::server

## 2016-04-08 - 1.8.1 (Bugfix release)

#### Bugfixes:
Expand Down
53 changes: 53 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
2. [Setup - The basics of getting started with redis](#setup)
* [Beginning with redis - Installation](#beginning-with-redis)
* [Run multiple instances on same host](#run-multiple-instances-on-same-host)
* [Create a cluster-enabled instance](#Create a cluster-enable instance)
* [Setting up sentinel with two monitors](#setting-up-sentinel-with-two-monitors)
3. [Usage - The class and defined types available for configuration](#usage)
* [Classes and Defined Types](#classes-and-defined-types)
Expand Down Expand Up @@ -139,6 +140,36 @@ node 'redis-slave.my.domain' {
}
```

###Create a cluster-enable instance

Please note that right now you can only create cluster-enabled instances
but you cannot configure a Redis Cluster only with this module. You should
still use `redis-trib.rb` from Redis source distribution or configure it
by hand with redis cluster commands. Moreover, the cluster mode will be enabled
only for Redis >= 3.0

A simple example of a cluster-enabled instance, with a timeout of 5 seconds to
detect if another node is dead.

```puppet
node 'redis-cluster.my.domain' {
# install latest stable build.
class { 'redis::install': }
redis::server {
'cluster-instance':
redis_memory => '1g',
redis_ip => '0.0.0.0',
redis_port => 6379,
running => true,
enabled => true,
cluster_enabled => true,
cluster_node_timeout => '5000',
}
}
```

### Example using Hiera

redis::install::redis_package: true
Expand Down Expand Up @@ -402,6 +433,28 @@ Configure Redis slave replication timeout in seconds. Default: 60 (number)

Configure Redis replication ping slave period in seconds. Default: 10 (number)

##### Cluster Options

#####`cluster_enabled`

Enable Redis Cluster. Supported only in Redis 3.x. Default: false

#####`cluster_node_timeout`

Timeout in ms to declare a node as failed.

#####`cluster_slave_validity_factor`

Configure slave validity factor. Please read the Redis documentation to learn more about this parameter.

#####`cluster_migration_barrier`

Slaves migrate to orphaned masters only if there are still at least this given number of other working slaves for their old master.

#####`cluster_require_full_coverage`

By default Redis Cluster nodes stop accepting queries if they detect there is at least an hash slot uncovered.

####Defined Type: `redis::sentinel`

Used to configure sentinel instances. You can setup multiple sentinel servers
Expand Down
71 changes: 39 additions & 32 deletions manifests/install.pp
Original file line number Diff line number Diff line change
Expand Up @@ -31,19 +31,20 @@
$download_tool = $::redis::params::download_tool,
$redis_user = $::redis::params::redis_user,
$redis_group = $::redis::params::redis_group,
$download_base = $::redis::params::download_base,
) inherits redis {
if ( $redis_package == true ) {
$download_base = $::redis::params::download_base,) inherits redis {
if ($redis_package == true) {
case $::operatingsystem {
'Debian', 'Ubuntu': {
package { 'redis-server' : ensure => $redis_version, }
service { 'redis-server' :
'Debian', 'Ubuntu' : {
package { 'redis-server': ensure => $redis_version, }

service { 'redis-server':
ensure => stopped,
subscribe => Package['redis-server']
}
}
'Fedora', 'RedHat', 'CentOS', 'OEL', 'OracleLinux', 'Amazon', 'Scientific', 'SLES': {
package { 'redis' : ensure => $redis_version, }
'Fedora', 'RedHat', 'CentOS', 'OEL', 'OracleLinux', 'Amazon', 'Scientific', 'SLES' : {
package { 'redis': ensure => $redis_version, }

# The SLES DatabaseServer repository installs a conflicting logrotation configuration
if $::operatingsystem == 'SLES' {
file { '/etc/logrotate.d/redis':
Expand All @@ -52,30 +53,29 @@
}
}
}
'Gentoo': {
package { 'dev-db/redis' : ensure => $redis_version, }
'Gentoo' : {
package { 'dev-db/redis': ensure => $redis_version, }
}
default: {
default : {
fail('The module does not support this OS.')
}
}
} else {

# install necessary packages for build.
case $::operatingsystem {
'Debian', 'Ubuntu': {
'Debian', 'Ubuntu' : {
ensure_packages('build-essential')
Package['build-essential'] -> Anchor['redis::prepare_build']
}
'Fedora', 'RedHat', 'CentOS', 'OEL', 'OracleLinux', 'Amazon', 'Scientific', 'Sles': {
'Fedora', 'RedHat', 'CentOS', 'OEL', 'OracleLinux', 'Amazon', 'Scientific', 'Sles' : {
ensure_packages('make')
Package['make'] -> Anchor['redis::prepare_build']
ensure_packages('gcc')
Package['gcc'] -> Anchor['redis::prepare_build']
ensure_packages('glibc-devel')
Package['glibc-devel'] -> Anchor['redis::prepare_build']
}
default: {
default : {
fail('The module does not support this OS.')
}
}
Expand All @@ -90,9 +90,7 @@
before => File[$redis_build_dir]
}

file { $redis_build_dir:
ensure => directory,
}
file { $redis_build_dir: ensure => directory, }

$redis_download_url = "${download_base}/redis-${redis_version}.tar.gz"

Expand All @@ -107,9 +105,7 @@
group => 'root',
}

anchor { 'redis::prepare_build':
before => Exec['redis::compile'],
}
anchor { 'redis::prepare_build': before => Exec['redis::compile'], }

# if this fails, then a 'make distclean' can help
exec { 'redis::compile':
Expand All @@ -127,18 +123,29 @@
require => Exec['redis::compile']
}

anchor { 'redis::install':
require => File["${redis_build_dir}/redis"],
}
anchor { 'redis::install': require => File["${redis_build_dir}/redis"], }

$redis_binaries = [
'redis-benchmark',
'redis-check-aof',
'redis-check-dump',
'redis-cli',
'redis-sentinel',
'redis-server'
]
# issue #75 redis-check-dump was renamed to redis-check.rdb since 3.2
case $redis_version {
/^2\./, /^3\.0/, /^3\.1/ : {
$redis_binaries = [
'redis-benchmark',
'redis-check-aof',
'redis-check-dump',
'redis-cli',
'redis-sentinel',
'redis-server']
}
default : {
$redis_binaries = [
'redis-benchmark',
'redis-check-aof',
'redis-check-rdb',
'redis-cli',
'redis-sentinel',
'redis-server']
}
}

redis::installbinary { $redis_binaries:
require => Anchor['redis::install'],
Expand Down
25 changes: 25 additions & 0 deletions manifests/server.pp
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,25 @@
#
# [*manage_logrotate*]
# Configure logrotate rules for redis server. Default: true
#
# [*cluster_enabled*]
# Enable Redis Cluster. Supported only in Redis 3.x. Default: false
#
# [*cluster_node_timeout*]
# Timeout in ms to declare a node as failed.
#
# [*cluster_slave_validity_factor*]
# Configure slave validity factor. Please read the Redis documentation to learn more
# about this parameter.
#
# [*cluster_migration_barrier*]
# Slaves migrate to orphaned masters only if there are still at least this
# given number of other working slaves for their old master.
#
# [*cluster_require_full_coverage*]
# By default Redis Cluster nodes stop accepting queries if they detect there
# is at least an hash slot uncovered.

define redis::server (
$redis_name = $name,
$redis_memory = '100mb',
Expand Down Expand Up @@ -126,6 +145,11 @@
$hash_max_ziplist_entries = 512,
$hash_max_ziplist_value = 64,
$manage_logrotate = true,
$cluster_enabled = false,
$cluster_node_timeout = undef,
$cluster_slave_validity_factor = undef,
$cluster_migration_barrier = undef,
$cluster_require_full_coverage = true,
) {
$redis_user = $::redis::install::redis_user
$redis_group = $::redis::install::redis_group
Expand All @@ -139,6 +163,7 @@
default => undef,
}
$redis_2_6_or_greater = versioncmp($::redis::install::redis_version,'2.6') >= 0
$redis_with_cluster_support = versioncmp($::redis::install::redis_version,'3.0') >= 0

# redis conf file
$conf_file_name = "redis_${redis_name}.conf"
Expand Down
2 changes: 1 addition & 1 deletion metadata.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
}
],
"name": "dwerder-redis",
"version": "1.8.1",
"version": "1.9.0",
"source": "https://github.com/echocat/puppet-redis.git",
"author": "Daniel Werdermann",
"license": "MPL-2.0",
Expand Down
Loading

0 comments on commit 3a076a7

Please sign in to comment.