Revisions
-
richievos created this gist
Aug 27, 2009 .There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,26 @@ # Optional more complicated strat for the database.yml require 'ftools' namespace :config do task :build do File.mkdir_p temp_config_dir # this is the place to hook after when creating a config file end task :update do # upload contents of temp_config_dir to #{release_path}/config end before 'config:update', 'config:build' after 'deploy:update_code', 'config:update' end task :some_config do # write file1 to temp_config_dir end task :some_other_config do # write file2 to temp_config_dir end after 'config:build', 'some_config' after 'config:build', 'some_other_config' # both file1 and file2 will automatically get uploaded to #{release_path}/config/[file1, file2] This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,6 @@ task deploy do users = {:user_1 => db_pass_1, :user_2 => db_pass_2, :user_n => db_pass_n } users.each do |user, pass| system("cap deploy:update -S user=#{user} -S pass=#{pass}") or abort("Could not deploy to #{user}") end end This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,44 @@ def validate_credentials fail("Cannot deploy without giving user credentials") unless variables[:user] && variables[:password] end validate_credentials set :user, variables[:user] set :password, variables[:password] logger.info("Deploying to #{user}") set deploy_to: "/home/#{user}/apps/#{application}" set :app, "#{user}.my_domain.com" set :web, "#{user}.my_domain.com" set :db, "#{user}.my_domain.com" # and configure it to write out the database.yml # some other options: # * manually put the database.yml in the #{shared_path}/config/database.yml and just symlink # This has the big benefit of only keeping the credentials on the server itself and not having # to manage them outside of that (Assuming they're relatively static, I would do that) # * automatically put the creds in #{shared_path}/config/database.yml and symlink it in namespace :db do task :update_config, :roles => :app, :except => { :no_release => true } do yaml = <<EOF production: adapter: mysql encoding: utf8 database: #{user}_app_production username: #{user} password: #{pass} EOF # now get that file into #{release_path}/config/database.yml # leave that up to you # I'd probably write to a temp file and upload it (should make sure to delete it afterwards to # avoid leaving a credentials file in tmp) # or echo it directly into a file on that box (but I can never get multiline stuff to work # properly when doing a run("...")) end after 'deploy:update_code', 'db:update_config' end