Add Redis replica recipe and role

This commit is contained in:
2024-01-24 18:11:58 +03:00
parent c32e8bc9e5
commit 88e96747e3
5 changed files with 51 additions and 13 deletions

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