12

How do you deploy to only one server with Capistrano v3? All the solutions I found out there deploy to every server, so, I would assume they are for v2.

I don't want to deploy a stage, I'm already using multistaging and I want to deploy to only one server in one of the stages.

Pablo Fernandez
  • 279,434
  • 135
  • 377
  • 622
  • What are "all the solutions [you] found"? Please provide some hints as to what will _not_ work to prevent time being wasted on non-helpful answers. – tobias_k Jul 09 '14 at 09:26
  • 1
    Looks like you need HOST and ROLE filter. Have you tried out as mentioned in the below link? http://capistranorb.com/documentation/advanced-features/role-filtering/ Similar question was found in the following link too: http://stackoverflow.com/questions/20783552/can-capistrano-v3-specify-hosts-in-command-line-like-v2-does?rq=1 – leenasn Jul 09 '14 at 16:52
  • My answer worked for you? – gpupo Jul 16 '14 at 11:35

2 Answers2

7

As pointed out, in Capistrano 3 the way to deploy specific parts of your app to a single server is making use of HOST filtering. Let’s imagine that you are deploying directly to production and you have this configuration in config/deploy/production.rb

set :stage, :production


server "webserver1.example.com”,         roles: [:web]

server "appserver1.example.com",         roles: [:app]                   
server "appserver2.example.com",         roles: [:app]                   
server "appserver3.example.com",         roles: [:app]                        

server “dbserver1.example.com”,          roles: [:db]
server “dbserver2.example.com”,          roles: [:db]


Then if you want to deploy only to your webserver1, you just run the command:

cap --hosts=webserver1.example.com production deploy
Pablo Fernandez
  • 279,434
  • 135
  • 377
  • 622
sdude
  • 7,985
  • 2
  • 21
  • 24
  • 1
    I am running cap --host=foo production deploy and yet, capistrano, towards the end of deploying this rails application, connects to bar to run some task and fails because the release directory doesn't exist. – Pablo Fernandez Aug 04 '14 at 05:25
1

You must use settings multistage.

Capistrano 3.x is multistage by default.

In one of his stage you define only the server you want.

set :stage, :staging

server 'staging.zodiacmedia.co.uk', roles: %w{web app db}, port: 22

set :deploy_to, '/var/www/staging.example.com'

Run command:

cd /home/deploy/capistrano/example
cap staging something:to:do

This tutorial is old but may help you.

gpupo
  • 942
  • 9
  • 16
  • 1
    I'm already using multistage. I don't want to deploy to one stage, I one to deploy to one server of many in one of the stages. – Pablo Fernandez Jul 17 '14 at 08:41