Capistrano configuration

Posted by Eli on Stack Overflow See other posts from Stack Overflow or by Eli
Published on 2010-02-01T21:29:08Z Indexed on 2010/04/04 2:23 UTC
Read the original article Hit count: 379

Filed under:
|

I'm having some issues with variable scope with the capistrano-ext gem's multistage module. I currently have, in config/deploy/staging.rb.

set(:settings) { YAML.load_file("config/deploy.yml")['staging'] }

set :repository,  settings["repository"]
set :deploy_to,   settings["deploy_to"]
set :branch,      settings["branch"]
set :domain,      settings["domain"]
set :user,        settings["user"]

role :app, domain
role :web, domain
role :db,  domain, :primary => true

My config/deploy/production.rb file is similar. This doesn't seem very DRY. Ideally, I think I'd like everything to be in the deploy.rb file. If there were a variable set with the current stage, everything would be really clean.

UPDATE: I found a solution.

I defined this function in deploy.rb:

def set_settings(params)
  params.each_pair do |k,v|
    set k.to_sym, v
  end
  if exists? :domain
    role :app, domain
    role :web, domain
    role :db,  domain, :primary => true
  end
end

Then my staging.rb file is just set_settings(YAML.load_file("config/deploy.yml")['staging'])

© Stack Overflow or respective owner

Related posts about capistrano

Related posts about ruby-on-rails