From bf55b9c3d065cb7d73c2e74280101dd96664c6db Mon Sep 17 00:00:00 2001 From: Steve Maddison Date: Thu, 25 Jun 2015 11:18:13 +0200 Subject: [PATCH 1/7] Support for extra configuration directives. --- manifests/server.pp | 16 ++++++++++++++-- templates/etc/redis.conf.erb | 14 ++++++++++---- 2 files changed, 24 insertions(+), 6 deletions(-) diff --git a/manifests/server.pp b/manifests/server.pp index 846d7bd..f3f82dc 100644 --- a/manifests/server.pp +++ b/manifests/server.pp @@ -63,6 +63,14 @@ # Configure Redis replication ping slave period # [*save*] # Configure Redis save snapshotting. Example: [[900, 1], [300, 10]]. Default: [] +# [*hash_max_ziplist_entries*] +# Threshold for ziplist entries. Default: 512 +# [*hash_max_ziplist_value*] +# Threshold for ziplist value. Default: 64 +# [*unixsocket*] +# Optional full path to the UNIX socket on which Redis should listen. +# [*unixsocketperm*] +# Optional file permissions for the above UNIX socket. # define redis::server ( $redis_name = $name, @@ -96,6 +104,10 @@ $repl_timeout = 60, $repl_ping_slave_period = 10, $save = [], + $hash_max_ziplist_entries = 512, + $hash_max_ziplist_value = 64, + $unixsocket = undef, + $unixsocketperm = undef, ) { $redis_install_dir = $::redis::install::redis_install_dir @@ -112,7 +124,8 @@ "/etc/redis_${redis_name}.conf": ensure => file, content => template('redis/etc/redis.conf.erb'), - require => Class['redis::install']; + require => Class['redis::install'], + notify => Service["redis-server_${redis_name}"], } # startup script @@ -163,6 +176,5 @@ enable => $enabled, hasstatus => true, hasrestart => true, - require => File["/etc/init.d/redis-server_${redis_name}"] } } diff --git a/templates/etc/redis.conf.erb b/templates/etc/redis.conf.erb index 613a155..5a1a083 100644 --- a/templates/etc/redis.conf.erb +++ b/templates/etc/redis.conf.erb @@ -36,6 +36,12 @@ bind <%= @redis_ip %> # on a unix socket when not specified. # # unixsocket /var/run/redis/redis.sock +<% if @unixsocket -%> +unixsocket <%= @unixsocket %> +<% end -%> +<% if @unixsocketperm -%> +unixsocketperm <%= @unixsocketperm %> +<% end -%> # Close the connection after a client is idle for N seconds (0 to disable) timeout 0 @@ -424,11 +430,11 @@ slowlog-max-len 1024 # small number of entries, and the biggest entry does not exceed a given # threshold. These thresholds can be configured using the following directives. <% if @redis_2_6_or_greater -%> -hash-max-ziplist-entries 512 -hash-max-ziplist-value 64 +hash-max-ziplist-entries <%= @hash_max_ziplist_entries %> +hash-max-ziplist-value <%= @hash_max_ziplist_value %> <% else -%> -hash-max-zipmap-entries 512 -hash-max-zipmap-value 64 +hash-max-zipmap-entries <%= @hash_max_ziplist_entries %> +hash-max-zipmap-value <%= @hash_max_ziplist_value %> <% end -%> # Similarly to hashes, small lists are also encoded in a special way in order From d362335ca635843a07fca519376a71c1172ee06a Mon Sep 17 00:00:00 2001 From: Devin Christensen Date: Mon, 12 Oct 2015 14:14:12 -0600 Subject: [PATCH 2/7] Explicitly define sentinel's pidfile Before this change, the redis-sentinel process was writing its pid to `/var/run/redis.pid`, preventing the init.d scripts for correctly identifying in stop and status calls. Tested on redis 3.0.4. --- templates/etc/sentinel.conf.erb | 2 ++ 1 file changed, 2 insertions(+) diff --git a/templates/etc/sentinel.conf.erb b/templates/etc/sentinel.conf.erb index 12fc4bf..5ba896b 100644 --- a/templates/etc/sentinel.conf.erb +++ b/templates/etc/sentinel.conf.erb @@ -4,6 +4,8 @@ daemonize yes +pidfile <%= @sentinel_pid_dir %>/redis-sentinel_<%= @sentinel_name %>.pid + logfile <%= @sentinel_log_dir -%>/redis-sentinel_<%= @sentinel_name %>.log port <%= @sentinel_port -%> From 696864c1c8061b070685b10786994c6690ef69bb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=89mile=20Morel?= Date: Fri, 16 Oct 2015 11:44:08 +0200 Subject: [PATCH 3/7] add create_ressource from hiera --- README.md | 12 ++++++++++++ manifests/init.pp | 14 ++++++++++++-- 2 files changed, 24 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 31e5216..91a5256 100644 --- a/README.md +++ b/README.md @@ -138,6 +138,18 @@ node 'redis-slave.my.domain' { } ``` +### Example using Hiera + + redis::install::redis_package: true + redis::install::redis_version: '2:2.8.17-1+deb8u1' + redis::servers: + 'name_server': + requirepass: 'strongpass' + enabled: true + redis_ip: '0.0.0.0' + redis_port: '6800' + redis_log_dir: '/var/log/redis/' + ###Setting up sentinel with two monitors You can create multiple sentinels on one node. But most of the time you will diff --git a/manifests/init.pp b/manifests/init.pp index 21ab9c6..daaab2e 100644 --- a/manifests/init.pp +++ b/manifests/init.pp @@ -4,6 +4,16 @@ # # === Parameters # -# None. +# [*servers*] +# Hash for servers instantiation from hiera # -class redis inherits redis::params {} +class redis ( + # START Hiera Lookups ### + $servers = {}, + ### END Hiera Lookups ### +) inherits redis::params { + + create_resources('redis::server', $servers) + +} + From b35b2a5199e0170f57f0770b4daf0d8915a0a0c4 Mon Sep 17 00:00:00 2001 From: Matthias Wiesner Date: Wed, 21 Oct 2015 11:15:47 +0200 Subject: [PATCH 4/7] Change ownership of $redis_dir depending on the redis system user Some packages, at least the redis package for SLES creates by default a redis system user. When using the redis cluster feature the $redis_dir is used for synchronizing. Therefor, the $redis_dir has to be owned by the redis system user, otherwise the redis server cannot start. This commit sets the $redis_dir ownership according to the given $redis_user. By default the $redis_user is undef, which results to 'root' as redis system user. --- README.md | 16 ++++++++++++++++ manifests/install.pp | 10 +++++++++- manifests/params.pp | 2 ++ manifests/server.pp | 4 ++++ templates/etc/init.d/sles_redis-server.erb | 5 +++-- 5 files changed, 34 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 91a5256..bbf6347 100644 --- a/README.md +++ b/README.md @@ -216,6 +216,22 @@ directoy like '/opt/redis-2.8.8/' Default is '/usr/bin' (string). The dir to which the newly built redis binaries are copied. +#####`redis_user` + +Redis system user. Default: undef (string) +Default 'undef' results to 'root' as redis system user + +Some redis install packages create the redis system user by default (at +least SLES and Ubuntu provide redis install packages). +Normally the log directory and the pid directory are created also by +the redis install package. Therefor, these values must be adjusted too. + + +#####`redis_group` + +Redis system group. Default: undef (string) +Default 'undef' results to 'root' as redis system group + ####Defined Type: `redis::server` Used to configure redis instances. You can setup multiple redis servers on the diff --git a/manifests/install.pp b/manifests/install.pp index 579a5a4..ee708e6 100644 --- a/manifests/install.pp +++ b/manifests/install.pp @@ -14,12 +14,20 @@ # [*redis_install_dir*] # The dir to which the newly built redis binaries are copied. Default value is '/usr/bin'. # +# [*redis_user*] +# The redis system user. Default value is 'undef', which results to 'root' as system user. +# +# [*redis_group*] +# The redis system group. Default value is 'undef', which results to 'root' as system group. +# class redis::install ( $redis_version = $::redis::params::redis_version, $redis_build_dir = $::redis::params::redis_build_dir, $redis_install_dir = $::redis::params::redis_install_dir, $redis_package = $::redis::params::redis_install_package, - $download_tool = $::redis::params::download_tool + $download_tool = $::redis::params::download_tool, + $redis_user = $::redis::params::redis_user, + $redis_group = $::redis::params::redis_group, ) inherits redis { if ( $redis_package == true ) { case $::operatingsystem { diff --git a/manifests/params.pp b/manifests/params.pp index 565a414..522709c 100644 --- a/manifests/params.pp +++ b/manifests/params.pp @@ -6,4 +6,6 @@ $redis_install_dir = '/usr/bin' $redis_install_package = false $download_tool = 'curl -s -L' + $redis_user = undef + $redis_group = undef } diff --git a/manifests/server.pp b/manifests/server.pp index 211ee7a..399756c 100644 --- a/manifests/server.pp +++ b/manifests/server.pp @@ -119,6 +119,8 @@ $save = [], $force_rewrite = false, ) { + $redis_user = $::redis::install::redis_user + $redis_group = $::redis::install::redis_group $redis_install_dir = $::redis::install::redis_install_dir $redis_init_script = $::operatingsystem ? { @@ -164,6 +166,8 @@ file { "${redis_dir}/redis_${redis_name}": ensure => directory, require => Class['redis::install'], + owner => $redis_user, + group => $redis_group, } # install and configure logrotate diff --git a/templates/etc/init.d/sles_redis-server.erb b/templates/etc/init.d/sles_redis-server.erb index 2050f71..42389aa 100644 --- a/templates/etc/init.d/sles_redis-server.erb +++ b/templates/etc/init.d/sles_redis-server.erb @@ -22,7 +22,8 @@ ### END INIT INFO EXEC=/usr/sbin/redis-server -USER=redis +USER=<%= @redis_user or 'root' %> +GROUP=<%= @redis_group or 'root' %> STATE=<%= @redis_pid_dir %> CONF=/etc PIDFILE=${STATE}/redis_<%= @redis_name %>.pid @@ -31,7 +32,7 @@ CONFIG=${CONF}/redis_<%= @redis_name %>.conf . /etc/rc.status if [ ! -d $STATE ]; then - install -d $state -o $USER -g $USER -m 0755 $STATE + install -d $state -o $USER -g $GROUP -m 0755 $STATE fi start() { From 748e2265ba8a6de6e3281f9bf50cd77542bedfd6 Mon Sep 17 00:00:00 2001 From: Matthias Wiesner Date: Fri, 30 Oct 2015 13:32:10 +0100 Subject: [PATCH 5/7] Prevent default redis-server from automatically start When installing the redis-server with an install package on Ubuntu or Debian, the redis-server is started automatically. This prevents the puppet-configured redis-server from a correct start due to a port conflict. Stop the redis-server, after you install or upgrade the server with an installation package. --- manifests/install.pp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/manifests/install.pp b/manifests/install.pp index ee708e6..58ce8f7 100644 --- a/manifests/install.pp +++ b/manifests/install.pp @@ -33,6 +33,10 @@ case $::operatingsystem { '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, } From 44693073e7bc14e3b4fefb0a128963a6e3f55736 Mon Sep 17 00:00:00 2001 From: Janez Podpecan Date: Thu, 19 Nov 2015 19:56:50 +0100 Subject: [PATCH 6/7] Fix a spelling typo --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 31e5216..26ef752 100644 --- a/README.md +++ b/README.md @@ -184,7 +184,7 @@ The redis service(s) are configured with the defined type `redis::server`. ####Class: `redis::install` This class downloads, compiles and installs redis. It does not configure any -redis services. This is done by defimed type redis::server. +redis services. This is done by defined type redis::server. **Parameters within `redis::install`:** From 047db2d5e747952b628e63d62aa629b2eb6e0fac Mon Sep 17 00:00:00 2001 From: Daniel Werdermann Date: Wed, 2 Dec 2015 10:37:58 +0100 Subject: [PATCH 7/7] prepare release 1.7.0 --- CHANGELOG.md | 18 ++++++++++++++++++ metadata.json | 2 +- 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 3fc35cb..5c5404b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,21 @@ +## 2015-12-02 - 1.7.0 (Feature/Bugfix release) + +#### Features: + +- (3236f41) #33 add Scientific Linux support +- (ad5d3c1) #37 Server: add parameters `redis_usesocket` `redis_socket` `redis_socketperm` `redis_memsamples` +- (edf870b) #31 Server: add parameters `force_rewrite` +- (e1c2011) #53 Server: add parameters `hash_max_ziplist_entries` and `hash_max_ziplist_value` +- (f1006e2) #48 Server: add parameters `redis_user` and `redis_group` +- (42bb23f) #44 Sentinel: explititly define sentinel pidfile + +#### Bugfixes: + +- (3e920e3) #35 Server: correct usage of `redis_timeout` in servers +- (f8e44b2) #39 avoid conflicts build-essential +- (75cffe8) #51 prevent default redis-server from automatically start + + ## 2015-05-11 - 1.6.0 (Feature/Bugfix release) #### Features: diff --git a/metadata.json b/metadata.json index fe12402..959a60a 100644 --- a/metadata.json +++ b/metadata.json @@ -30,7 +30,7 @@ } ], "name": "dwerder-redis", - "version": "1.6.0", + "version": "1.7.0", "source": "git clone https://github.com/echocat/puppet-redis.git", "author": "Daniel Werdermann", "license": "MPL-2.0",