Last active
January 4, 2016 04:08
-
-
Save g8d3/8566023 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
### recipe | |
# This file should be in .../cookbooks/database/recipes/default.rb | |
if ['solo', 'app_master', 'app', 'util'].include?(node[:instance_role]) | |
# for each application | |
node[:engineyard][:environment][:apps].each do |app| | |
# create new database.yml | |
template "/data/#{app[:name]}/shared/config/database.yml" do | |
source 'database.yml.erb' | |
owner node[:users][0][:username] | |
group node[:users][0][:username] | |
mode 0644 | |
variables({ | |
:environment => node[:environment][:framework_env], | |
:adapter => 'mysql2', | |
:database => app[:database_name], | |
:username => node[:users][0][:username], | |
:password => node[:users][0][:password], | |
:host => node[:db_host], | |
:vd => { | |
:adapter => 'mysql2', | |
:database => x , | |
:username => xx, | |
:password => xxx, | |
:host => xxxx, | |
}, | |
:ms => { | |
:adapter => 123123123, | |
:host => 123123123123, | |
:database => 123123123, | |
:username => 123123123, | |
:password => 123123123, | |
:port => 123123123, | |
:pool => 123123123 | |
} | |
}) | |
end | |
end | |
end | |
### template | |
# This file should be in .../cookbooks/database/templates/default/database.yml.erb | |
<%= @environment %>: | |
adapter: <%= @adapter %> | |
database: <%= @database %> | |
username: <%= @username %> | |
password: <%= @password %> | |
host: <%= @host %> | |
vd_<%= @environment %>: | |
adapter: <%= @vd[:adapter] %> | |
database: <%= @vd[:database] %> | |
username: <%= @vd[:username] %> | |
password: <%= @vd[:password] %> | |
host: <%= @vd[:host] %> | |
ms_<%= @environment %>: | |
adapter: <%= @ms[:adapter] %> | |
host: <%= @ms[:host] %> | |
database: <%= @ms[:database] %> | |
username: <%= @ms[:username] %> | |
password: <%= @ms[:password] %> | |
port: <%= @ms[:port] %> | |
pool: <%= @ms[:pool] %> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment