Ori.livneh has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/63438


Change subject: Add Redis module
......................................................................

Add Redis module

The simple syntax of redis config files makes them easy to generate
programmatically. I exploit that here, making the redis module quite simple by
default but exposing the full range of configuration options via the 'settings'
hash.

Change-Id: Ic7df04197019448aa77516ad30794643ebd9700b
---
A puppet/modules/redis/manifests/init.pp
A puppet/modules/redis/templates/redis.conf.erb
2 files changed, 97 insertions(+), 0 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/vagrant 
refs/changes/38/63438/1

diff --git a/puppet/modules/redis/manifests/init.pp 
b/puppet/modules/redis/manifests/init.pp
new file mode 100644
index 0000000..4c67652
--- /dev/null
+++ b/puppet/modules/redis/manifests/init.pp
@@ -0,0 +1,87 @@
+# == Class: redis
+#
+# Redis is a fast in-memory key-value store, like memcached, but with
+# support for rich data types. MediaWiki can use Redis as a back-end for
+# the job queue.
+#
+# === Parameters
+#
+# [*max_memory*]
+#   This parameter specifies the maximum amount of memory Redis will be
+#   allowed to consume. Legal units include 'kb', 'mb', and 'gb'. If no
+#   unit is specified, the value is measured in bytes. Default: '16mb'.
+#
+# [*persist*]
+#   If true, redis will sync its contents to disk every 60 seconds,
+#   provided at least one key has changed. If you need more granular
+#   control, see the documentation for the 'settings' parameter below.
+#   Default: false.
+#
+# [*settings*]
+#   A hash-map of Redis config => value pairs. Empty by default. Its
+#   contents are merged onto the default settings map and the result is
+#   used to generate a redis.conf file.
+#
+#   For a full listing of configuration options and their meaning, see
+#   <https://raw.github.com/antirez/redis/2.6/redis.conf>.
+#
+# === Examples
+#
+# If the configuration key contains a hyphen, use an underscore
+# instead:
+#
+#  class { 'redis':
+#    max_memory => '2mb',
+#    settings   => {
+#      maxmemory_policy => 'volatile-lru',
+#      masterauth       => 'secret',
+#    }
+#  }
+#
+class redis(
+       $max_memory = '16mb',
+       $persist    = false,
+       $settings   = {},
+) {
+       $save = $persist ? {
+               true    => [ '60', '1' ],
+               default => undef,
+       }
+
+       $defaults = {
+               daemonize  => 'yes',
+               pidfile    => '/var/run/redis/redis-server.pid',
+               logfile    => '/var/log/redis/redis-server.log',
+               dir        => '/srv/redis',
+               dbfilename => 'redis-db.rdb',
+               maxmemory  => $max_memory,
+               maxclients => 1000,
+               save       => $save,
+       }
+
+       package { 'redis-server':
+               ensure => '2:2.6.3-wmf1',
+       }
+
+       file { '/srv/redis':
+               ensure  => directory,
+               owner   => 'redis',
+               group   => 'redis',
+               mode    => '0755',
+       }
+
+       file { '/etc/redis/redis.conf':
+               content => template('redis/redis.conf.erb'),
+               require => Package['redis-server'],
+       }
+
+       service { 'redis-server':
+               ensure    => running,
+               provider  => init,
+               subscribe => File['/etc/redis/redis.conf'],
+               require  => [
+                       File['/etc/redis/redis.conf', '/srv/redis'],
+                       Package['redis-server'],
+               ],
+       }
+}
diff --git a/puppet/modules/redis/templates/redis.conf.erb 
b/puppet/modules/redis/templates/redis.conf.erb
new file mode 100644
index 0000000..2326e0d
--- /dev/null
+++ b/puppet/modules/redis/templates/redis.conf.erb
@@ -0,0 +1,10 @@
+# Configuration file for Redis, an in-memory key-value store.
+# This file is managed by Puppet.
+
+<%=
+    @defaults.merge(@settings).select { |k,v|
+        v and v.to_s != 'undef'
+    }.map { |k,v|
+        [k.tr('_','-')].push(v).flatten.join(' ')
+    }.sort.join("\n")
+%>

-- 
To view, visit https://gerrit.wikimedia.org/r/63438
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: Ic7df04197019448aa77516ad30794643ebd9700b
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/vagrant
Gerrit-Branch: master
Gerrit-Owner: Ori.livneh <[email protected]>

_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to