Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Enables RDS support

  • Loading branch information...
commit ca31d8ff21d71796197e6b5f53d932f9953d26df 1 parent badf11e
Thom Mahoney authored Ines Sombra committed
View
20 cookbooks/rds/README.md
@@ -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.
View
4 cookbooks/rds/attributes/rds.rb
@@ -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'
View
38 cookbooks/rds/recipes/default.rb
@@ -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
View
7 cookbooks/rds/templates/default/database.yml.erb
@@ -0,0 +1,7 @@
+<%= @environment %>:
+ adapter: <%= @adapter %>
+ database: '<%= @database %>'
+ username: '<%= @username %>'
+ password: '<%= @password %>'
+ host: '<%= @host %>'
+ reconnect: true
Please sign in to comment.
Something went wrong with that request. Please try again.