Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Deploy to only one role / server with capistrano

I'm trying to set up multiple roles, one for live, and another for dev. They look like this:

role :live, "example.com"
role :dev, "dev.example.com"

When I run cap deploy, however, it executes for both servers. I've tried the following and it always executes on both.

cap deploy live
cap ROLE=live deploy

What am I missing? I know I can write a custom task that only responds to one role, but I don't want to have to write a whole bunch of tasks just to tell it to respond to one role or another. Thanks!

like image 714
Sean Clark Hess Avatar asked Dec 01 '22 11:12

Sean Clark Hess


1 Answers

Capistrano Multistage is definitely the solution to the example you posted for deploying to environments. In regard to your question of deploying to roles or servers, Capistrano has command-line solutions for that too.

To deploy to a single role (notice ROLES is plural):

cap ROLES=web deploy

To deploy to multiple roles:

cap ROLES=app,web deploy

To deploy to particular server (notice HOSTS is plural):

cap HOSTS=web1.myserver.com deploy

To deploy to several servers:

cap HOSTS=web1.myserver.com,web2.myserver.com deploy

To deploy to a server(s) with a role(s):

cap HOSTS=web1.myserver.com ROLES=db deploy
like image 118
scarver2 Avatar answered Dec 30 '22 08:12

scarver2