-
Notifications
You must be signed in to change notification settings - Fork 68
/
Copy pathinit.pp
211 lines (196 loc) · 7.35 KB
/
init.pp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
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
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
# == Class: redis
#
# Install and configure a Redis server
#
# === Parameters
#
# All the redis.conf parameters can be passed to the class.
# See below for a complete list of parameters accepted.
#
# Check the README.md file for any further information about parameters for this class.
#
# === 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 (
$conf_activerehashing = 'yes',
$conf_aof_rewrite_incremental_fsync = 'yes', # 2.6+
$conf_append = {}, # hash of custom variables+values
$conf_appendfilename = undef, # default appendonly.aof
$conf_appendfsync = 'everysec',
$conf_appendonly = 'no',
$conf_auto_aof_rewrite_min_size = '64mb',
$conf_auto_aof_rewrite_percentage = '100',
$conf_bind = '0.0.0.0',
$conf_client_output_buffer_limit_normal = '0 0 0', # 2.6+
$conf_client_output_buffer_limit_pubsub = '32mb 8mb 60', # 2.6+
$conf_client_output_buffer_limit_slave = '256mb 64mb 60', # 2.6+
$conf_daemonize = 'yes',
$conf_databases = '16',
$conf_dbfilename = 'dump.rdb',
$conf_dir = '/var/lib/redis/',
$conf_glueoutputbuf = undef,
$conf_hash_max_zipmap_entries = '512',
$conf_hash_max_zipmap_value = '64',
$conf_hll_sparse_max_bytes = undef, # default 3000, 2.8.5?+
$conf_hz = '10', # 2.6+
$conf_include = [], # array of custom include files
$conf_list_max_ziplist_entries = '512',
$conf_list_max_ziplist_value = '64',
$conf_logfile = undef, #default ""
$conf_loglevel = 'notice',
$conf_lua_time_limit = '5000', # 2.6+
$conf_masterauth = undef,
$conf_maxclients = undef, # default 10000 in 2.6+
$conf_maxmemory = undef,
$conf_maxmemory_policy = undef,
$conf_maxmemory_samples = undef,
$conf_min_slaves_max_lag = undef, # default 10, 2.8+
$conf_min_slaves_to_write = undef, # 2.8+
$conf_no_appendfsync_on_rewrite = 'no',
$conf_nosave = undef,
$conf_notify_keyspace_events = undef, # 2.8+
$conf_pidfile = undef,
$conf_port = '6379',
$conf_rdbchecksum = 'yes', # 2.6+
$conf_rdbcompression = 'yes',
$conf_repl_backlog_size = '1mb', # 2,8+
$conf_repl_backlog_ttl = '3600', # 2.8+
$conf_repl_disable_tcp_nodelay = 'no', # 2,6+
$conf_repl_ping_slave_period = '10', # 2.4+
$conf_repl_timeout = '60', # 2.4+
$conf_requirepass = undef,
$conf_save = {'900' =>'1', '300' => '10', '60' => '10000'},
$conf_set_max_intset_entries = '512',
$conf_slave_priority = undef, # 2.6+
$conf_slave_read_only = 'yes', # 2.6+
$conf_slave_serve_stale_data = 'yes',
$conf_slaveof = undef,
$conf_slowlog_log_slower_than = '10000',
$conf_slowlog_max_len = '128',
$conf_stop_writes_on_bgsave_error = 'yes', # 2.6+
$conf_syslog_enabled = undef,
$conf_syslog_facility = undef,
$conf_syslog_ident = undef,
$conf_tcp_backlog = undef, # default is 511, 2.8.5+
$conf_tcp_keepalive = '0', # 2.6+
$conf_timeout = '0',
$conf_unixsocket = '/tmp/redis.sock', # 2.2+
$conf_unixsocketperm = '755', # 2.4+
$conf_vm_enabled = 'no', # deprecated in 2.4+
$conf_vm_max_memory = '0', # deprecated in 2.4+
$conf_vm_max_threads = '4', # deprecated in 2.4+
$conf_vm_page_size = '32', # deprecated in 2.4+
$conf_vm_pages = '134217728', # deprecated in 2.4+
$conf_vm_swap_file = '/tmp/redis.swap', # deprecated in 2.4+
$conf_zset_max_ziplist_entries = '128', # 2.4+
$conf_zset_max_ziplist_value = '64', # 2.4+
$package_ensure = 'present',
$package_name = undef,
$redis_version_override = undef,
$service_enable = true,
$service_ensure = 'running',
$service_restart = true,
$system_sysctl = false,
) {
include redis::params
$conf_redis = $redis::params::conf
$conf_logrotate = $redis::params::conf_logrotate
$service = $redis::params::service
if $redis_version_override {
$redis_version_real = $redis_version_override
} else {
$redis_version_real = $package_ensure ? {
/2\.2\..*/ => '2.2.x',
/2\.4\..*/ => '2.4.x',
/2\.6\..*/ => '2.6.x',
/2\.8\..*/ => '2.8.x',
default => $::redis_version
}
}
if $package_name {
$package = $package_name
}else{
$package = $redis::params::package
}
if $conf_pidfile {
$conf_pidfile_real = $conf_pidfile
}else{
$conf_pidfile_real = $::redis::params::pidfile
}
if $conf_logfile {
$conf_logfile_real = $conf_logfile
}else{
$conf_logfile_real = $::redis::params::logfile
}
package { 'redis':
ensure => $package_ensure,
name => $package,
}
service { 'redis':
ensure => $service_ensure,
name => $service,
enable => $service_enable,
hasrestart => true,
hasstatus => true,
require => [ Package['redis'],
Exec[$conf_dir],
File[$conf_redis] ],
}
file { $conf_redis:
path => $conf_redis,
content => template('redis/redis.conf.erb'),
owner => root,
group => root,
mode => '0644',
require => Package['redis'],
}
file { $conf_logrotate:
path => $conf_logrotate,
content => template('redis/logrotate.erb'),
owner => root,
group => root,
mode => '0644',
}
exec { $conf_dir:
path => '/bin:/usr/bin:/sbin:/usr/sbin',
command => "mkdir -p ${conf_dir}",
user => root,
group => root,
creates => $conf_dir,
before => Service['redis'],
require => Package['redis'],
}
file { $conf_dir:
ensure => directory,
owner => redis,
group => redis,
mode => '0755',
before => Service['redis'],
require => Exec[$conf_dir],
}
if ( $system_sysctl == true ) {
# add necessary kernel parameters
# see the redis admin guide here: http://redis.io/topics/admin
sysctl { 'vm.overcommit_memory':
value => '1',
}
}
if $service_restart == true {
# https://github.com/fsalum/puppet-redis/pull/28
Exec[$conf_dir] ~> Service['redis']
File[$conf_redis] ~> Service['redis']
}
}