20 lines
450 B
Ruby

#
# 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'