From 283a04f8d98725ed3c82e2d02fe3fa025cbfcd18 Mon Sep 17 00:00:00 2001 From: William Mantly Date: Mon, 27 May 2019 22:06:21 -0400 Subject: [PATCH] Redis recipe --- attributes/redis.rb | 1 + recipes/redis.rb | 19 +++++++++++++++++++ templates/redis/local.conf | 7 +++++++ 3 files changed, 27 insertions(+) create mode 100644 attributes/redis.rb create mode 100644 recipes/redis.rb create mode 100644 templates/redis/local.conf diff --git a/attributes/redis.rb b/attributes/redis.rb new file mode 100644 index 0000000..ce39b86 --- /dev/null +++ b/attributes/redis.rb @@ -0,0 +1 @@ +default['redis']['unix']['path'] = '/var/run/redis/redis.sock' diff --git a/recipes/redis.rb b/recipes/redis.rb new file mode 100644 index 0000000..095d7a2 --- /dev/null +++ b/recipes/redis.rb @@ -0,0 +1,19 @@ +apt_package 'redis-server' + +template '/etc/redis/local.conf' do + source 'redis/local.conf' +end + +if node['redis']['unix']['perm'] + bash 'append_to_config' do + user 'root' + code <<~EOF + echo "include /etc/redis/local.conf" >> /etc/redis/redis.conf + EOF + not_if 'grep -q "/etc/redis/local.conf" /etc/redis/redis.conf' + end +end + +systemd_unit 'redis-server.service' do + action :restart +end diff --git a/templates/redis/local.conf b/templates/redis/local.conf new file mode 100644 index 0000000..4ed4830 --- /dev/null +++ b/templates/redis/local.conf @@ -0,0 +1,7 @@ +# Specify the path for the Unix socket that will be used to listen for +# incoming connections. There is no default, so Redis will not listen +# on a unix socket when not specified. +# + +unixsocket <%= node['redis']['unix']['path'] %> +unixsocketperm <%= node['redis']['unix']['perm'] %>