11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
|
# File 'lib/mimas/plugins/server/redis.rb', line 11
def configure_redis(sudo_user:)
config_destination = Pathname.new("/").join("etc", "redis", "conf.d")
ssh(self, user: sudo_user) do |session|
session.run "sudo -u redis mkdir -p #{config_destination}"
config_files = find_files("redis/*.conf")
tmp_dir = Pathname.new("/").join("tmp", "redis")
session.run "mkdir -p #{tmp_dir}"
config_files.each do |file_path|
file_name = Pathname.new(file_path).basename
session.upload file_path, tmp_dir.join(file_name)
end
session.run "sudo rsync --archive --recursive --chown=redis:redis #{tmp_dir.join("*")} #{config_destination}"
session.run "rm -rf #{tmp_dir}"
session.run "sudo -u redis bash -c \"echo -e '\n\ninclude /etc/redis/conf.d/*.conf' >> /etc/redis/redis.conf\""
session.run "sudo systemctl restart redis"
end
end
|