Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

elasticache redis and memcache recipes #125

Open
wants to merge 1 commit into
base: next-release
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 25 additions & 0 deletions custom-cookbooks/elasticache-memcache/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
## Optional Cookbook for Engine Yard Cloud

# Elasticache Memcache

AWS Elasticache is managed service for Memcache.

## Overview

This cookbook generates configuration file from provided environment variables.

## Installation

### Environment Variables

When the environment variable `EY_ELASTICACHE_MEMCACHE_ENABLED` is set to "true", this recipe will be enabled and setup up Memcache configuration file.
`EY_ELASTICACHE_MEMCACHE_URL` vairable will be used for the URL


### Custom Chef

Since this is an optional recipe, it can be installed by simply including it via a `depends` in your `ey-custom/metadata.rb` file and an `include_recipe` in the appropriate hook file.

## Notes

1. This recipe will put in place a `memcached.yml` on `/data/{app_name}/shared/config/`.
7 changes: 7 additions & 0 deletions custom-cookbooks/elasticache-memcache/attributes/default.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
default["elasticache-memcache"].tap do |elasticache|

elasticache['ey_elastic_memcache_enabled'] = fetch_env_var(node, "EY_ELASTICACHE_MEMCACHE_ENABLED")
elasticache['ey_elastic_memcache_url'] = fetch_env_var(node, "EY_ELASTICACHE_MEMCACHE_URL")
elasticache['ey_memcache'] = fetch_env_var(node, "EY_MEMCACHE")

end
8 changes: 8 additions & 0 deletions custom-cookbooks/elasticache-memcache/metadata.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
name 'elasticache-memcache'
description 'Configuration of Elasticache Memcache on AWS'
long_description IO.read(File.join(File.dirname(__FILE__), 'README.md'))
maintainer 'Engine Yard'
maintainer_email '[email protected]'
version '1.0.1'
issues_url 'https://github.com/engineyard/ey-cookbooks-stable-v6/issues'
source_url 'https://github.com/engineyard/ey-cookbooks-stable-v6'
34 changes: 34 additions & 0 deletions custom-cookbooks/elasticache-memcache/recipes/configure.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
#
# Cookbook Name:: memcache
# Recipe:: configure
#

if node['elasticache-memcache']['ey_elastic_memcache_enabled']

if node['elasticache-memcache']['ey_memcache']
# ERROR both EY_MEMCACHE and ELASTICACHE Enabled
end

if node['elasticache-memcache']['ey_elastic_memcache_url'].nil? || node['elasticache-memcache']['ey_elastic_memcache_url'].empty?
# ERROR URL missing
end

if ['solo', 'app', 'app_master', 'util'].include?(node['dna']['instance_role'])

node['dna']['applications'].each do |app, data|
template "/data/#{app}/shared/config/memcached.yml"do
source 'memcached.yml.erb'
owner node['owner_name']
group node['owner_name']
mode 0655
backup 0
variables({
'hostname' => node['elasticache-memcache']['ey_elastic_memcache_url'],
'environment' => node["dna"]["engineyard"]["environment"]["framework_env"]
})
end
end

end

end
5 changes: 5 additions & 0 deletions custom-cookbooks/elasticache-memcache/recipes/default.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#
# Cookbook Name:: elasticache-memcache
#

include_recipe 'elasticache-memcache::configure'
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
defaults:
servers:
- <%= @hostname %>:11211

<%= @environment %>:
servers:
- <%= @hostname %>:11211
25 changes: 25 additions & 0 deletions custom-cookbooks/elasticache-redis/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
## Optional Cookbook for Engine Yard Cloud

# Elasticache Redis

AWS Elasticache is managed service for Redis.

## Overview

This cookbook generates configuration file from provided environment variables.

## Installation

### Environment Variables

When the environment variable `EY_ELASTICACHE_REDIS_ENABLED` is set to "true", this recipe will be enabled and setup up Redis configuration file.
`EY_ELASTICACHE_REDIS_URL` vairable will be used for the URL


### Custom Chef

Since this is an optional recipe, it can be installed by simply including it via a `depends` in your `ey-custom/metadata.rb` file and an `include_recipe` in the appropriate hook file.

## Notes

1. This recipe will put in place a `redis.yml` on `/data/{app_name}/shared/config/`.
7 changes: 7 additions & 0 deletions custom-cookbooks/elasticache-redis/attributes/default.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
default["elasticache-redis"].tap do |elasticache|

elasticache['ey_elastic_redis_enabled'] = fetch_env_var(node, "EY_ELASTICACHE_REDIS_ENABLED")
elasticache['ey_elastic_redis_url'] = fetch_env_var(node, "EY_ELASTICACHE_REDIS_URL")
elasticache['ey_redis'] = fetch_env_var(node, "EY_REDIS")

end
8 changes: 8 additions & 0 deletions custom-cookbooks/elasticache-redis/metadata.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
name 'elasticache-redis'
description 'Configuration of Elasticache Redis on AWS'
long_description IO.read(File.join(File.dirname(__FILE__), 'README.md'))
maintainer 'Engine Yard'
maintainer_email '[email protected]'
version '1.0.1'
issues_url 'https://github.com/engineyard/ey-cookbooks-stable-v6/issues'
source_url 'https://github.com/engineyard/ey-cookbooks-stable-v6'
34 changes: 34 additions & 0 deletions custom-cookbooks/elasticache-redis/recipes/configure.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
#
# Cookbook Name:: redis
# Recipe:: configure
#

if node['elasticache-redis']['ey_elastic_redis_enabled']

if node["elasticache-redis"]['ey_redis']
# ERROR both EY_REDIS and ELASTICACHE Enabled
end

if node['elasticache-redis']['ey_elastic_redis_url'].nil? || node['elasticache-redis']['ey_elastic_redis_url'].empty?
# ERROR URL missing
end

if ['solo', 'app', 'app_master', 'util'].include?(node['dna']['instance_role'])

node['dna']['applications'].each do |app, data|
template "/data/#{app}/shared/config/redis.yml"do
source 'redis.yml.erb'
owner node['owner_name']
group node['owner_name']
mode 0655
backup 0
variables({
'hostname' => node['elasticache-redis']['ey_elastic_redis_url'],
'environment' => node["dna"]["engineyard"]["environment"]["framework_env"]
})
end
end

end

end
5 changes: 5 additions & 0 deletions custom-cookbooks/elasticache-redis/recipes/default.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#
# Cookbook Name:: elasticache-redis
#

include_recipe 'elasticache-redis::configure'
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<%= @environment %>:
host: <%= @hostname %>
port: 6379