I\'ve heard that Capistrano supports deployment to multiple servers, but I haven\'t found a practical way to set it up. When I say multiple servers I mean servers running the sa
Using multiple servers is one of the main reasons to use capistrano versus just doing things by hand.
Your deploy.rb just needs to define what actions should be performed on what servers, which is done by setting which servers belong to which roles. You can create your own roles, but the built-in capistrano recipes expect you to define 3 roles:
It's not uncommon for these 3 to be synonymous: if you have a bunch of identical servers all running apache + passenger then they are all app and web servers. One of them needs to be given the db role.
You define roles in your deploy.rb file. At its simplest this is just a list of ip addresses or host names:
role :app, [192.168.1.1,192.168.1.2]
It can also be a block. For example when deploying to ec2 you might insert an api call that retrieves the list of servers to deploy to. I usually do this by assigning tags to servers, in which case you might have
role :app do
ec2.instances.tagged('app').map(&:ip_address)
end
to have that role map to the ec2 instances with the app tag (capistrano caches this information and will only execute your block once)
I had to use a different syntax with Rails 4.
role :app, %w{s01.app.com s02.app.com}
role :web, %w{s01.web.com s02.web.com}