开发者

Server specific details with Capistrano during deploy

I have a lot of servers running the same code with different configuration that i would like to deploy with Capistrano. The server configuration looks like this:

role(:server) { ["127.0.0.1", {:name => "mymachine1"}] }
role(:server) { ["127.0.0.2", {:name => "mymachine2"}] }
role(:server) { ["127.0.0.3", {:name => "mymachine3"}] }
开发者_JAVA百科

The problem is that is would like to create a symlink depending on the server name e.g.

task :setup_all_server do
    find_servers(:roles => "server").each do |server|
        server_name = server.options[:name]
        run "mkdir -p #{deploy_to}/releases"
        run "ln -s #{deploy_to}/current/scripts /home/#{user}/scripts"
        run "ln -s #{deploy_to}/current/configuration/#{server_name} /home/#{user}/configuration"
    end
end

The setup and the deploy works pretty good for all servers, but is there a simple way if I would like to only deploy or setup one server depending on the name? Something like

cap deploy [:name=>"mymachine1337"]

Or something like: How to deploy to a single specific server using Capistrano

but with a filter for :name without loosing the server.options[:name] when running the setup task.


This is more of a workaround than a solution for the specific problem. I ended up using the multistage extension for Capistrano https://github.com/capistrano/capistrano/wiki/2.x-Multistage-Extension with a specific configuration for each installation instead of a configuration file for each environment e.g.

/deploy/myinstallation.rb
   set :config_folder, "myinstallation"
   role(:server) { ["myuser@127.0.0.1"] }

This makes it possible to run:

cap myinstallation deploy:setup
cap myinstallation deploy
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜