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'])