Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- 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
Add Comment
Please, Sign In to add comment