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
This commit is contained in:
parent
6a9a83d0d9
commit
a53478afe9
|
@ -0,0 +1,34 @@
|
||||||
|
# Copyright 2015 Mirantis, Inc.
|
||||||
|
#
|
||||||
|
# Licensed under the Apache License, Version 2.0 (the "License"); you may
|
||||||
|
# not use this file except in compliance with the License. You may obtain
|
||||||
|
# a copy of the License at
|
||||||
|
#
|
||||||
|
# http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
#
|
||||||
|
# Unless required by applicable law or agreed to in writing, software
|
||||||
|
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||||
|
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||||
|
# License for the specific language governing permissions and limitations
|
||||||
|
# under the License.
|
||||||
|
|
||||||
|
prepare_network_config(hiera('network_scheme', {}))
|
||||||
|
|
||||||
|
$redis_roles = ["primary-controller", "controller"]
|
||||||
|
$redis_nodes = get_nodes_hash_by_roles(hiera('network_metadata'), $redis_roles)
|
||||||
|
# Use ceilometer network role
|
||||||
|
$redis_address_map = get_node_to_ipaddr_map_by_network_role($redis_nodes, 'ceilometer/api')
|
||||||
|
$redis_hosts = values($redis_address_map)
|
||||||
|
$redis_bind_address = get_network_role_property('ceilometer/api', 'ipaddr')
|
||||||
|
|
||||||
|
# Set primary redis on primary-controller
|
||||||
|
$redis_primary_nodes = get_nodes_hash_by_roles(hiera('network_metadata'), ["primary-controller"])
|
||||||
|
$redis_primary_address_map = get_node_to_ipaddr_map_by_network_role($redis_primary_nodes, 'ceilometer/api')
|
||||||
|
$primary_redis_node = values($redis_primary_address_map)
|
||||||
|
|
||||||
|
class {'::redis::main':
|
||||||
|
primary_redis_node => $primary_redis_node[0],
|
||||||
|
redis_hosts => $redis_hosts,
|
||||||
|
redis_bind_address => $redis_bind_address,
|
||||||
|
primary_controller => false,
|
||||||
|
}
|
|
@ -0,0 +1,34 @@
|
||||||
|
# Copyright 2015 Mirantis, Inc.
|
||||||
|
#
|
||||||
|
# Licensed under the Apache License, Version 2.0 (the "License"); you may
|
||||||
|
# not use this file except in compliance with the License. You may obtain
|
||||||
|
# a copy of the License at
|
||||||
|
#
|
||||||
|
# http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
#
|
||||||
|
# Unless required by applicable law or agreed to in writing, software
|
||||||
|
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||||
|
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||||
|
# License for the specific language governing permissions and limitations
|
||||||
|
# under the License.
|
||||||
|
|
||||||
|
prepare_network_config(hiera('network_scheme', {}))
|
||||||
|
|
||||||
|
$redis_roles = ["primary-controller", "controller"]
|
||||||
|
$redis_nodes = get_nodes_hash_by_roles(hiera('network_metadata'), $redis_roles)
|
||||||
|
# Use ceilometer network role
|
||||||
|
$redis_address_map = get_node_to_ipaddr_map_by_network_role($redis_nodes, 'ceilometer/api')
|
||||||
|
$redis_hosts = values($redis_address_map)
|
||||||
|
$redis_bind_address = get_network_role_property('ceilometer/api', 'ipaddr')
|
||||||
|
|
||||||
|
# Set primary redis on primary-controller
|
||||||
|
$redis_primary_nodes = get_nodes_hash_by_roles(hiera('network_metadata'), ["primary-controller"])
|
||||||
|
$redis_primary_address_map = get_node_to_ipaddr_map_by_network_role($redis_primary_nodes, 'ceilometer/api')
|
||||||
|
$primary_redis_node = values($redis_primary_address_map)
|
||||||
|
|
||||||
|
class {'::redis::main':
|
||||||
|
primary_redis_node => $primary_redis_node[0],
|
||||||
|
redis_hosts => $redis_hosts,
|
||||||
|
redis_bind_address => $redis_bind_address,
|
||||||
|
primary_controller => true,
|
||||||
|
}
|
|
@ -1,6 +1,6 @@
|
||||||
|
require 'rubygems'
|
||||||
require 'puppetlabs_spec_helper/rake_tasks'
|
require 'puppetlabs_spec_helper/rake_tasks'
|
||||||
require 'puppet-lint/tasks/puppet-lint'
|
require 'puppet-lint/tasks/puppet-lint'
|
||||||
|
|
||||||
PuppetLint.configuration.fail_on_warnings
|
PuppetLint.configuration.fail_on_warnings
|
||||||
PuppetLint.configuration.send('relative')
|
PuppetLint.configuration.send('relative')
|
||||||
PuppetLint.configuration.send('disable_80chars')
|
PuppetLint.configuration.send('disable_80chars')
|
||||||
|
@ -9,3 +9,16 @@ PuppetLint.configuration.send('disable_class_parameter_defaults')
|
||||||
PuppetLint.configuration.send('disable_documentation')
|
PuppetLint.configuration.send('disable_documentation')
|
||||||
PuppetLint.configuration.send('disable_single_quote_string_with_variables')
|
PuppetLint.configuration.send('disable_single_quote_string_with_variables')
|
||||||
PuppetLint.configuration.ignore_paths = ["spec/**/*.pp", "pkg/**/*.pp"]
|
PuppetLint.configuration.ignore_paths = ["spec/**/*.pp", "pkg/**/*.pp"]
|
||||||
|
|
||||||
|
desc "Validate manifests, templates, and ruby files in lib."
|
||||||
|
task :validate do
|
||||||
|
Dir['manifests/**/*.pp'].each do |manifest|
|
||||||
|
sh "puppet parser validate --noop #{manifest}"
|
||||||
|
end
|
||||||
|
Dir['lib/**/*.rb'].each do |lib_file|
|
||||||
|
sh "ruby -c #{lib_file}"
|
||||||
|
end
|
||||||
|
Dir['templates/**/*.erb'].each do |template|
|
||||||
|
sh "erb -P -x -T '-' #{template} | ruby -c"
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
|
@ -0,0 +1,348 @@
|
||||||
|
#!/bin/sh
|
||||||
|
#
|
||||||
|
#
|
||||||
|
# Redis Service (redis-server)
|
||||||
|
#
|
||||||
|
# Description:
|
||||||
|
# Redis is an open source, BSD licensed, advanced key-value cache and store.
|
||||||
|
# It is often referred to as a data structure server since keys can contain
|
||||||
|
# strings, hashes, lists, sets, sorted sets, bitmaps and hyperloglogs.
|
||||||
|
#
|
||||||
|
#
|
||||||
|
# License: Apache Software License (ASL) 2.0
|
||||||
|
#
|
||||||
|
#
|
||||||
|
# See usage() function below for more details ...
|
||||||
|
#
|
||||||
|
# OCF instance parameters:
|
||||||
|
# OCF_RESKEY_binary
|
||||||
|
# OCF_RESKEY_config
|
||||||
|
# OCF_RESKEY_user
|
||||||
|
# OCF_RESKEY_pid
|
||||||
|
# OCF_RESKEY_monitor_binary
|
||||||
|
# OCF_RESKEY_redis_server_port
|
||||||
|
# OCF_RESKEY_additional_parameters
|
||||||
|
#######################################################################
|
||||||
|
# Initialization:
|
||||||
|
|
||||||
|
: ${OCF_FUNCTIONS_DIR=${OCF_ROOT}/lib/heartbeat}
|
||||||
|
. ${OCF_FUNCTIONS_DIR}/ocf-shellfuncs
|
||||||
|
|
||||||
|
#######################################################################
|
||||||
|
|
||||||
|
# Fill in some defaults if no values are specified
|
||||||
|
|
||||||
|
OCF_RESKEY_binary_default="redis-server"
|
||||||
|
if [ -f "/etc/redis.conf" ]; then
|
||||||
|
OCF_RESKEY_config_default="/etc/redis.conf"
|
||||||
|
else
|
||||||
|
OCF_RESKEY_config_default="/etc/redis/redis.conf"
|
||||||
|
fi
|
||||||
|
OCF_RESKEY_user_default="redis"
|
||||||
|
OCF_RESKEY_pid_default="/var/run/redis/redis-server.pid"
|
||||||
|
OCF_RESKEY_redis_server_port_default="6379"
|
||||||
|
|
||||||
|
: ${OCF_RESKEY_binary=${OCF_RESKEY_binary_default}}
|
||||||
|
: ${OCF_RESKEY_config=${OCF_RESKEY_config_default}}
|
||||||
|
: ${OCF_RESKEY_user=${OCF_RESKEY_user_default}}
|
||||||
|
: ${OCF_RESKEY_pid=${OCF_RESKEY_pid_default}}
|
||||||
|
: ${OCF_RESKEY_redis_server_port=${OCF_RESKEY_redis_server_port_default}}
|
||||||
|
|
||||||
|
#######################################################################
|
||||||
|
|
||||||
|
usage() {
|
||||||
|
cat <<UEND
|
||||||
|
usage: $0 (start|stop|validate-all|meta-data|status|monitor)
|
||||||
|
|
||||||
|
$0 manages an Redis Service (redis-server) process as an HA resource
|
||||||
|
|
||||||
|
The 'start' operation starts the scheduler service.
|
||||||
|
The 'stop' operation stops the scheduler service.
|
||||||
|
The 'validate-all' operation reports whether the parameters are valid
|
||||||
|
The 'meta-data' operation reports this RA's meta-data information
|
||||||
|
The 'status' operation reports whether the scheduler service is running
|
||||||
|
The 'monitor' operation reports whether the scheduler service seems to be working
|
||||||
|
|
||||||
|
UEND
|
||||||
|
}
|
||||||
|
|
||||||
|
meta_data() {
|
||||||
|
cat <<END
|
||||||
|
<?xml version="1.0"?>
|
||||||
|
<!DOCTYPE resource-agent SYSTEM "ra-api-1.dtd">
|
||||||
|
<resource-agent name="redis-server">
|
||||||
|
<version>1.0</version>
|
||||||
|
|
||||||
|
<longdesc lang="en">
|
||||||
|
Resource agent for the Redis Service (redis-server)
|
||||||
|
May manage a redis-server instance or a clone set that
|
||||||
|
creates a distributed redis-server cluster.
|
||||||
|
</longdesc>
|
||||||
|
<shortdesc lang="en">Manages the Redis Service (redis)</shortdesc>
|
||||||
|
<parameters>
|
||||||
|
|
||||||
|
<parameter name="binary" unique="0" required="0">
|
||||||
|
<longdesc lang="en">
|
||||||
|
Location of the Redis server binary (redis-server)
|
||||||
|
</longdesc>
|
||||||
|
<shortdesc lang="en">Redis server binary (redis-server)</shortdesc>
|
||||||
|
<content type="string" default="${OCF_RESKEY_binary_default}" />
|
||||||
|
</parameter>
|
||||||
|
|
||||||
|
<parameter name="config" unique="0" required="0">
|
||||||
|
<longdesc lang="en">
|
||||||
|
Redis service (redis-server) configuration file
|
||||||
|
</longdesc>
|
||||||
|
<shortdesc lang="en">Rredis (redis-server) config file</shortdesc>
|
||||||
|
<content type="string" default="${OCF_RESKEY_config_default}" />
|
||||||
|
</parameter>
|
||||||
|
|
||||||
|
<parameter name="user" unique="0" required="0">
|
||||||
|
<longdesc lang="en">
|
||||||
|
User running Redis Service (redis)
|
||||||
|
</longdesc>
|
||||||
|
<shortdesc lang="en">Redis Service (redis-server) user</shortdesc>
|
||||||
|
<content type="string" default="${OCF_RESKEY_user_default}" />
|
||||||
|
</parameter>
|
||||||
|
|
||||||
|
<parameter name="pid" unique="0" required="0">
|
||||||
|
<longdesc lang="en">
|
||||||
|
The pid file to use for this Redis Service (redis-server) instance
|
||||||
|
</longdesc>
|
||||||
|
<shortdesc lang="en">Redis Service (redis-server) pid file</shortdesc>
|
||||||
|
<content type="string" default="${OCF_RESKEY_pid_default}" />
|
||||||
|
</parameter>
|
||||||
|
|
||||||
|
<parameter name="redis_server_port" unique="0" required="0">
|
||||||
|
<longdesc lang="en">
|
||||||
|
The listening port number of the Redis server. Use for monitoring purposes
|
||||||
|
</longdesc>
|
||||||
|
<shortdesc lang="en">Redis server listening port</shortdesc>
|
||||||
|
<content type="integer" default="${OCF_RESKEY_redis_server_port_default}" />
|
||||||
|
</parameter>
|
||||||
|
|
||||||
|
<parameter name="additional_parameters" unique="0" required="0">
|
||||||
|
<longdesc lang="en">
|
||||||
|
Additional parameters to pass on to the Redis Service (redis-server)
|
||||||
|
</longdesc>
|
||||||
|
<shortdesc lang="en">Additional parameters for redis-server</shortdesc>
|
||||||
|
<content type="string" />
|
||||||
|
</parameter>
|
||||||
|
|
||||||
|
</parameters>
|
||||||
|
|
||||||
|
<actions>
|
||||||
|
<action name="start" timeout="20" />
|
||||||
|
<action name="stop" timeout="20" />
|
||||||
|
<action name="status" timeout="20" />
|
||||||
|
<action name="monitor" timeout="30" interval="20" />
|
||||||
|
<action name="validate-all" timeout="5" />
|
||||||
|
<action name="meta-data" timeout="5" />
|
||||||
|
</actions>
|
||||||
|
</resource-agent>
|
||||||
|
END
|
||||||
|
}
|
||||||
|
|
||||||
|
#######################################################################
|
||||||
|
# Functions invoked by resource manager actions
|
||||||
|
|
||||||
|
redis_server_check_port() {
|
||||||
|
local int
|
||||||
|
local cnt
|
||||||
|
|
||||||
|
int="$1"
|
||||||
|
cnt=${#int}
|
||||||
|
echo $int |egrep -qx '[0-9]+(:[0-9]+)?(,[0-9]+(:[0-9]+)?)*'
|
||||||
|
|
||||||
|
if [ $? -ne 0 ] || [ $cnt -ne 4 ]; then
|
||||||
|
ocf_log err "Invalid port number: $1"
|
||||||
|
exit $OCF_ERR_CONFIGURED
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
redis_server_validate() {
|
||||||
|
local rc
|
||||||
|
|
||||||
|
check_binary $OCF_RESKEY_binary
|
||||||
|
check_binary netstat
|
||||||
|
redis_server_check_port $OCF_RESKEY_redis_server_port
|
||||||
|
|
||||||
|
# A config file on shared storage that is not available
|
||||||
|
# during probes is OK.
|
||||||
|
if [ ! -f $OCF_RESKEY_config ]; then
|
||||||
|
if ! ocf_is_probe; then
|
||||||
|
ocf_log err "Config $OCF_RESKEY_config doesn't exist"
|
||||||
|
return $OCF_ERR_INSTALLED
|
||||||
|
fi
|
||||||
|
ocf_log_warn "Config $OCF_RESKEY_config not available during a probe"
|
||||||
|
fi
|
||||||
|
|
||||||
|
getent passwd $OCF_RESKEY_user >/dev/null 2>&1
|
||||||
|
rc=$?
|
||||||
|
if [ $rc -ne 0 ]; then
|
||||||
|
ocf_log err "User $OCF_RESKEY_user doesn't exist"
|
||||||
|
return $OCF_ERR_INSTALLED
|
||||||
|
fi
|
||||||
|
|
||||||
|
true
|
||||||
|
}
|
||||||
|
|
||||||
|
redis_server_status() {
|
||||||
|
local pid
|
||||||
|
local rc
|
||||||
|
|
||||||
|
# check and make PID file dir
|
||||||
|
local PID_DIR="$( dirname ${OCF_RESKEY_pid} )"
|
||||||
|
if [ ! -d "${PID_DIR}" ] ; then
|
||||||
|
ocf_log debug "Create pid file dir: ${PID_DIR} and chown to ${OCF_RESKEY_user}"
|
||||||
|
mkdir -p "${PID_DIR}"
|
||||||
|
chown -R ${OCF_RESKEY_user} "${PID_DIR}"
|
||||||
|
chmod 755 "${PID_DIR}"
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ ! -f $OCF_RESKEY_pid ]; then
|
||||||
|
ocf_log info "Redis service (redis-server) is not running"
|
||||||
|
return $OCF_NOT_RUNNING
|
||||||
|
else
|
||||||
|
pid=`cat $OCF_RESKEY_pid`
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ -n "${pid}" ]; then
|
||||||
|
ocf_run -warn kill -s 0 $pid
|
||||||
|
rc=$?
|
||||||
|
else
|
||||||
|
ocf_log err "PID file ${OCF_RESKEY_pid} is empty!"
|
||||||
|
return $OCF_ERR_GENERIC
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ $rc -eq 0 ]; then
|
||||||
|
return $OCF_SUCCESS
|
||||||
|
else
|
||||||
|
ocf_log info "Old PID file found, but Redis service (redis-server) is not running"
|
||||||
|
return $OCF_NOT_RUNNING
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
redis_server_monitor() {
|
||||||
|
local rc
|
||||||
|
local pid
|
||||||
|
|
||||||
|
redis_server_status
|
||||||
|
rc=$?
|
||||||
|
|
||||||
|
# If status returned anything but success, return that immediately
|
||||||
|
if [ $rc -ne $OCF_SUCCESS ]; then
|
||||||
|
return $rc
|
||||||
|
fi
|
||||||
|
|
||||||
|
ocf_log debug "Redis service (redis-server) monitor succeeded"
|
||||||
|
return $OCF_SUCCESS
|
||||||
|
}
|
||||||
|
|
||||||
|
redis_server_start() {
|
||||||
|
local rc
|
||||||
|
|
||||||
|
redis_server_status
|
||||||
|
rc=$?
|
||||||
|
if [ $rc -eq $OCF_SUCCESS ]; then
|
||||||
|
ocf_log info "Redis service (redis-server) already running"
|
||||||
|
return $OCF_SUCCESS
|
||||||
|
fi
|
||||||
|
|
||||||
|
# run the actual redis-server daemon. Don't use ocf_run as we're sending the tool's output
|
||||||
|
# straight to /dev/null anyway and using ocf_run would break stdout-redirection here.
|
||||||
|
su ${OCF_RESKEY_user} -s /bin/sh -c "${OCF_RESKEY_binary} $OCF_RESKEY_config \
|
||||||
|
$OCF_RESKEY_additional_parameters"' >> /dev/null 2>&1'
|
||||||
|
|
||||||
|
# Spin waiting for the server to come up.
|
||||||
|
while true; do
|
||||||
|
redis_server_monitor
|
||||||
|
rc=$?
|
||||||
|
[ $rc -eq $OCF_SUCCESS ] && break
|
||||||
|
if [ $rc -ne $OCF_NOT_RUNNING ]; then
|
||||||
|
ocf_log err "Redis service (redis_server) start failed"
|
||||||
|
exit $OCF_ERR_GENERIC
|
||||||
|
fi
|
||||||
|
sleep 3
|
||||||
|
done
|
||||||
|
|
||||||
|
ocf_log info "Redis service (redis_server) started"
|
||||||
|
return $OCF_SUCCESS
|
||||||
|
}
|
||||||
|
|
||||||
|
redis_server_stop() {
|
||||||
|
local rc
|
||||||
|
local pid
|
||||||
|
|
||||||
|
redis_server_status
|
||||||
|
rc=$?
|
||||||
|
if [ $rc -eq $OCF_NOT_RUNNING ]; then
|
||||||
|
ocf_log info "Redis service (redis-server) already stopped"
|
||||||
|
return $OCF_SUCCESS
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Try SIGTERM
|
||||||
|
pid=`cat $OCF_RESKEY_pid`
|
||||||
|
ocf_run kill -s TERM $pid
|
||||||
|
rc=$?
|
||||||
|
if [ $rc -ne 0 ]; then
|
||||||
|
ocf_log err "Redis service (redis-server) couldn't be stopped"
|
||||||
|
exit $OCF_ERR_GENERIC
|
||||||
|
fi
|
||||||
|
|
||||||
|
# stop waiting
|
||||||
|
shutdown_timeout=15
|
||||||
|
if [ -n "$OCF_RESKEY_CRM_meta_timeout" ]; then
|
||||||
|
shutdown_timeout=$((($OCF_RESKEY_CRM_meta_timeout/1000)-5))
|
||||||
|
fi
|
||||||
|
count=0
|
||||||
|
while [ $count -lt $shutdown_timeout ]; do
|
||||||
|
redis_server_status
|
||||||
|
rc=$?
|
||||||
|
if [ $rc -eq $OCF_NOT_RUNNING ]; then
|
||||||
|
break
|
||||||
|
fi
|
||||||
|
count=`expr $count + 1`
|
||||||
|
sleep 1
|
||||||
|
ocf_log debug "Redis service (redis-server) still hasn't stopped yet. Waiting ..."
|
||||||
|
done
|
||||||
|
|
||||||
|
redis_server_status
|
||||||
|
rc=$?
|
||||||
|
if [ $rc -ne $OCF_NOT_RUNNING ]; then
|
||||||
|
# SIGTERM didn't help either, try SIGKILL
|
||||||
|
ocf_log info "Redis service (redis-server) failed to stop after ${shutdown_timeout}s \
|
||||||
|
using SIGTERM. Trying SIGKILL ..."
|
||||||
|
ocf_run kill -s KILL $pid
|
||||||
|
fi
|
||||||
|
|
||||||
|
ocf_log info "Redis service (redis-server) stopped"
|
||||||
|
|
||||||
|
ocf_log debug "Delete pid file: ${OCF_RESKEY_pid} with content $(cat $OCF_RESKEY_pid)"
|
||||||
|
rm -f $OCF_RESKEY_pid
|
||||||
|
|
||||||
|
return $OCF_SUCCESS
|
||||||
|
}
|
||||||
|
|
||||||
|
#######################################################################
|
||||||
|
|
||||||
|
case "$1" in
|
||||||
|
meta-data) meta_data
|
||||||
|
exit $OCF_SUCCESS;;
|
||||||
|
usage|help) usage
|
||||||
|
exit $OCF_SUCCESS;;
|
||||||
|
esac
|
||||||
|
|
||||||
|
# Anything except meta-data and help must pass validation
|
||||||
|
redis_server_validate || exit $?
|
||||||
|
|
||||||
|
# What kind of method was invoked?
|
||||||
|
case "$1" in
|
||||||
|
start) redis_server_start;;
|
||||||
|
stop) redis_server_stop;;
|
||||||
|
status) redis_server_status;;
|
||||||
|
monitor) redis_server_monitor;;
|
||||||
|
validate-all) ;;
|
||||||
|
*) usage
|
||||||
|
exit $OCF_ERR_UNIMPLEMENTED;;
|
||||||
|
esac
|
|
@ -0,0 +1,5 @@
|
||||||
|
Facter.add('cluster_mode') do
|
||||||
|
setcode do
|
||||||
|
Facter::Util::Resolution.exec("cat /etc/astute.yaml | grep deployment_mode | awk '{print $2}'")
|
||||||
|
end
|
||||||
|
end
|
|
@ -0,0 +1,21 @@
|
||||||
|
module Puppet::Parser::Functions
|
||||||
|
newfunction(:redis_backend_url, :type => :rvalue) do |args|
|
||||||
|
if args.length != 3
|
||||||
|
raise "Wrong number of arguments"
|
||||||
|
end
|
||||||
|
nodes = args[0]
|
||||||
|
port = args[1]
|
||||||
|
timeout = args[2]
|
||||||
|
|
||||||
|
backend_url="redis://" + nodes[0] + ":" + port + "?sentinel=" + nodes[0]
|
||||||
|
|
||||||
|
nodes.each do |value|
|
||||||
|
if value != nodes[0]
|
||||||
|
backend_url=backend_url + "&sentinel_fallback=" + value + ":" + port
|
||||||
|
end
|
||||||
|
end
|
||||||
|
backend_url=backend_url + "&timeout=" + timeout
|
||||||
|
|
||||||
|
backend_url
|
||||||
|
end
|
||||||
|
end
|
|
@ -0,0 +1,23 @@
|
||||||
|
module Puppet::Parser::Functions
|
||||||
|
newfunction(:sentinel_confs, :type => :rvalue) do |args|
|
||||||
|
if args.length != 6
|
||||||
|
raise "Wrong number of arguments"
|
||||||
|
end
|
||||||
|
nodes = args[0]
|
||||||
|
port = args[1]
|
||||||
|
quorum = args[2]
|
||||||
|
parallel_syncs = args[3]
|
||||||
|
down_after_milliseconds = args[4]
|
||||||
|
failover_timeout = args[5]
|
||||||
|
hash = {}
|
||||||
|
|
||||||
|
nodes.each do |value|
|
||||||
|
hash[value] = { 'monitor' => value + ' ' + port + ' ' + quorum,
|
||||||
|
'down-after-milliseconds' => down_after_milliseconds,
|
||||||
|
'failover-timeout' => failover_timeout,
|
||||||
|
'parallel-syncs' => parallel_syncs }
|
||||||
|
end
|
||||||
|
|
||||||
|
hash
|
||||||
|
end
|
||||||
|
end
|
|
@ -161,8 +161,8 @@ class redis (
|
||||||
file { $conf_redis:
|
file { $conf_redis:
|
||||||
path => $conf_redis,
|
path => $conf_redis,
|
||||||
content => template('redis/redis.conf.erb'),
|
content => template('redis/redis.conf.erb'),
|
||||||
owner => root,
|
owner => redis,
|
||||||
group => root,
|
group => redis,
|
||||||
mode => '0644',
|
mode => '0644',
|
||||||
require => Package['redis'],
|
require => Package['redis'],
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,221 @@
|
||||||
|
#
|
||||||
|
# == Class: redis::main
|
||||||
|
#
|
||||||
|
# Installs and configures Redis
|
||||||
|
#
|
||||||
|
# === Parameters:
|
||||||
|
#
|
||||||
|
# [*primary_controller*]
|
||||||
|
# Status of controller node
|
||||||
|
# Defaults to false
|
||||||
|
#
|
||||||
|
# [*parallel_syncs*]
|
||||||
|
# How many slaves we can reconfigure to point to the new slave simultaneously
|
||||||
|
# during the failover
|
||||||
|
# Defaults to 2
|
||||||
|
#
|
||||||
|
# [*quorum*]
|
||||||
|
# Tells Sentinel to monitor this master, and to consider it in O_DOWN
|
||||||
|
# (Objectively Down) state only if at least <quorum> sentinels agree
|
||||||
|
# Defaults to 2
|
||||||
|
#
|
||||||
|
# [*down_after_milliseconds*]
|
||||||
|
# Number of milliseconds the master (or any attached slave or sentinel) should
|
||||||
|
# be unreachable (as in, not acceptable reply to PING, continuously, for the
|
||||||
|
# specified period) in order to consider it in S_DOWN state (Subjectively Down)
|
||||||
|
# Defaults to 30000
|
||||||
|
#
|
||||||
|
# [*failover_timeout*]
|
||||||
|
# Specifies the failover timeout in milliseconds
|
||||||
|
# Defaults to 60000
|
||||||
|
#
|
||||||
|
# [*timeout*]
|
||||||
|
# Specifes timeout for ceilometer coordination url
|
||||||
|
# Defaults to 10
|
||||||
|
#
|
||||||
|
# [*redis_port*]
|
||||||
|
# Port for redis-server to listen on
|
||||||
|
# Defaults to '6379'
|
||||||
|
#
|
||||||
|
# [*redis_sentinel_port*]
|
||||||
|
# Port for redis-sentinel to listen on
|
||||||
|
# Defaults to '26379'
|
||||||
|
#
|
||||||
|
|
||||||
|
class redis::main (
|
||||||
|
$primary_controller = false,
|
||||||
|
$parallel_syncs = '2',
|
||||||
|
$quorum = '2',
|
||||||
|
$down_after_milliseconds = '30000',
|
||||||
|
$failover_timeout = '60000',
|
||||||
|
$timeout = '10',
|
||||||
|
$primary_redis_node = '127.0.0.1',
|
||||||
|
$redis_hosts = ['127.0.0.1'],
|
||||||
|
$redis_bind_address = '0.0.0.0',
|
||||||
|
$redis_port = '6379',
|
||||||
|
$redis_sentinel_port = '26379',
|
||||||
|
) {
|
||||||
|
|
||||||
|
include ceilometer::params
|
||||||
|
include redis::params
|
||||||
|
|
||||||
|
case $::osfamily {
|
||||||
|
'RedHat': {
|
||||||
|
$manage_upstart_scripts = false
|
||||||
|
}
|
||||||
|
'Debian': {
|
||||||
|
$manage_upstart_scripts = true
|
||||||
|
}
|
||||||
|
default: {
|
||||||
|
fail("Unsupported osfamily: ${::osfamily} operatingsystem: ${::operatingsystem}")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
firewall {'121 redis_port':
|
||||||
|
port => $redis_port,
|
||||||
|
proto => 'tcp',
|
||||||
|
action => 'accept',
|
||||||
|
}
|
||||||
|
|
||||||
|
firewall {'122 redis_sentinel_port':
|
||||||
|
port => $redis_sentinel_port,
|
||||||
|
proto => 'tcp',
|
||||||
|
action => 'accept',
|
||||||
|
}
|
||||||
|
|
||||||
|
if $primary_controller {
|
||||||
|
$conf_slaveof = undef
|
||||||
|
} else {
|
||||||
|
$conf_slaveof = "$primary_redis_node $redis_port"
|
||||||
|
}
|
||||||
|
|
||||||
|
# Use custom function to generate sentinel configuration
|
||||||
|
$sentinel_confs = sentinel_confs($redis_hosts, $redis_port, $quorum,
|
||||||
|
$parallel_syncs, $down_after_milliseconds,
|
||||||
|
$failover_timeout)
|
||||||
|
|
||||||
|
package {'python-redis':
|
||||||
|
ensure => 'present',
|
||||||
|
} ->
|
||||||
|
|
||||||
|
class { '::redis':
|
||||||
|
conf_bind => $redis_bind_address,
|
||||||
|
conf_slave_read_only => 'no',
|
||||||
|
service_enable => false,
|
||||||
|
service_ensure => 'stopped',
|
||||||
|
conf_slaveof => $conf_slaveof,
|
||||||
|
} ->
|
||||||
|
|
||||||
|
class { '::redis::sentinel':
|
||||||
|
conf_port => $redis_sentinel_port,
|
||||||
|
sentinel_confs => $sentinel_confs,
|
||||||
|
manage_upstart_scripts => $manage_upstart_scripts,
|
||||||
|
}
|
||||||
|
|
||||||
|
ceilometer_config {
|
||||||
|
'coordination/backend_url' : value => redis_backend_url($redis_hosts, $redis_sentinel_port, $timeout);
|
||||||
|
'coordination/heartbeat' : value => '1.0';
|
||||||
|
'coordination/check_watchers' : value => $timeout;
|
||||||
|
}
|
||||||
|
|
||||||
|
if $primary_controller {
|
||||||
|
exec {'remove_old_resource_central_agent':
|
||||||
|
path => '/usr/sbin:/usr/bin:/sbin:/bin',
|
||||||
|
command => 'pcs resource delete p_ceilometer-agent-central --wait=120',
|
||||||
|
onlyif => 'pcs resource show p_ceilometer-agent-central > /dev/null 2>&1',
|
||||||
|
}
|
||||||
|
|
||||||
|
Exec['remove_old_resource_central_agent'] -> Cluster::Corosync::Cs_service["$::ceilometer::params::agent_central_service_name"]
|
||||||
|
}
|
||||||
|
|
||||||
|
file {'redis_ocf_script':
|
||||||
|
path => '/usr/lib/ocf/resource.d/fuel/redis-server',
|
||||||
|
owner => 'root',
|
||||||
|
group => 'root',
|
||||||
|
mode => '0755',
|
||||||
|
source => 'puppet:///modules/redis/ocf/redis-server'
|
||||||
|
}
|
||||||
|
|
||||||
|
cluster::corosync::cs_service { "$::ceilometer::params::agent_central_service_name":
|
||||||
|
ocf_script => 'ceilometer-agent-central',
|
||||||
|
csr_parameters => {},
|
||||||
|
csr_metadata => undef,
|
||||||
|
csr_complex_type => 'clone',
|
||||||
|
csr_ms_metadata => { 'interleave' => true },
|
||||||
|
csr_mon_intr => '20',
|
||||||
|
csr_mon_timeout => '10',
|
||||||
|
csr_timeout => '60',
|
||||||
|
service_name => $::ceilometer::params::agent_central_service_name,
|
||||||
|
package_name => $::ceilometer::params::agent_central_package_name,
|
||||||
|
service_title => 'ceilometer-agent-central',
|
||||||
|
primary => $primary_controller,
|
||||||
|
hasrestart => false,
|
||||||
|
}
|
||||||
|
|
||||||
|
cluster::corosync::cs_service { 'redis':
|
||||||
|
ocf_script => 'redis-server',
|
||||||
|
csr_parameters => {},
|
||||||
|
csr_metadata => undef,
|
||||||
|
csr_complex_type => 'clone',
|
||||||
|
csr_ms_metadata => { 'interleave' => true },
|
||||||
|
csr_mon_intr => '20',
|
||||||
|
csr_mon_timeout => '10',
|
||||||
|
csr_timeout => '60',
|
||||||
|
service_name => $::redis::params::service,
|
||||||
|
package_name => $::redis::params::package,
|
||||||
|
service_title => 'redis',
|
||||||
|
primary => $primary_controller,
|
||||||
|
hasrestart => false,
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
File['redis_ocf_script'] ->
|
||||||
|
Cluster::Corosync::Cs_service['redis'] ->
|
||||||
|
Ceilometer_config <||> ->
|
||||||
|
Cluster::Corosync::Cs_service["$::ceilometer::params::agent_central_service_name"]
|
||||||
|
|
||||||
|
if !$primary_controller {
|
||||||
|
exec {'waiting-for-agent-up-on-primary':
|
||||||
|
tries => 10,
|
||||||
|
try_sleep => 30,
|
||||||
|
command => "pcs resource | grep -A 1 p_${::ceilometer::params::agent_central_service_name} | grep Started > /dev/null 2>&1",
|
||||||
|
path => '/usr/sbin:/usr/bin:/sbin:/bin',
|
||||||
|
}
|
||||||
|
|
||||||
|
exec {'waiting-for-redis-up-on-primary':
|
||||||
|
tries => 10,
|
||||||
|
try_sleep => 30,
|
||||||
|
command => "pcs resource | grep -A 1 p_${::redis::params::service} | grep Started > /dev/null 2>&1",
|
||||||
|
path => '/usr/sbin:/usr/bin:/sbin:/bin',
|
||||||
|
}
|
||||||
|
|
||||||
|
service {"p_${::ceilometer::params::agent_central_service_name}":
|
||||||
|
enable => true,
|
||||||
|
ensure => 'running',
|
||||||
|
hasstatus => true,
|
||||||
|
hasrestart => true,
|
||||||
|
provider => 'pacemaker',
|
||||||
|
}
|
||||||
|
|
||||||
|
service {"p_${::redis::params::service}":
|
||||||
|
enable => true,
|
||||||
|
ensure => 'running',
|
||||||
|
hasstatus => true,
|
||||||
|
hasrestart => true,
|
||||||
|
provider => 'pacemaker',
|
||||||
|
}
|
||||||
|
|
||||||
|
Exec['waiting-for-redis-up-on-primary'] ->
|
||||||
|
Service["p_${::redis::params::service}"] ->
|
||||||
|
Cluster::Corosync::Cs_service['redis'] ->
|
||||||
|
Exec['waiting-for-agent-up-on-primary'] ->
|
||||||
|
Ceilometer_config <||> ->
|
||||||
|
Cluster::Corosync::Cs_service["$::ceilometer::params::agent_central_service_name"]
|
||||||
|
}
|
||||||
|
|
||||||
|
service { 'ceilometer-agent-central':
|
||||||
|
ensure => 'stopped',
|
||||||
|
name => $::ceilometer::params::agent_central_service_name,
|
||||||
|
enable => false,
|
||||||
|
}
|
||||||
|
}
|
|
@ -50,6 +50,7 @@ class redis::sentinel (
|
||||||
) {
|
) {
|
||||||
|
|
||||||
include redis::sentinel_params
|
include redis::sentinel_params
|
||||||
|
include redis
|
||||||
|
|
||||||
$conf_sentinel = $redis::sentinel_params::conf
|
$conf_sentinel = $redis::sentinel_params::conf
|
||||||
$conf_sentinel_orig = "${conf_sentinel}.puppet"
|
$conf_sentinel_orig = "${conf_sentinel}.puppet"
|
||||||
|
@ -74,18 +75,13 @@ class redis::sentinel (
|
||||||
$conf_logfile_real = $::redis::sentinel_params::logfile
|
$conf_logfile_real = $::redis::sentinel_params::logfile
|
||||||
}
|
}
|
||||||
|
|
||||||
package { 'redis':
|
|
||||||
ensure => $package_ensure,
|
|
||||||
name => $package,
|
|
||||||
}
|
|
||||||
|
|
||||||
if $manage_upstart_scripts == true {
|
if $manage_upstart_scripts == true {
|
||||||
service { 'sentinel':
|
service { 'sentinel':
|
||||||
ensure => $service_ensure,
|
ensure => $service_ensure,
|
||||||
name => $service,
|
name => $service,
|
||||||
hasrestart => true,
|
hasrestart => true,
|
||||||
hasstatus => true,
|
hasstatus => true,
|
||||||
require => [ File[$conf_sentinel_orig],
|
require => [ File[$conf_sentinel],
|
||||||
File[$upstart_script] ],
|
File[$upstart_script] ],
|
||||||
provider => 'upstart'
|
provider => 'upstart'
|
||||||
}
|
}
|
||||||
|
@ -97,7 +93,7 @@ class redis::sentinel (
|
||||||
hasrestart => true,
|
hasrestart => true,
|
||||||
hasstatus => true,
|
hasstatus => true,
|
||||||
require => [ Package['redis'],
|
require => [ Package['redis'],
|
||||||
File[$conf_sentinel_orig] ],
|
File[$conf_sentinel] ],
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -107,26 +103,33 @@ class redis::sentinel (
|
||||||
# only if it changed.
|
# only if it changed.
|
||||||
file { $conf_sentinel_orig:
|
file { $conf_sentinel_orig:
|
||||||
content => template('redis/sentinel.conf.erb'),
|
content => template('redis/sentinel.conf.erb'),
|
||||||
owner => redis,
|
owner => root,
|
||||||
group => redis,
|
group => root,
|
||||||
mode => '0644',
|
mode => '0644',
|
||||||
require => Package['redis'],
|
require => Package['redis'],
|
||||||
notify => Exec["cp ${conf_sentinel_orig} ${conf_sentinel}"],
|
|
||||||
}
|
}
|
||||||
|
|
||||||
file { $conf_sentinel:
|
file { $conf_sentinel:
|
||||||
owner => redis,
|
owner => redis,
|
||||||
group => redis,
|
group => redis,
|
||||||
require => Package['redis'],
|
require => [ Package['redis'],
|
||||||
|
Exec["cp ${conf_sentinel_orig} ${conf_sentinel}"] ],
|
||||||
|
}
|
||||||
|
|
||||||
|
exec {"mv ${conf_sentinel} ${conf_sentinel}.original":
|
||||||
|
path => '/bin:/usr/bin:/sbin:/usr/sbin',
|
||||||
|
user => root,
|
||||||
|
group => root,
|
||||||
|
require => [ Package['redis'],
|
||||||
|
File[$conf_sentinel_orig] ],
|
||||||
}
|
}
|
||||||
|
|
||||||
exec { "cp ${conf_sentinel_orig} ${conf_sentinel}":
|
exec { "cp ${conf_sentinel_orig} ${conf_sentinel}":
|
||||||
path => '/bin:/usr/bin:/sbin:/usr/sbin',
|
path => '/bin:/usr/bin:/sbin:/usr/sbin',
|
||||||
refreshonly => true,
|
user => root,
|
||||||
user => redis,
|
group => root,
|
||||||
group => redis,
|
|
||||||
notify => Service['sentinel'],
|
notify => Service['sentinel'],
|
||||||
require => File[$conf_sentinel],
|
require => Exec["mv ${conf_sentinel} ${conf_sentinel}.original"],
|
||||||
}
|
}
|
||||||
|
|
||||||
file { $conf_logrotate:
|
file { $conf_logrotate:
|
||||||
|
@ -138,8 +141,7 @@ class redis::sentinel (
|
||||||
}
|
}
|
||||||
|
|
||||||
if $service_restart == true {
|
if $service_restart == true {
|
||||||
# https://github.com/fsalum/puppet-redis/pull/28
|
File[$conf_sentinel] ~> Service['sentinel']
|
||||||
File[$conf_sentinel_orig] ~> Service['sentinel']
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if $manage_upstart_scripts == true {
|
if $manage_upstart_scripts == true {
|
||||||
|
|
|
@ -14,16 +14,16 @@ class redis::sentinel_params {
|
||||||
|
|
||||||
case $::osfamily {
|
case $::osfamily {
|
||||||
# TODO: add redhat support
|
# TODO: add redhat support
|
||||||
#'redhat': {
|
'redhat': {
|
||||||
# $package = 'redis'
|
$package = 'redis'
|
||||||
# $service = 'redis-sentinel'
|
$service = 'redis-sentinel'
|
||||||
# $conf = '/etc/sentinel.conf'
|
$conf = '/etc/redis-sentinel.conf'
|
||||||
# $conf_dir = undef
|
$conf_dir = undef
|
||||||
# $conf_logrotate = '/etc/logrotate.d/sentinel'
|
$conf_logrotate = '/etc/logrotate.d/sentinel'
|
||||||
# $pidfile = '/var/run/redis/sentinel.pid'
|
$pidfile = '/var/run/redis/sentinel.pid'
|
||||||
# $logfile = '/var/log/redis/sentinel.log'
|
$logfile = '/var/log/redis/sentinel.log'
|
||||||
# $upstart_script = '/etc/init/redis-sentinel.conf'
|
$upstart_script = '/etc/init/redis-sentinel.conf'
|
||||||
#}
|
}
|
||||||
'debian': {
|
'debian': {
|
||||||
$package = 'redis-server'
|
$package = 'redis-server'
|
||||||
$service = 'redis-sentinel'
|
$service = 'redis-sentinel'
|
||||||
|
|
|
@ -0,0 +1,6 @@
|
||||||
|
attributes:
|
||||||
|
# Install redis only if ceilometer is enabled
|
||||||
|
metadata:
|
||||||
|
restrictions:
|
||||||
|
- condition: settings:additional_components.ceilometer.value == false
|
||||||
|
action: hide
|
|
@ -0,0 +1,34 @@
|
||||||
|
# Plugin name
|
||||||
|
name: ceilometer-redis
|
||||||
|
# Human-readable name for your plugin
|
||||||
|
title: Redis plugin for Ceilometer
|
||||||
|
# Plugin version
|
||||||
|
version: 1.0.0
|
||||||
|
# Description
|
||||||
|
description: Ceilometer extension that provide workload-partitioning and HA for ceilometer services
|
||||||
|
# Required fuel version
|
||||||
|
fuel_version: ['7.0']
|
||||||
|
# Specify license of your plugin
|
||||||
|
licenses: ['Apache License Version 2.0']
|
||||||
|
# Specify author or company name
|
||||||
|
authors: ['Ivan Berezovskiy', 'Ilya Tyaptin']
|
||||||
|
# A link to the plugin's page
|
||||||
|
homepage: 'https://github.com/stackforge/fuel-plugin-ceilometer-redis'
|
||||||
|
# Groups
|
||||||
|
groups: []
|
||||||
|
|
||||||
|
# The plugin is compatible with releases in the list
|
||||||
|
releases:
|
||||||
|
- os: ubuntu
|
||||||
|
version: 2015.1.0-7.0
|
||||||
|
mode: ['ha']
|
||||||
|
deployment_scripts_path: deployment_scripts/
|
||||||
|
repository_path: repositories/ubuntu
|
||||||
|
# - os: centos
|
||||||
|
# version: 2015.1.0-7.0
|
||||||
|
# mode: ['ha']
|
||||||
|
# deployment_scripts_path: deployment_scripts/
|
||||||
|
# repository_path: repositories/centos
|
||||||
|
|
||||||
|
# Version of plugin package
|
||||||
|
package_version: '2.0.0'
|
|
@ -0,0 +1,5 @@
|
||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
# Add here any the actions which are required before plugin build
|
||||||
|
# like packages building, packages downloading from mirrors and so on.
|
||||||
|
# The script should return 0 if there were no errors.
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
|
@ -0,0 +1,15 @@
|
||||||
|
- role: ['primary-controller']
|
||||||
|
stage: post_deployment
|
||||||
|
type: puppet
|
||||||
|
parameters:
|
||||||
|
puppet_manifest: puppet/manifests/primary-controller.pp
|
||||||
|
puppet_modules: puppet/modules:/etc/puppet/modules
|
||||||
|
timeout: 720
|
||||||
|
|
||||||
|
- role: ['controller']
|
||||||
|
stage: post_deployment
|
||||||
|
type: puppet
|
||||||
|
parameters:
|
||||||
|
puppet_manifest: puppet/manifests/controller.pp
|
||||||
|
puppet_modules: puppet/modules:/etc/puppet/modules
|
||||||
|
timeout: 720
|
Loading…
Reference in New Issue