Posted over 1 year ago. Visible to the public.

Capistrano 2: How to deploy a single server

When you have a multi-server setup, you'll be adding a new server from time to time. Before doing a full deploy, you might want to test that server in an isolated deploy. There is a single way to do this: the HOSTFILTER env variable.

Commenting out "server" lines in the Capistrano deploy config will raise a Capistrano::NoMatchingServersError with <task> is only run for servers matching {:roles=> <role>}, but no servers matched. Instead, specify the server-under-test like this:

Copy cap production deploy

Capistrano is aware of this env variable and will only deploy that single server, skipping any tasks that do not apply. Profit!

As a side note, there is a secret Capistrano task option that will also silence the above exception. Generally it is a good idea that Capistrano complains when it doesn't have a server to run a (presumably important) task on. If you want it optional, define it like this:

task :my_task, on_no_matching_server: :continue do # Do stuff end
Growing Rails Applications in Practice
Check out our new e-book:
Learn to structure large Ruby on Rails codebases with the tools you already know and love.

Owner of this card:

Dominik Schöler
Last edit:
over 1 year ago
by Dominik Schöler
About this deck:
We are makandra and do test-driven, agile Ruby on Rails software development.
License for source code
Posted by Dominik Schöler to makandra dev
This website uses cookies to improve usability and analyze traffic.
Accept or learn more