summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authoriberezovskiy <iberezovskiy@mirantis.com>2015-07-28 13:24:22 +0300
committeriberezovskiy <iberezovskiy@mirantis.com>2015-08-18 16:23:57 +0300
commita53478afe9d379403392a912a9b0134955b539d8 (patch)
tree7f1a0dfc5ec6e6e9b8eeeed3b72e35553bdcdc3c
parent6a9a83d0d9da73a094bd29e5629b4c4b93d151bd (diff)
Implement Ceilometer-Redis plugin
In details: * Adapt Redis puppet module for plugin usage: - update tests - improvements for sentinel installation - uncomment CentOS params for plugin usage on next Fuel releases * Prepare main puppet script for: - Redis and sentinel installation - Work with ceilometer-agent-central service as pacemaker resource (remove old one and configure new with clone set) - Configure redis under pacemaker - Add ocf scripts for redis-server * Add tasks for plugin * Add metadata for plugin * Add Redis packages (2.8 version) and their dependencies * Use existing ceilometer network role for redis Partially implements: blueprint ceilometer-central-agent-ha Change-Id: I77c75e05b28f3ff4690e89034e345cc9c64af5e5
Notes
Notes (review): Verified+2: Jenkins Code-Review+1: Nadya Shakhat <nprivalova@mirantis.com> Code-Review+2: Ilya Tyaptin <ityaptin@mirantis.com> Workflow+1: Ilya Tyaptin <ityaptin@mirantis.com> Submitted-by: Jenkins Submitted-at: Thu, 24 Sep 2015 11:06:05 +0000 Reviewed-on: https://review.openstack.org/206469 Project: stackforge/fuel-plugin-ceilometer-redis Branch: refs/heads/master
-rw-r--r--deployment_scripts/puppet/manifests/controller.pp34
-rw-r--r--deployment_scripts/puppet/manifests/primary-controller.pp34
-rw-r--r--deployment_scripts/puppet/modules/redis/Rakefile15
-rw-r--r--deployment_scripts/puppet/modules/redis/files/ocf/redis-server348
-rw-r--r--deployment_scripts/puppet/modules/redis/lib/facter/check_mode.rb5
-rw-r--r--deployment_scripts/puppet/modules/redis/lib/puppet/parser/functions/redis_backend_url.rb21
-rw-r--r--deployment_scripts/puppet/modules/redis/lib/puppet/parser/functions/sentinel_confs.rb23
-rw-r--r--deployment_scripts/puppet/modules/redis/manifests/init.pp4
-rw-r--r--deployment_scripts/puppet/modules/redis/manifests/main.pp221
-rw-r--r--deployment_scripts/puppet/modules/redis/manifests/sentinel.pp36
-rw-r--r--deployment_scripts/puppet/modules/redis/manifests/sentinel_params.pp20
-rw-r--r--environment_config.yaml6
-rw-r--r--metadata.yaml34
-rw-r--r--pre_build_hook5
-rw-r--r--repositories/centos/jemalloc-3.6.0-1.el6.x86_64.rpmbin0 -> 102624 bytes
-rw-r--r--repositories/centos/redis-2.8.18-2.el6.remi.x86_64.rpmbin0 -> 400048 bytes
-rw-r--r--repositories/ubuntu/libjemalloc1_3.5.1-2_amd64.debbin0 -> 76810 bytes
-rw-r--r--repositories/ubuntu/redis-server_2%3a2.8.4-2_amd64.debbin0 -> 267446 bytes
-rw-r--r--repositories/ubuntu/redis-tools_2%3a2.8.4-2_amd64.debbin0 -> 65740 bytes
-rw-r--r--tasks.yaml15
20 files changed, 791 insertions, 30 deletions
diff --git a/deployment_scripts/puppet/manifests/controller.pp b/deployment_scripts/puppet/manifests/controller.pp
new file mode 100644
index 0000000..857ef23
--- /dev/null
+++ b/deployment_scripts/puppet/manifests/controller.pp
@@ -0,0 +1,34 @@
1# Copyright 2015 Mirantis, Inc.
2#
3# Licensed under the Apache License, Version 2.0 (the "License"); you may
4# not use this file except in compliance with the License. You may obtain
5# a copy of the License at
6#
7# http://www.apache.org/licenses/LICENSE-2.0
8#
9# Unless required by applicable law or agreed to in writing, software
10# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
11# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
12# License for the specific language governing permissions and limitations
13# under the License.
14
15prepare_network_config(hiera('network_scheme', {}))
16
17$redis_roles = ["primary-controller", "controller"]
18$redis_nodes = get_nodes_hash_by_roles(hiera('network_metadata'), $redis_roles)
19# Use ceilometer network role
20$redis_address_map = get_node_to_ipaddr_map_by_network_role($redis_nodes, 'ceilometer/api')
21$redis_hosts = values($redis_address_map)
22$redis_bind_address = get_network_role_property('ceilometer/api', 'ipaddr')
23
24# Set primary redis on primary-controller
25$redis_primary_nodes = get_nodes_hash_by_roles(hiera('network_metadata'), ["primary-controller"])
26$redis_primary_address_map = get_node_to_ipaddr_map_by_network_role($redis_primary_nodes, 'ceilometer/api')
27$primary_redis_node = values($redis_primary_address_map)
28
29class {'::redis::main':
30 primary_redis_node => $primary_redis_node[0],
31 redis_hosts => $redis_hosts,
32 redis_bind_address => $redis_bind_address,
33 primary_controller => false,
34}
diff --git a/deployment_scripts/puppet/manifests/primary-controller.pp b/deployment_scripts/puppet/manifests/primary-controller.pp
new file mode 100644
index 0000000..513387d
--- /dev/null
+++ b/deployment_scripts/puppet/manifests/primary-controller.pp
@@ -0,0 +1,34 @@
1# Copyright 2015 Mirantis, Inc.
2#
3# Licensed under the Apache License, Version 2.0 (the "License"); you may
4# not use this file except in compliance with the License. You may obtain
5# a copy of the License at
6#
7# http://www.apache.org/licenses/LICENSE-2.0
8#
9# Unless required by applicable law or agreed to in writing, software
10# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
11# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
12# License for the specific language governing permissions and limitations
13# under the License.
14
15prepare_network_config(hiera('network_scheme', {}))
16
17$redis_roles = ["primary-controller", "controller"]
18$redis_nodes = get_nodes_hash_by_roles(hiera('network_metadata'), $redis_roles)
19# Use ceilometer network role
20$redis_address_map = get_node_to_ipaddr_map_by_network_role($redis_nodes, 'ceilometer/api')
21$redis_hosts = values($redis_address_map)
22$redis_bind_address = get_network_role_property('ceilometer/api', 'ipaddr')
23
24# Set primary redis on primary-controller
25$redis_primary_nodes = get_nodes_hash_by_roles(hiera('network_metadata'), ["primary-controller"])
26$redis_primary_address_map = get_node_to_ipaddr_map_by_network_role($redis_primary_nodes, 'ceilometer/api')
27$primary_redis_node = values($redis_primary_address_map)
28
29class {'::redis::main':
30 primary_redis_node => $primary_redis_node[0],
31 redis_hosts => $redis_hosts,
32 redis_bind_address => $redis_bind_address,
33 primary_controller => true,
34}
diff --git a/deployment_scripts/puppet/modules/redis/Rakefile b/deployment_scripts/puppet/modules/redis/Rakefile
index 43e1b83..c6edbe0 100644
--- a/deployment_scripts/puppet/modules/redis/Rakefile
+++ b/deployment_scripts/puppet/modules/redis/Rakefile
@@ -1,6 +1,6 @@
1require 'rubygems'
1require 'puppetlabs_spec_helper/rake_tasks' 2require 'puppetlabs_spec_helper/rake_tasks'
2require 'puppet-lint/tasks/puppet-lint' 3require 'puppet-lint/tasks/puppet-lint'
3
4PuppetLint.configuration.fail_on_warnings 4PuppetLint.configuration.fail_on_warnings
5PuppetLint.configuration.send('relative') 5PuppetLint.configuration.send('relative')
6PuppetLint.configuration.send('disable_80chars') 6PuppetLint.configuration.send('disable_80chars')
@@ -9,3 +9,16 @@ PuppetLint.configuration.send('disable_class_parameter_defaults')
9PuppetLint.configuration.send('disable_documentation') 9PuppetLint.configuration.send('disable_documentation')
10PuppetLint.configuration.send('disable_single_quote_string_with_variables') 10PuppetLint.configuration.send('disable_single_quote_string_with_variables')
11PuppetLint.configuration.ignore_paths = ["spec/**/*.pp", "pkg/**/*.pp"] 11PuppetLint.configuration.ignore_paths = ["spec/**/*.pp", "pkg/**/*.pp"]
12
13desc "Validate manifests, templates, and ruby files in lib."
14task :validate do
15 Dir['manifests/**/*.pp'].each do |manifest|
16 sh "puppet parser validate --noop #{manifest}"
17 end
18 Dir['lib/**/*.rb'].each do |lib_file|
19 sh "ruby -c #{lib_file}"
20 end
21 Dir['templates/**/*.erb'].each do |template|
22 sh "erb -P -x -T '-' #{template} | ruby -c"
23 end
24end
diff --git a/deployment_scripts/puppet/modules/redis/files/ocf/redis-server b/deployment_scripts/puppet/modules/redis/files/ocf/redis-server
new file mode 100644
index 0000000..f731987
--- /dev/null
+++ b/deployment_scripts/puppet/modules/redis/files/ocf/redis-server
@@ -0,0 +1,348 @@
1#!/bin/sh
2#
3#
4# Redis Service (redis-server)
5#
6# Description:
7# Redis is an open source, BSD licensed, advanced key-value cache and store.
8# It is often referred to as a data structure server since keys can contain
9# strings, hashes, lists, sets, sorted sets, bitmaps and hyperloglogs.
10#
11#
12# License: Apache Software License (ASL) 2.0
13#
14#
15# See usage() function below for more details ...
16#
17# OCF instance parameters:
18# OCF_RESKEY_binary
19# OCF_RESKEY_config
20# OCF_RESKEY_user
21# OCF_RESKEY_pid
22# OCF_RESKEY_monitor_binary
23# OCF_RESKEY_redis_server_port
24# OCF_RESKEY_additional_parameters
25#######################################################################
26# Initialization:
27
28: ${OCF_FUNCTIONS_DIR=${OCF_ROOT}/lib/heartbeat}
29. ${OCF_FUNCTIONS_DIR}/ocf-shellfuncs
30
31#######################################################################
32
33# Fill in some defaults if no values are specified
34
35OCF_RESKEY_binary_default="redis-server"
36if [ -f "/etc/redis.conf" ]; then
37 OCF_RESKEY_config_default="/etc/redis.conf"
38else
39 OCF_RESKEY_config_default="/etc/redis/redis.conf"
40fi
41OCF_RESKEY_user_default="redis"
42OCF_RESKEY_pid_default="/var/run/redis/redis-server.pid"
43OCF_RESKEY_redis_server_port_default="6379"
44
45: ${OCF_RESKEY_binary=${OCF_RESKEY_binary_default}}
46: ${OCF_RESKEY_config=${OCF_RESKEY_config_default}}
47: ${OCF_RESKEY_user=${OCF_RESKEY_user_default}}
48: ${OCF_RESKEY_pid=${OCF_RESKEY_pid_default}}
49: ${OCF_RESKEY_redis_server_port=${OCF_RESKEY_redis_server_port_default}}
50
51#######################################################################
52
53usage() {
54 cat <<UEND
55 usage: $0 (start|stop|validate-all|meta-data|status|monitor)
56
57 $0 manages an Redis Service (redis-server) process as an HA resource
58
59 The 'start' operation starts the scheduler service.
60 The 'stop' operation stops the scheduler service.
61 The 'validate-all' operation reports whether the parameters are valid
62 The 'meta-data' operation reports this RA's meta-data information
63 The 'status' operation reports whether the scheduler service is running
64 The 'monitor' operation reports whether the scheduler service seems to be working
65
66UEND
67}
68
69meta_data() {
70 cat <<END
71<?xml version="1.0"?>
72<!DOCTYPE resource-agent SYSTEM "ra-api-1.dtd">
73<resource-agent name="redis-server">
74<version>1.0</version>
75
76<longdesc lang="en">
77Resource agent for the Redis Service (redis-server)
78May manage a redis-server instance or a clone set that
79creates a distributed redis-server cluster.
80</longdesc>
81<shortdesc lang="en">Manages the Redis Service (redis)</shortdesc>
82<parameters>
83
84<parameter name="binary" unique="0" required="0">
85<longdesc lang="en">
86Location of the Redis server binary (redis-server)
87</longdesc>
88<shortdesc lang="en">Redis server binary (redis-server)</shortdesc>
89<content type="string" default="${OCF_RESKEY_binary_default}" />
90</parameter>
91
92<parameter name="config" unique="0" required="0">
93<longdesc lang="en">
94Redis service (redis-server) configuration file
95</longdesc>
96<shortdesc lang="en">Rredis (redis-server) config file</shortdesc>
97<content type="string" default="${OCF_RESKEY_config_default}" />
98</parameter>
99
100<parameter name="user" unique="0" required="0">
101<longdesc lang="en">
102User running Redis Service (redis)
103</longdesc>
104<shortdesc lang="en">Redis Service (redis-server) user</shortdesc>
105<content type="string" default="${OCF_RESKEY_user_default}" />
106</parameter>
107
108<parameter name="pid" unique="0" required="0">
109<longdesc lang="en">
110The pid file to use for this Redis Service (redis-server) instance
111</longdesc>
112<shortdesc lang="en">Redis Service (redis-server) pid file</shortdesc>
113<content type="string" default="${OCF_RESKEY_pid_default}" />
114</parameter>
115
116<parameter name="redis_server_port" unique="0" required="0">
117<longdesc lang="en">
118The listening port number of the Redis server. Use for monitoring purposes
119</longdesc>
120<shortdesc lang="en">Redis server listening port</shortdesc>
121<content type="integer" default="${OCF_RESKEY_redis_server_port_default}" />
122</parameter>
123
124<parameter name="additional_parameters" unique="0" required="0">
125<longdesc lang="en">
126Additional parameters to pass on to the Redis Service (redis-server)
127</longdesc>
128<shortdesc lang="en">Additional parameters for redis-server</shortdesc>
129<content type="string" />
130</parameter>
131
132</parameters>
133
134<actions>
135<action name="start" timeout="20" />
136<action name="stop" timeout="20" />
137<action name="status" timeout="20" />
138<action name="monitor" timeout="30" interval="20" />
139<action name="validate-all" timeout="5" />
140<action name="meta-data" timeout="5" />
141</actions>
142</resource-agent>
143END
144}
145
146#######################################################################
147# Functions invoked by resource manager actions
148
149redis_server_check_port() {
150 local int
151 local cnt
152
153 int="$1"
154 cnt=${#int}
155 echo $int |egrep -qx '[0-9]+(:[0-9]+)?(,[0-9]+(:[0-9]+)?)*'
156
157 if [ $? -ne 0 ] || [ $cnt -ne 4 ]; then
158 ocf_log err "Invalid port number: $1"
159 exit $OCF_ERR_CONFIGURED
160 fi
161}
162
163redis_server_validate() {
164 local rc
165
166 check_binary $OCF_RESKEY_binary
167 check_binary netstat
168 redis_server_check_port $OCF_RESKEY_redis_server_port
169
170 # A config file on shared storage that is not available
171 # during probes is OK.
172 if [ ! -f $OCF_RESKEY_config ]; then
173 if ! ocf_is_probe; then
174 ocf_log err "Config $OCF_RESKEY_config doesn't exist"
175 return $OCF_ERR_INSTALLED
176 fi
177 ocf_log_warn "Config $OCF_RESKEY_config not available during a probe"
178 fi
179
180 getent passwd $OCF_RESKEY_user >/dev/null 2>&1
181 rc=$?
182 if [ $rc -ne 0 ]; then
183 ocf_log err "User $OCF_RESKEY_user doesn't exist"
184 return $OCF_ERR_INSTALLED
185 fi
186
187 true
188}
189
190redis_server_status() {
191 local pid
192 local rc
193
194 # check and make PID file dir
195 local PID_DIR="$( dirname ${OCF_RESKEY_pid} )"
196 if [ ! -d "${PID_DIR}" ] ; then
197 ocf_log debug "Create pid file dir: ${PID_DIR} and chown to ${OCF_RESKEY_user}"
198 mkdir -p "${PID_DIR}"
199 chown -R ${OCF_RESKEY_user} "${PID_DIR}"
200 chmod 755 "${PID_DIR}"
201 fi
202
203 if [ ! -f $OCF_RESKEY_pid ]; then
204 ocf_log info "Redis service (redis-server) is not running"
205 return $OCF_NOT_RUNNING
206 else
207 pid=`cat $OCF_RESKEY_pid`
208 fi
209
210 if [ -n "${pid}" ]; then
211 ocf_run -warn kill -s 0 $pid
212 rc=$?
213 else
214 ocf_log err "PID file ${OCF_RESKEY_pid} is empty!"
215 return $OCF_ERR_GENERIC
216 fi
217
218 if [ $rc -eq 0 ]; then
219 return $OCF_SUCCESS
220 else
221 ocf_log info "Old PID file found, but Redis service (redis-server) is not running"
222 return $OCF_NOT_RUNNING
223 fi
224}
225
226redis_server_monitor() {
227 local rc
228 local pid
229
230 redis_server_status
231 rc=$?
232
233 # If status returned anything but success, return that immediately
234 if [ $rc -ne $OCF_SUCCESS ]; then
235 return $rc
236 fi
237
238 ocf_log debug "Redis service (redis-server) monitor succeeded"
239 return $OCF_SUCCESS
240}
241
242redis_server_start() {
243 local rc
244
245 redis_server_status
246 rc=$?
247 if [ $rc -eq $OCF_SUCCESS ]; then
248 ocf_log info "Redis service (redis-server) already running"
249 return $OCF_SUCCESS
250 fi
251
252 # run the actual redis-server daemon. Don't use ocf_run as we're sending the tool's output
253 # straight to /dev/null anyway and using ocf_run would break stdout-redirection here.
254 su ${OCF_RESKEY_user} -s /bin/sh -c "${OCF_RESKEY_binary} $OCF_RESKEY_config \
255 $OCF_RESKEY_additional_parameters"' >> /dev/null 2>&1'
256
257 # Spin waiting for the server to come up.
258 while true; do
259 redis_server_monitor
260 rc=$?
261 [ $rc -eq $OCF_SUCCESS ] && break
262 if [ $rc -ne $OCF_NOT_RUNNING ]; then
263 ocf_log err "Redis service (redis_server) start failed"
264 exit $OCF_ERR_GENERIC
265 fi
266 sleep 3
267 done
268
269 ocf_log info "Redis service (redis_server) started"
270 return $OCF_SUCCESS
271}
272
273redis_server_stop() {
274 local rc
275 local pid
276
277 redis_server_status
278 rc=$?
279 if [ $rc -eq $OCF_NOT_RUNNING ]; then
280 ocf_log info "Redis service (redis-server) already stopped"
281 return $OCF_SUCCESS
282 fi
283
284 # Try SIGTERM
285 pid=`cat $OCF_RESKEY_pid`
286 ocf_run kill -s TERM $pid
287 rc=$?
288 if [ $rc -ne 0 ]; then
289 ocf_log err "Redis service (redis-server) couldn't be stopped"
290 exit $OCF_ERR_GENERIC
291 fi
292
293 # stop waiting
294 shutdown_timeout=15
295 if [ -n "$OCF_RESKEY_CRM_meta_timeout" ]; then
296 shutdown_timeout=$((($OCF_RESKEY_CRM_meta_timeout/1000)-5))
297 fi
298 count=0
299 while [ $count -lt $shutdown_timeout ]; do
300 redis_server_status
301 rc=$?
302 if [ $rc -eq $OCF_NOT_RUNNING ]; then
303 break
304 fi
305 count=`expr $count + 1`
306 sleep 1
307 ocf_log debug "Redis service (redis-server) still hasn't stopped yet. Waiting ..."
308 done
309
310 redis_server_status
311 rc=$?
312 if [ $rc -ne $OCF_NOT_RUNNING ]; then
313 # SIGTERM didn't help either, try SIGKILL
314 ocf_log info "Redis service (redis-server) failed to stop after ${shutdown_timeout}s \
315 using SIGTERM. Trying SIGKILL ..."
316 ocf_run kill -s KILL $pid
317 fi
318
319 ocf_log info "Redis service (redis-server) stopped"
320
321 ocf_log debug "Delete pid file: ${OCF_RESKEY_pid} with content $(cat $OCF_RESKEY_pid)"
322 rm -f $OCF_RESKEY_pid
323
324 return $OCF_SUCCESS
325}
326
327#######################################################################
328
329case "$1" in
330 meta-data) meta_data
331 exit $OCF_SUCCESS;;
332 usage|help) usage
333 exit $OCF_SUCCESS;;
334esac
335
336# Anything except meta-data and help must pass validation
337redis_server_validate || exit $?
338
339# What kind of method was invoked?
340case "$1" in
341 start) redis_server_start;;
342 stop) redis_server_stop;;
343 status) redis_server_status;;
344 monitor) redis_server_monitor;;
345 validate-all) ;;
346 *) usage
347 exit $OCF_ERR_UNIMPLEMENTED;;
348esac
diff --git a/deployment_scripts/puppet/modules/redis/lib/facter/check_mode.rb b/deployment_scripts/puppet/modules/redis/lib/facter/check_mode.rb
new file mode 100644
index 0000000..eea5dc8
--- /dev/null
+++ b/deployment_scripts/puppet/modules/redis/lib/facter/check_mode.rb
@@ -0,0 +1,5 @@
1Facter.add('cluster_mode') do
2 setcode do
3 Facter::Util::Resolution.exec("cat /etc/astute.yaml | grep deployment_mode | awk '{print $2}'")
4 end
5end
diff --git a/deployment_scripts/puppet/modules/redis/lib/puppet/parser/functions/redis_backend_url.rb b/deployment_scripts/puppet/modules/redis/lib/puppet/parser/functions/redis_backend_url.rb
new file mode 100644
index 0000000..550fd0a
--- /dev/null
+++ b/deployment_scripts/puppet/modules/redis/lib/puppet/parser/functions/redis_backend_url.rb
@@ -0,0 +1,21 @@
1module Puppet::Parser::Functions
2 newfunction(:redis_backend_url, :type => :rvalue) do |args|
3 if args.length != 3
4 raise "Wrong number of arguments"
5 end
6 nodes = args[0]
7 port = args[1]
8 timeout = args[2]
9
10 backend_url="redis://" + nodes[0] + ":" + port + "?sentinel=" + nodes[0]
11
12 nodes.each do |value|
13 if value != nodes[0]
14 backend_url=backend_url + "&sentinel_fallback=" + value + ":" + port
15 end
16 end
17 backend_url=backend_url + "&timeout=" + timeout
18
19 backend_url
20 end
21end
diff --git a/deployment_scripts/puppet/modules/redis/lib/puppet/parser/functions/sentinel_confs.rb b/deployment_scripts/puppet/modules/redis/lib/puppet/parser/functions/sentinel_confs.rb
new file mode 100644
index 0000000..d0b151a
--- /dev/null
+++ b/deployment_scripts/puppet/modules/redis/lib/puppet/parser/functions/sentinel_confs.rb
@@ -0,0 +1,23 @@
1module Puppet::Parser::Functions
2 newfunction(:sentinel_confs, :type => :rvalue) do |args|
3 if args.length != 6
4 raise "Wrong number of arguments"
5 end
6 nodes = args[0]
7 port = args[1]
8 quorum = args[2]
9 parallel_syncs = args[3]
10 down_after_milliseconds = args[4]
11 failover_timeout = args[5]
12 hash = {}
13
14 nodes.each do |value|
15 hash[value] = { 'monitor' => value + ' ' + port + ' ' + quorum,
16 'down-after-milliseconds' => down_after_milliseconds,
17 'failover-timeout' => failover_timeout,
18 'parallel-syncs' => parallel_syncs }
19 end
20
21 hash
22 end
23end
diff --git a/deployment_scripts/puppet/modules/redis/manifests/init.pp b/deployment_scripts/puppet/modules/redis/manifests/init.pp
index d2d3814..fa880e4 100644
--- a/deployment_scripts/puppet/modules/redis/manifests/init.pp
+++ b/deployment_scripts/puppet/modules/redis/manifests/init.pp
@@ -161,8 +161,8 @@ class redis (
161 file { $conf_redis: 161 file { $conf_redis:
162 path => $conf_redis, 162 path => $conf_redis,
163 content => template('redis/redis.conf.erb'), 163 content => template('redis/redis.conf.erb'),
164 owner => root, 164 owner => redis,
165 group => root, 165 group => redis,
166 mode => '0644', 166 mode => '0644',
167 require => Package['redis'], 167 require => Package['redis'],
168 } 168 }
diff --git a/deployment_scripts/puppet/modules/redis/manifests/main.pp b/deployment_scripts/puppet/modules/redis/manifests/main.pp
new file mode 100644
index 0000000..baa84ba
--- /dev/null
+++ b/deployment_scripts/puppet/modules/redis/manifests/main.pp
@@ -0,0 +1,221 @@
1#
2# == Class: redis::main
3#
4# Installs and configures Redis
5#
6# === Parameters:
7#
8# [*primary_controller*]
9# Status of controller node
10# Defaults to false
11#
12# [*parallel_syncs*]
13# How many slaves we can reconfigure to point to the new slave simultaneously
14# during the failover
15# Defaults to 2
16#
17# [*quorum*]
18# Tells Sentinel to monitor this master, and to consider it in O_DOWN
19# (Objectively Down) state only if at least <quorum> sentinels agree
20# Defaults to 2
21#
22# [*down_after_milliseconds*]
23# Number of milliseconds the master (or any attached slave or sentinel) should
24# be unreachable (as in, not acceptable reply to PING, continuously, for the
25# specified period) in order to consider it in S_DOWN state (Subjectively Down)
26# Defaults to 30000
27#
28# [*failover_timeout*]
29# Specifies the failover timeout in milliseconds
30# Defaults to 60000
31#
32# [*timeout*]
33# Specifes timeout for ceilometer coordination url
34# Defaults to 10
35#
36# [*redis_port*]
37# Port for redis-server to listen on
38# Defaults to '6379'
39#
40# [*redis_sentinel_port*]
41# Port for redis-sentinel to listen on
42# Defaults to '26379'
43#
44
45class redis::main (
46 $primary_controller = false,
47 $parallel_syncs = '2',
48 $quorum = '2',
49 $down_after_milliseconds = '30000',
50 $failover_timeout = '60000',
51 $timeout = '10',
52 $primary_redis_node = '127.0.0.1',
53 $redis_hosts = ['127.0.0.1'],
54 $redis_bind_address = '0.0.0.0',
55 $redis_port = '6379',
56 $redis_sentinel_port = '26379',
57) {
58
59 include ceilometer::params
60 include redis::params
61
62 case $::osfamily {
63 'RedHat': {
64 $manage_upstart_scripts = false
65 }
66 'Debian': {
67 $manage_upstart_scripts = true
68 }
69 default: {
70 fail("Unsupported osfamily: ${::osfamily} operatingsystem: ${::operatingsystem}")
71 }
72 }
73
74 firewall {'121 redis_port':
75 port => $redis_port,
76 proto => 'tcp',
77 action => 'accept',
78 }
79
80 firewall {'122 redis_sentinel_port':
81 port => $redis_sentinel_port,
82 proto => 'tcp',
83 action => 'accept',
84 }
85
86 if $primary_controller {
87 $conf_slaveof = undef
88 } else {
89 $conf_slaveof = "$primary_redis_node $redis_port"
90 }
91
92 # Use custom function to generate sentinel configuration
93 $sentinel_confs = sentinel_confs($redis_hosts, $redis_port, $quorum,
94 $parallel_syncs, $down_after_milliseconds,
95 $failover_timeout)
96
97 package {'python-redis':
98 ensure => 'present',
99 } ->
100
101 class { '::redis':
102 conf_bind => $redis_bind_address,
103 conf_slave_read_only => 'no',
104 service_enable => false,
105 service_ensure => 'stopped',
106 conf_slaveof => $conf_slaveof,
107 } ->
108
109 class { '::redis::sentinel':
110 conf_port => $redis_sentinel_port,
111 sentinel_confs => $sentinel_confs,
112 manage_upstart_scripts => $manage_upstart_scripts,
113 }
114
115 ceilometer_config {
116 'coordination/backend_url' : value => redis_backend_url($redis_hosts, $redis_sentinel_port, $timeout);
117 'coordination/heartbeat' : value => '1.0';
118 'coordination/check_watchers' : value => $timeout;
119 }
120
121 if $primary_controller {
122 exec {'remove_old_resource_central_agent':
123 path => '/usr/sbin:/usr/bin:/sbin:/bin',
124 command => 'pcs resource delete p_ceilometer-agent-central --wait=120',
125 onlyif => 'pcs resource show p_ceilometer-agent-central > /dev/null 2>&1',
126 }
127
128 Exec['remove_old_resource_central_agent'] -> Cluster::Corosync::Cs_service["$::ceilometer::params::agent_central_service_name"]
129 }
130
131 file {'redis_ocf_script':
132 path => '/usr/lib/ocf/resource.d/fuel/redis-server',
133 owner => 'root',
134 group => 'root',
135 mode => '0755',
136 source => 'puppet:///modules/redis/ocf/redis-server'
137 }
138
139 cluster::corosync::cs_service { "$::ceilometer::params::agent_central_service_name":
140 ocf_script => 'ceilometer-agent-central',
141 csr_parameters => {},
142 csr_metadata => undef,
143 csr_complex_type => 'clone',
144 csr_ms_metadata => { 'interleave' => true },
145 csr_mon_intr => '20',
146 csr_mon_timeout => '10',
147 csr_timeout => '60',
148 service_name => $::ceilometer::params::agent_central_service_name,
149 package_name => $::ceilometer::params::agent_central_package_name,
150 service_title => 'ceilometer-agent-central',
151 primary => $primary_controller,
152 hasrestart => false,
153 }
154
155 cluster::corosync::cs_service { 'redis':
156 ocf_script => 'redis-server',
157 csr_parameters => {},
158 csr_metadata => undef,
159 csr_complex_type => 'clone',
160 csr_ms_metadata => { 'interleave' => true },
161 csr_mon_intr => '20',
162 csr_mon_timeout => '10',
163 csr_timeout => '60',
164 service_name => $::redis::params::service,
165 package_name => $::redis::params::package,
166 service_title => 'redis',
167 primary => $primary_controller,
168 hasrestart => false,
169 }
170
171
172 File['redis_ocf_script'] ->
173 Cluster::Corosync::Cs_service['redis'] ->
174 Ceilometer_config <||> ->
175 Cluster::Corosync::Cs_service["$::ceilometer::params::agent_central_service_name"]
176
177 if !$primary_controller {
178 exec {'waiting-for-agent-up-on-primary':
179 tries => 10,
180 try_sleep => 30,
181 command => "pcs resource | grep -A 1 p_${::ceilometer::params::agent_central_service_name} | grep Started > /dev/null 2>&1",
182 path => '/usr/sbin:/usr/bin:/sbin:/bin',
183 }
184
185 exec {'waiting-for-redis-up-on-primary':
186 tries => 10,
187 try_sleep => 30,
188 command => "pcs resource | grep -A 1 p_${::redis::params::service} | grep Started > /dev/null 2>&1",
189 path => '/usr/sbin:/usr/bin:/sbin:/bin',
190 }
191
192 service {"p_${::ceilometer::params::agent_central_service_name}":
193 enable => true,
194 ensure => 'running',
195 hasstatus => true,
196 hasrestart => true,
197 provider => 'pacemaker',
198 }
199
200 service {"p_${::redis::params::service}":
201 enable => true,
202 ensure => 'running',
203 hasstatus => true,
204 hasrestart => true,
205 provider => 'pacemaker',
206 }
207
208 Exec['waiting-for-redis-up-on-primary'] ->
209 Service["p_${::redis::params::service}"] ->
210 Cluster::Corosync::Cs_service['redis'] ->
211 Exec['waiting-for-agent-up-on-primary'] ->
212 Ceilometer_config <||> ->
213 Cluster::Corosync::Cs_service["$::ceilometer::params::agent_central_service_name"]
214 }
215
216 service { 'ceilometer-agent-central':
217 ensure => 'stopped',
218 name => $::ceilometer::params::agent_central_service_name,
219 enable => false,
220 }
221}
diff --git a/deployment_scripts/puppet/modules/redis/manifests/sentinel.pp b/deployment_scripts/puppet/modules/redis/manifests/sentinel.pp
index fa9c3ed..ded9a87 100644
--- a/deployment_scripts/puppet/modules/redis/manifests/sentinel.pp
+++ b/deployment_scripts/puppet/modules/redis/manifests/sentinel.pp
@@ -50,6 +50,7 @@ class redis::sentinel (
50) { 50) {
51 51
52 include redis::sentinel_params 52 include redis::sentinel_params
53 include redis
53 54
54 $conf_sentinel = $redis::sentinel_params::conf 55 $conf_sentinel = $redis::sentinel_params::conf
55 $conf_sentinel_orig = "${conf_sentinel}.puppet" 56 $conf_sentinel_orig = "${conf_sentinel}.puppet"
@@ -74,18 +75,13 @@ class redis::sentinel (
74 $conf_logfile_real = $::redis::sentinel_params::logfile 75 $conf_logfile_real = $::redis::sentinel_params::logfile
75 } 76 }
76 77
77 package { 'redis':
78 ensure => $package_ensure,
79 name => $package,
80 }
81
82 if $manage_upstart_scripts == true { 78 if $manage_upstart_scripts == true {
83 service { 'sentinel': 79 service { 'sentinel':
84 ensure => $service_ensure, 80 ensure => $service_ensure,
85 name => $service, 81 name => $service,
86 hasrestart => true, 82 hasrestart => true,
87 hasstatus => true, 83 hasstatus => true,
88 require => [ File[$conf_sentinel_orig], 84 require => [ File[$conf_sentinel],
89 File[$upstart_script] ], 85 File[$upstart_script] ],
90 provider => 'upstart' 86 provider => 'upstart'
91 } 87 }
@@ -97,7 +93,7 @@ class redis::sentinel (
97 hasrestart => true, 93 hasrestart => true,
98 hasstatus => true, 94 hasstatus => true,
99 require => [ Package['redis'], 95 require => [ Package['redis'],
100 File[$conf_sentinel_orig] ], 96 File[$conf_sentinel] ],
101 } 97 }
102 } 98 }
103 99
@@ -107,26 +103,33 @@ class redis::sentinel (
107 # only if it changed. 103 # only if it changed.
108 file { $conf_sentinel_orig: 104 file { $conf_sentinel_orig:
109 content => template('redis/sentinel.conf.erb'), 105 content => template('redis/sentinel.conf.erb'),
110 owner => redis, 106 owner => root,
111 group => redis, 107 group => root,
112 mode => '0644', 108 mode => '0644',
113 require => Package['redis'], 109 require => Package['redis'],
114 notify => Exec["cp ${conf_sentinel_orig} ${conf_sentinel}"],
115 } 110 }
116 111
117 file { $conf_sentinel: 112 file { $conf_sentinel:
118 owner => redis, 113 owner => redis,
119 group => redis, 114 group => redis,
120 require => Package['redis'], 115 require => [ Package['redis'],
116 Exec["cp ${conf_sentinel_orig} ${conf_sentinel}"] ],
117 }
118
119 exec {"mv ${conf_sentinel} ${conf_sentinel}.original":
120 path => '/bin:/usr/bin:/sbin:/usr/sbin',
121 user => root,
122 group => root,
123 require => [ Package['redis'],
124 File[$conf_sentinel_orig] ],
121 } 125 }
122 126
123 exec { "cp ${conf_sentinel_orig} ${conf_sentinel}": 127 exec { "cp ${conf_sentinel_orig} ${conf_sentinel}":
124 path => '/bin:/usr/bin:/sbin:/usr/sbin', 128 path => '/bin:/usr/bin:/sbin:/usr/sbin',
125 refreshonly => true, 129 user => root,
126 user => redis, 130 group => root,
127 group => redis,
128 notify => Service['sentinel'], 131 notify => Service['sentinel'],
129 require => File[$conf_sentinel], 132 require => Exec["mv ${conf_sentinel} ${conf_sentinel}.original"],
130 } 133 }
131 134
132 file { $conf_logrotate: 135 file { $conf_logrotate:
@@ -138,8 +141,7 @@ class redis::sentinel (
138 } 141 }
139 142
140 if $service_restart == true { 143 if $service_restart == true {
141 # https://github.com/fsalum/puppet-redis/pull/28 144 File[$conf_sentinel] ~> Service['sentinel']
142 File[$conf_sentinel_orig] ~> Service['sentinel']
143 } 145 }
144 146
145 if $manage_upstart_scripts == true { 147 if $manage_upstart_scripts == true {
diff --git a/deployment_scripts/puppet/modules/redis/manifests/sentinel_params.pp b/deployment_scripts/puppet/modules/redis/manifests/sentinel_params.pp
index 5fc8bf7..3e7c6ae 100644
--- a/deployment_scripts/puppet/modules/redis/manifests/sentinel_params.pp
+++ b/deployment_scripts/puppet/modules/redis/manifests/sentinel_params.pp
@@ -14,16 +14,16 @@ class redis::sentinel_params {
14 14
15 case $::osfamily { 15 case $::osfamily {
16 # TODO: add redhat support 16 # TODO: add redhat support
17 #'redhat': { 17 'redhat': {
18 # $package = 'redis' 18 $package = 'redis'
19 # $service = 'redis-sentinel' 19 $service = 'redis-sentinel'
20 # $conf = '/etc/sentinel.conf' 20 $conf = '/etc/redis-sentinel.conf'
21 # $conf_dir = undef 21 $conf_dir = undef
22 # $conf_logrotate = '/etc/logrotate.d/sentinel' 22 $conf_logrotate = '/etc/logrotate.d/sentinel'
23 # $pidfile = '/var/run/redis/sentinel.pid' 23 $pidfile = '/var/run/redis/sentinel.pid'
24 # $logfile = '/var/log/redis/sentinel.log' 24 $logfile = '/var/log/redis/sentinel.log'
25 # $upstart_script = '/etc/init/redis-sentinel.conf' 25 $upstart_script = '/etc/init/redis-sentinel.conf'
26 #} 26 }
27 'debian': { 27 'debian': {
28 $package = 'redis-server' 28 $package = 'redis-server'
29 $service = 'redis-sentinel' 29 $service = 'redis-sentinel'
diff --git a/environment_config.yaml b/environment_config.yaml
new file mode 100644
index 0000000..7e0bf6f
--- /dev/null
+++ b/environment_config.yaml
@@ -0,0 +1,6 @@
1attributes:
2 # Install redis only if ceilometer is enabled
3 metadata:
4 restrictions:
5 - condition: settings:additional_components.ceilometer.value == false
6 action: hide
diff --git a/metadata.yaml b/metadata.yaml
new file mode 100644
index 0000000..b375803
--- /dev/null
+++ b/metadata.yaml
@@ -0,0 +1,34 @@
1# Plugin name
2name: ceilometer-redis
3# Human-readable name for your plugin
4title: Redis plugin for Ceilometer
5# Plugin version
6version: 1.0.0
7# Description
8description: Ceilometer extension that provide workload-partitioning and HA for ceilometer services
9# Required fuel version
10fuel_version: ['7.0']
11# Specify license of your plugin
12licenses: ['Apache License Version 2.0']
13# Specify author or company name
14authors: ['Ivan Berezovskiy', 'Ilya Tyaptin']
15# A link to the plugin's page
16homepage: 'https://github.com/stackforge/fuel-plugin-ceilometer-redis'
17# Groups
18groups: []
19
20# The plugin is compatible with releases in the list
21releases:
22 - os: ubuntu
23 version: 2015.1.0-7.0
24 mode: ['ha']
25 deployment_scripts_path: deployment_scripts/
26 repository_path: repositories/ubuntu
27# - os: centos
28# version: 2015.1.0-7.0
29# mode: ['ha']
30# deployment_scripts_path: deployment_scripts/
31# repository_path: repositories/centos
32
33# Version of plugin package
34package_version: '2.0.0'
diff --git a/pre_build_hook b/pre_build_hook
new file mode 100644
index 0000000..dc05e98
--- /dev/null
+++ b/pre_build_hook
@@ -0,0 +1,5 @@
1#!/bin/bash
2
3# Add here any the actions which are required before plugin build
4# like packages building, packages downloading from mirrors and so on.
5# The script should return 0 if there were no errors.
diff --git a/repositories/centos/jemalloc-3.6.0-1.el6.x86_64.rpm b/repositories/centos/jemalloc-3.6.0-1.el6.x86_64.rpm
new file mode 100644
index 0000000..1a74ad1
--- /dev/null
+++ b/repositories/centos/jemalloc-3.6.0-1.el6.x86_64.rpm
Binary files differ
diff --git a/repositories/centos/redis-2.8.18-2.el6.remi.x86_64.rpm b/repositories/centos/redis-2.8.18-2.el6.remi.x86_64.rpm
new file mode 100644
index 0000000..7c2cf22
--- /dev/null
+++ b/repositories/centos/redis-2.8.18-2.el6.remi.x86_64.rpm
Binary files differ
diff --git a/repositories/ubuntu/libjemalloc1_3.5.1-2_amd64.deb b/repositories/ubuntu/libjemalloc1_3.5.1-2_amd64.deb
new file mode 100644
index 0000000..639c166
--- /dev/null
+++ b/repositories/ubuntu/libjemalloc1_3.5.1-2_amd64.deb
Binary files differ
diff --git a/repositories/ubuntu/redis-server_2%3a2.8.4-2_amd64.deb b/repositories/ubuntu/redis-server_2%3a2.8.4-2_amd64.deb
new file mode 100644
index 0000000..2a5221e
--- /dev/null
+++ b/repositories/ubuntu/redis-server_2%3a2.8.4-2_amd64.deb
Binary files differ
diff --git a/repositories/ubuntu/redis-tools_2%3a2.8.4-2_amd64.deb b/repositories/ubuntu/redis-tools_2%3a2.8.4-2_amd64.deb
new file mode 100644
index 0000000..df94450
--- /dev/null
+++ b/repositories/ubuntu/redis-tools_2%3a2.8.4-2_amd64.deb
Binary files differ
diff --git a/tasks.yaml b/tasks.yaml
new file mode 100644
index 0000000..9cc7ec9
--- /dev/null
+++ b/tasks.yaml
@@ -0,0 +1,15 @@
1- role: ['primary-controller']
2 stage: post_deployment
3 type: puppet
4 parameters:
5 puppet_manifest: puppet/manifests/primary-controller.pp
6 puppet_modules: puppet/modules:/etc/puppet/modules
7 timeout: 720
8
9- role: ['controller']
10 stage: post_deployment
11 type: puppet
12 parameters:
13 puppet_manifest: puppet/manifests/controller.pp
14 puppet_modules: puppet/modules:/etc/puppet/modules
15 timeout: 720