Re: [capistrano] Per-server configuration

227 views
Skip to first unread message

Lee Hambley

unread,
Jun 4, 2012, 5:53:24 AM6/4/12
to capis...@googlegroups.com
Jeremy,

You'll have to re-architect your system to include the stage in the :deploy_to, this is a  smart move anyway, (personally I use /opt/sites/:application/:environment) - then simply add the staging server as a normal server in the production deployment.

You could take it a step further and set some additional options on the server (staging) that it can be excluded from spinning up web servers/etc

- Lee

On Monday, June 4, 2012 at 11:50 AM, Jérémy Lecour wrote:

Hi,

I use a multistage Capistrano configuration. I have 2 serveurs 1 for production and 1 for staging, and there are 2 stages for capistrano, with the same configuration (deploy_to, …) That way, my production and staging environments are very similar.

Having just 1 production server, I'd like to be able to switch to the 2nd server in case of emergency, or for a scheduled long maintenance.
My staging server is perfect for this, but I don't want to use the staging DB, app, … for the production environment.

I 'd like to tweak my production deployment strategy to mirror every deployment to the 2nd server but with a specific configuration (mainly the "deploy_to" variable).

Is there a way to do that?

Thanks for your help

--
* You received this message because you are subscribed to the Google Groups "Capistrano" group.
* To post to this group, send email to capis...@googlegroups.com
* To unsubscribe from this group, send email to capistrano+...@googlegroups.com For more options, visit this group at http://groups.google.com/group/capistrano?hl=en

Jérémy Lecour

unread,
Jun 4, 2012, 6:39:15 AM6/4/12
to capis...@googlegroups.com
Hi Lee, thanks for your answer.


In fact, reading the source code ,n I've found that I can use the `parallel` block like this (and it seems to work) :

set :deploy_to, lambda {
  parallel do |session|
    session.when "server.host =~ /bis/", "/home/#{user}-pra/apps"
    session.else "/home/#{user}/apps"
  end
}

This way I can match some part of the host name and have a specific deploy_to variable for my special server.

That said, I'd rather rely on the "role options" to mark one or many servers (in the "web" role) as special and set the deploy_to accordingly.

Right now, I still didn't find how to access the options hash, but I'm searching.
* To unsubscribe from this group, send email to capistrano+unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/capistrano?hl=en

Jérémy Lecour

unread,
Jun 4, 2012, 6:43:00 AM6/4/12
to capis...@googlegroups.com
I guess I've made a mistake and misunderstand this "parallel" feature. It is for executing commands, not for what I need.

Back to square 1. Sorry for the noise.

Donovan Bray

unread,
Jun 4, 2012, 11:30:23 AM6/4/12
to capis...@googlegroups.com
I think you overcomplicating it

Create two tasks

task :production ...
task :staging ...

Override as necessary setting direct values. If you have different servers set them inside the tasks

Call as:

cap production deploy
Or
cap staging deploy
* To unsubscribe from this group, send email to capistrano+...@googlegroups.com For more options, visit this group at http://groups.google.com/group/capistrano?hl=en
Reply all
Reply to author
Forward
0 new messages