Skip to content

Commit

Permalink
Enables RDS support
Browse files Browse the repository at this point in the history
  • Loading branch information
Thom Mahoney authored and Ines Sombra committed Jun 13, 2012
1 parent badf11e commit ca31d8f
Show file tree
Hide file tree
Showing 4 changed files with 69 additions and 0 deletions.
20 changes: 20 additions & 0 deletions cookbooks/rds/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
ey-cloud-recipes/rds
------------------------------------------------------------------------------

A chef recipe for enabling remote Active Record databases like Amazon's RDS

Dependencies
--------------------------

Requires a running database instance with firewall access configured for
your Engine Yard environment.

Contact our support team if you need additional information about your environment.

Enabling this recipe
---------------------------

* Edit main/recipes/default.rb and comment out the line shown below.
``require_recipe "rds"``
* Alter the rds/attributes/rds.rb file to include your connection
information.
4 changes: 4 additions & 0 deletions cookbooks/rds/attributes/rds.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# place database credentials in this file
# app_name :adapter => '', :database => '', :username => '', :password => '', :host => ''
# for example:
# todo :adapter => 'mysql', :database => 'todoproduction', :username => 'engineyard', :password => 'mypassword', :host => 'todo.dhvg1ytl1sd8.us-east-1.rds.amazonaws.com'
38 changes: 38 additions & 0 deletions cookbooks/rds/recipes/default.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
#
# Cookbook Name:: rds
# Recipe:: default
#
# Configure application servers to use an Amazon RDS database (or any external ActiveRecord-compatible database)
# Note: This recipe does not make any changes to Engine Yard-provisioned databases

if ['solo', 'app_master', 'app', 'util'].include?(node[:instance_role])
# for each application
node.engineyard.apps.each do |app|
# retrieve attributes
attributes = node[app.name]

# skip if there are no attributes for this app
next if attributes.nil?

ey_cloud_report "RDS" do
message "RDS - Replacing database.yml for #{app.name}"
end

# create new database.yml with attributes
template "/data/#{app.name}/shared/config/database.yml" do
owner node[:owner_name]
group node[:owner_name]
backup false
mode 0644
source 'database.yml.erb'
variables({
:environment => node[:environment][:framework_env],
:adapter => attributes[:adapter],
:database => attributes[:database],
:username => attributes[:username],
:password => attributes[:password],
:host => attributes[:host]
})
end
end
end
7 changes: 7 additions & 0 deletions cookbooks/rds/templates/default/database.yml.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<%= @environment %>:
adapter: <%= @adapter %>
database: '<%= @database %>'
username: '<%= @username %>'
password: '<%= @password %>'
host: '<%= @host %>'
reconnect: true

0 comments on commit ca31d8f

Please sign in to comment.