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

Commit ad3c9be

Browse files
committed
back merge for 1.8.0
* Added the possibility to exclude logrotate * RH/CentOS 7 systemd support * Update config without manual actions with force_rewrite * Add binding ip option to sentinel * Set correct resources dependencies prevent exec of being run each time * add Gentoo support * fix source entry for forge api * add download_base to specify download url of source tar.gz * prepare release 1.8.0
1 parent ec430e7 commit ad3c9be

23 files changed

+358
-119
lines changed

.rspec

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
--color
2+
--format documentation

.travis.yml

+13-15
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,22 @@
11
---
22
sudo: false
33
language: ruby
4+
cache: bundler
45
bundler_args: --without system_tests
5-
script: "bundle exec rake validate && bundle exec rake lint && bundle exec rake spec SPEC_OPTS='--format documentation'"
6+
before_install: rm Gemfile.lock || true
7+
script: bundle exec rake validate lint spec
68
matrix:
79
fast_finish: true
810
include:
9-
- rvm: 1.9.3
10-
env: PUPPET_GEM_VERSION="~> 3.4.0"
11-
- rvm: 1.8.7
12-
env: PUPPET_GEM_VERSION="~> 3.0"
13-
- rvm: 1.9.3
14-
env: PUPPET_GEM_VERSION="~> 3.0"
15-
- rvm: 1.9.3
16-
env: PUPPET_GEM_VERSION="~> 3.0" FUTURE_PARSER="yes"
17-
- rvm: 2.1.5
18-
env: PUPPET_GEM_VERSION="~> 3.0"
19-
- rvm: 2.1.5
20-
env: PUPPET_GEM_VERSION="~> 3.6.0"
21-
- rvm: 2.1.5
22-
env: PUPPET_GEM_VERSION="~> 3.0" FUTURE_PARSER="yes"
11+
- rvm: 2.1.6
12+
env: PUPPET_GEM_VERSION='~> 4.0' COVERAGE=yes STRICT_VARIABLES=yes
13+
- rvm: 2.1.6
14+
env: PUPPET_GEM_VERSION='https://github.com/puppetlabs/puppet.git#stable
15+
- rvm: 2.1.5
16+
env: PUPPET_GEM_VERSION='~> 3.0' FUTURE_PARSER=yes
17+
- rvm: 2.1.5
18+
env: PUPPET_GEM_VERSION='~> 3.0'
19+
- rvm: 1.9.3
20+
env: PUPPET_GEM_VERSION='~> 3.0'
2321
notifications:
2422
email: false

CHANGELOG.md

+14
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,17 @@
1+
## 2016-04-05 - 1.8.0 (Feature/Bugfix release)
2+
3+
#### Features:
4+
5+
- (e37283e) Add the possibility to exclude logrotate
6+
- (316f492) RedHat 7: add systemd support
7+
- (316f492) Sentinel: add parameter `sentinel_ip` for binding address
8+
- (3fdbca0) Server::install: add parameter `download_base` at install class to specify download url of source tar.gz
9+
- (e47fc28) Gentoo: add support for Gentoo
10+
11+
#### Bugfixes:
12+
13+
- (6dea873) fix source entry for forge api in metadata.json
14+
115
## 2015-12-02 - 1.7.0 (Feature/Bugfix release)
216

317
#### Features:

Gemfile

+22-8
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,23 @@
1-
source 'https://rubygems.org'
1+
source ENV['GEM_SOURCE'] || "https://rubygems.org"
22

3-
puppetversion = ENV.key?('PUPPET_GEM_VERSION') ? "#{ENV['PUPPET_GEM_VERSION']}" : ['>= 3.3']
4-
facterversion = ENV.key?('FACTER_GEM_VERSION') ? "#{ENV['FACTER_GEM_VERSION']}" : ['>= 1.7']
5-
gem 'puppet', puppetversion
6-
gem 'puppetlabs_spec_helper', '>= 0.1.0'
7-
gem 'puppet-lint', '>= 0.3.2'
8-
gem 'facter', facterversion
9-
gem 'rspec', '< 3.2.0'
3+
def location_for(place, version = nil)
4+
if place =~ /^((?:git|https?)[:@][^#]*)#(.*)/
5+
[version, { :git => $1, :branch => $2, :require => false }].compact
6+
elsif place =~ /^file:\/\/(.*)/
7+
['>= 0', { :path => File.expand_path($1), :require => false }]
8+
else
9+
[place, version, { :require => false }].compact
10+
end
11+
end
12+
13+
gem 'puppet', *location_for(ENV['PUPPET_GEM_VERSION'] || '~> 4')
14+
gem 'facter', '>= 2.0'
15+
gem 'puppetlabs_spec_helper', '>= 0.1.0', :require => false
16+
gem 'puppet-lint', '>= 0.3.2', :require => false
17+
gem 'rspec-puppet', '>= 2.3.2', :require => false
18+
gem 'metadata-json-lint', :require => false
19+
gem 'rake', '< 11.0.0' # rubi <1.9 versus rake 11.0.0 workaround
20+
21+
if File.exists? "#{__FILE__}.local"
22+
eval(File.read("#{__FILE__}.local"), binding)
23+
end

README.md

+26-3
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,9 @@ This module installs and makes basic configs for multiple redis instances on
2222
the same node. It installs redis via REPO or from source. (http://redis.io/)
2323
It also can configure the monitoring server Sentinel.
2424

25-
Github Master: [![Build Status](https://secure.travis-ci.org/echocat/puppet-redis.png?branch=master)](https://travis-ci.org/echocat/puppet-redis)
26-
25+
[![Puppet Forge](http://img.shields.io/puppetforge/v/dwerder/redis.svg)](https://forge.puppetlabs.com/dwerder/redis)
26+
[![Build Status](https://secure.travis-ci.org/echocat/puppet-redis.png?branch=master)](https://travis-ci.org/echocat/puppet-redis)
27+
[![Puppet Forge Downloads](http://img.shields.io/puppetforge/dt/dwerder/redis.svg)](https://forge.puppetlabs.com/dwerder/redis)
2728

2829
##Setup
2930

@@ -232,6 +233,11 @@ the redis install package. Therefor, these values must be adjusted too.
232233
Redis system group. Default: undef (string)
233234
Default 'undef' results to 'root' as redis system group
234235

236+
#####`download_base`
237+
238+
Url where to find the source tar.gz.
239+
Default value is 'http://download.redis.io/releases'
240+
235241
####Defined Type: `redis::server`
236242

237243
Used to configure redis instances. You can setup multiple redis servers on the
@@ -366,6 +372,10 @@ Since redis automatically rewrite their config since
366372
version 2.8 setting this to `true` will trigger a redis restart on each puppet
367373
run with redis 2.8 or later.
368374

375+
#####`manage_logrotate`
376+
377+
Configure logrotate rules for redis server. Default: true
378+
369379
##### High Availability Options
370380

371381
#####`slaveof`
@@ -406,9 +416,13 @@ Name of Redis instance. Default: call name of the function.
406416
The name is used to create the init script(s), which follows the pattern
407417
`redis-sentinel_${sentinel_name}`
408418

419+
#####`sentinel_ip`
420+
421+
Listen IP of sentinel. Default: 6379
422+
409423
#####`sentinel_port`
410424

411-
Listen port of Redis. Default: 6379
425+
Listen port of sentinel. Default: 6379
412426

413427
#####`sentinel_log_dir`
414428

@@ -420,6 +434,11 @@ Path for log. Full log path is `sentinel_log_dir`/sentinel_`sentinel_name`.log.
420434
Default is '/var/run' (string).
421435
Path for pid file. Full pid file path is `sentinel_pid_dir`/sentinel_`sentinel_name`.pid.
422436

437+
#####`sentinel_run_dir`
438+
439+
Default: `/var/run/redis` (string)
440+
Since sentinels automatically rewrite their config since version 2.8 the puppet managed config will be copied
441+
to this directory and than sentinel will start with this copy.
423442

424443
#####`monitors`
425444

@@ -459,6 +478,10 @@ sentinel restart. Since sentinels automatically rewrite their config since
459478
version 2.8 setting this to `true` will trigger a sentinel restart on each puppet
460479
run with redis 2.8 or later.
461480

481+
#####`manage_logrotate`
482+
483+
Configure logrotate rules for redis server. Default: true
484+
462485
##Requirements
463486

464487
###Modules needed:

manifests/install.pp

+11-8
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,9 @@
2020
# [*redis_group*]
2121
# The redis system group. Default value is 'undef', which results to 'root' as system group.
2222
#
23+
# [*download_base*]
24+
# Url where to find the source tar.gz. Default value is 'http://download.redis.io/releases'
25+
#
2326
class redis::install (
2427
$redis_version = $::redis::params::redis_version,
2528
$redis_build_dir = $::redis::params::redis_build_dir,
@@ -28,6 +31,7 @@
2831
$download_tool = $::redis::params::download_tool,
2932
$redis_user = $::redis::params::redis_user,
3033
$redis_group = $::redis::params::redis_group,
34+
$download_base = $::redis::params::download_base,
3135
) inherits redis {
3236
if ( $redis_package == true ) {
3337
case $::operatingsystem {
@@ -48,6 +52,9 @@
4852
}
4953
}
5054
}
55+
'Gentoo': {
56+
package { 'dev-db/redis' : ensure => $redis_version, }
57+
}
5158
default: {
5259
fail('The module does not support this OS.')
5360
}
@@ -76,7 +83,7 @@
7683
exec { "Make dir ${redis_build_dir}":
7784
command => "mkdir -p ${redis_build_dir}",
7885
creates => $redis_build_dir,
79-
path => $::path,
86+
path => ['/usr/bin', '/usr/sbin', '/bin', '/sbin'],
8087
cwd => '/',
8188
user => 'root',
8289
group => 'root',
@@ -87,18 +94,14 @@
8794
ensure => directory,
8895
}
8996

90-
if $redis_version == $::redis::params::redis_version {
91-
$redis_download_url = 'http://download.redis.io/redis-stable.tar.gz'
92-
} else {
93-
$redis_download_url = "http://download.redis.io/releases/redis-${redis_version}.tar.gz"
94-
}
97+
$redis_download_url = "${download_base}/redis-${redis_version}.tar.gz"
9598

9699
exec { "Download and untar redis ${redis_version}":
97100
require => File[$redis_build_dir],
98101
before => Anchor['redis::prepare_build'],
99102
command => "${download_tool} ${redis_download_url} | tar xz",
100103
creates => "${redis_build_dir}/redis-${::redis::install::redis_version}",
101-
path => $::path,
104+
path => ['/usr/bin', '/usr/sbin', '/bin', '/sbin'],
102105
cwd => $redis_build_dir,
103106
user => 'root',
104107
group => 'root',
@@ -113,7 +116,7 @@
113116
command => 'make',
114117
creates => "${redis_build_dir}/redis-${redis_version}/src/redis-server",
115118
cwd => "${redis_build_dir}/redis-${::redis::install::redis_version}/",
116-
path => $::path,
119+
path => ['/usr/bin', '/usr/sbin', '/bin', '/sbin'],
117120
user => 'root',
118121
group => 'root',
119122
}

manifests/params.pp

+1
Original file line numberDiff line numberDiff line change
@@ -8,4 +8,5 @@
88
$download_tool = 'curl -s -L'
99
$redis_user = undef
1010
$redis_group = undef
11+
$download_base = 'http://download.redis.io/releases'
1112
}

manifests/sentinel.pp

+63-32
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@
55
#
66
# [*sentinel_name*]
77
# Name of Sentinel instance. Default: call name of the function.
8+
# [*sentinel_ip*]
9+
# Listen IP.
810
# [*sentinel_port*]
911
# Listen port of Redis. Default: 26379
1012
# [*sentinel_log_dir*]
@@ -32,21 +34,22 @@
3234
# Configure if Sentinel should be running or not. Default: true
3335
# [*enabled*]
3436
# Configure if Sentinel is started at boot. Default: true
35-
# [*force_rewrite*]
37+
# [*sentinel_run_dir*]
3638
#
37-
# Boolean. Default: `false`
38-
#
39-
# Configure if the sentinels config is overwritten by puppet followed by a
40-
# sentinel restart. Since sentinels automatically rewrite their config since
41-
# version 2.8 setting this to `true` will trigger a sentinel restart on each puppet
42-
# run with redis 2.8 or later.
39+
# Default: `/var/run/redis`
4340
#
41+
# Since sentinels automatically rewrite their config since version 2.8 the puppet managed config will be copied
42+
# to this directory and than sentinel will start with this copy.
43+
# [*manage_logrotate*]
44+
# Configure logrotate rules for redis sentinel. Default: true
4445
define redis::sentinel (
4546
$ensure = 'present',
4647
$sentinel_name = $name,
48+
$sentinel_ip = undef,
4749
$sentinel_port = 26379,
4850
$sentinel_log_dir = '/var/log',
4951
$sentinel_pid_dir = '/var/run',
52+
$sentinel_run_dir = '/var/run/redis',
5053
$monitors = {
5154
'mymaster' => {
5255
master_host => '127.0.0.1',
@@ -63,56 +66,84 @@
6366
},
6467
$running = true,
6568
$enabled = true,
66-
$force_rewrite = false,
69+
$manage_logrotate = true,
6770
) {
6871

6972
# validate parameters
70-
validate_bool($force_rewrite)
71-
73+
validate_absolute_path($sentinel_log_dir)
74+
validate_absolute_path($sentinel_pid_dir)
75+
validate_absolute_path($sentinel_run_dir)
76+
validate_hash($monitors)
77+
validate_bool($running)
78+
validate_bool($enabled)
79+
validate_bool($manage_logrotate)
80+
7281
$redis_install_dir = $::redis::install::redis_install_dir
7382
$sentinel_init_script = $::operatingsystem ? {
7483
/(Debian|Ubuntu)/ => 'redis/etc/init.d/debian_redis-sentinel.erb',
7584
/(Fedora|RedHat|CentOS|OEL|OracleLinux|Amazon|Scientific)/ => 'redis/etc/init.d/redhat_redis-sentinel.erb',
85+
/(Gentoo)/ => 'redis/etc/init.d/gentoo_redis-sentinel.erb',
7686
default => UNDEF,
7787
}
7888

7989
# redis conf file
80-
file {
81-
"/etc/redis-sentinel_${sentinel_name}.conf":
90+
$conf_file_name = "redis-sentinel_${sentinel_name}.conf"
91+
$conf_file = "/etc/${conf_file_name}"
92+
file { $conf_file:
8293
ensure => file,
8394
content => template('redis/etc/sentinel.conf.erb'),
84-
replace => $force_rewrite,
8595
require => Class['redis::install'];
86-
87-
}->
96+
}
8897

8998
# startup script
90-
file { "/etc/init.d/redis-sentinel_${sentinel_name}":
91-
ensure => file,
92-
mode => '0755',
93-
content => template($sentinel_init_script),
94-
}~>
99+
if ($::osfamily == 'RedHat' and versioncmp($::operatingsystemmajrelease, '7') >=0) {
100+
$service_file = "/usr/lib/systemd/system/redis-sentinel_${sentinel_name}.service"
101+
exec { "systemd_service_${sentinel_name}_preset":
102+
command => "/bin/systemctl preset redis-sentinel_${sentinel_name}.service",
103+
notify => Service["redis-sentinel_${sentinel_name}"],
104+
refreshonly => true,
105+
}
106+
107+
file { $service_file:
108+
ensure => file,
109+
mode => '0755',
110+
content => template('redis/systemd/sentinel.service.erb'),
111+
require => File[$conf_file],
112+
notify => Exec["systemd_service_${sentinel_name}_preset"],
113+
}
114+
} else {
115+
$service_file = "/etc/init.d/redis-sentinel_${sentinel_name}"
116+
file { $service_file:
117+
ensure => file,
118+
mode => '0755',
119+
content => template($sentinel_init_script),
120+
require => File[$conf_file],
121+
notify => Service["redis-sentinel_${sentinel_name}"],
122+
}
123+
}
95124

96125
# manage sentinel service
97126
service { "redis-sentinel_${sentinel_name}":
98127
ensure => $running,
99128
enable => $enabled,
100129
hasstatus => true,
101130
hasrestart => true,
131+
subscribe => File[$conf_file],
102132
}
103133

104-
# install and configure logrotate
105-
if ! defined(Package['logrotate']) {
106-
package { 'logrotate': ensure => installed; }
107-
}
134+
if ($manage_logrotate == true){
135+
# install and configure logrotate
136+
if ! defined(Package['logrotate']) {
137+
package { 'logrotate': ensure => installed; }
138+
}
108139

109-
file { "/etc/logrotate.d/redis-sentinel_${sentinel_name}":
110-
ensure => file,
111-
content => template('redis/sentinel_logrotate.conf.erb'),
112-
require => [
113-
Package['logrotate'],
114-
File["/etc/redis-sentinel_${sentinel_name}.conf"],
115-
]
140+
file { "/etc/logrotate.d/redis-sentinel_${sentinel_name}":
141+
ensure => file,
142+
content => template('redis/sentinel_logrotate.conf.erb'),
143+
require => [
144+
Package['logrotate'],
145+
File["/etc/redis-sentinel_${sentinel_name}.conf"],
146+
]
147+
}
116148
}
117-
118149
}

0 commit comments

Comments
 (0)