Add Redis replica recipe and role
This commit is contained in:
19
site-cookbooks/kosmos_redis/recipes/replica.rb
Normal file
19
site-cookbooks/kosmos_redis/recipes/replica.rb
Normal file
@@ -0,0 +1,19 @@
|
||||
#
|
||||
# Cookbook Name:: kosmos_redis
|
||||
# Recipe:: replica
|
||||
#
|
||||
|
||||
primary_host = search(:node, 'role:redis_server').first['knife_zero']['host'] rescue nil
|
||||
|
||||
if primary_host.nil?
|
||||
Chef::Log.warn("No node found with 'redis_server' role. Stopping here.")
|
||||
return
|
||||
end
|
||||
|
||||
node.normal['redisio']['servers'] = [{
|
||||
'port' => '6379',
|
||||
'replicaof' => { 'address' => primary_host, 'port' => '6379' }
|
||||
}]
|
||||
|
||||
include_recipe 'redisio::default'
|
||||
include_recipe 'redisio::enable'
|
||||
Reference in New Issue
Block a user