Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do you deploy to only one server with Capistrano v3?

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.

like image 330
pupeno Avatar asked Jun 16 '14 08:06

pupeno


2 Answers

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
like image 119
sdude Avatar answered Nov 11 '22 05:11

sdude


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.

like image 1
gpupo Avatar answered Nov 11 '22 05:11

gpupo