Puppet Class: redis
- Inherits:
- redis::params
- Defined in:
- manifests/init.pp
Overview
Class: redis
Install redis.
Parameters
- version
-
Version to install. Default: 2.4.13
- redis_src_dir
-
Location to unpack source code before building and installing it. Default: /opt/redis-src
- redis_bin_dir
-
Location to install redis binaries. Default: /opt/redis
Examples
include redis
class { ‘redis’:
version => '2.6',
redis_src_dir => '/fake/path/redis-src',
redis_bin_dir => '/fake/path/redis',
}
Authors
Thomas Van Doren
Copyright
Copyright 2012 Thomas Van Doren, unless otherwise noted.
37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 |
# File 'manifests/init.pp', line 37
class redis (
$version = $redis::params::version,
$redis_src_dir = $redis::params::redis_src_dir,
$redis_bin_dir = $redis::params::redis_bin_dir
) inherits redis::params {
include wget
include gcc
$redis_pkg_name = "redis-${version}.tar.gz"
$redis_pkg = "${redis_src_dir}/${redis_pkg_name}"
# Install default instance
redis::instance { 'redis-default': }
File {
owner => root,
group => root,
}
file { $redis_src_dir:
ensure => directory,
}
file { '/etc/redis':
ensure => directory,
}
file { 'redis-lib':
ensure => directory,
path => '/var/lib/redis',
}
# If the version is 2.4.13, use the tarball that ships with the
# module.
if ($version == '2.4.13') {
file { 'redis-pkg':
ensure => present,
path => $redis_pkg,
mode => '0644',
source => 'puppet:///modules/redis/redis-2.4.13.tar.gz',
}
}
exec { 'get-redis-pkg':
command => "/usr/bin/wget --output-document ${redis_pkg} http://redis.googlecode.com/files/${redis_pkg_name}",
unless => "/usr/bin/test -f ${redis_pkg}",
require => File[$redis_src_dir],
}
file { 'redis-cli-link':
ensure => link,
path => '/usr/local/bin/redis-cli',
target => "${redis_bin_dir}/bin/redis-cli",
}
exec { 'unpack-redis':
command => "tar --strip-components 1 -xzf ${redis_pkg}",
cwd => $redis_src_dir,
path => '/bin:/usr/bin',
unless => "test -f ${redis_src_dir}/Makefile",
require => Exec['get-redis-pkg'],
}
exec { 'install-redis':
command => "make && make install PREFIX=${redis_bin_dir}",
cwd => $redis_src_dir,
path => '/bin:/usr/bin',
unless => "test $(${redis_bin_dir}/bin/redis-server --version | cut -d ' ' -f 1) = 'Redis'",
require => [ Exec['unpack-redis'], Class['gcc'] ],
}
}
|