namespace :capistrano do
  after 'deploy:finalize_update', 'capistrano:write_roles'
  after 'deploy:finalize_update', 'capistrano:write_servers'

  desc 'Write roles config file'
  task :write_roles do
    config_hash = {}

    roles.each do |role_name, servers|
      config_hash[role_name] = servers.collect { |s| s.host }
    end

    put YAML::dump(config_hash), "#{shared_path}/config/capistrano_roles.yml"
    run "ln -s #{shared_path}/config/capistrano_roles.yml #{release_path}/config/capistrano_roles.yml"
  end

  desc 'Write servers config file'
  task :write_servers do
    config_hash = {}
    config_hash['roles'] = {}
    config_hash['options'] = {}

    roles.each do |role_name, servers|
      config_hash['roles'][role_name] = servers.collect { |s| s.host }

      servers.each do |server|
        config_hash['options'][server.host] = server.options
      end
    end

    put YAML::dump(config_hash), "#{shared_path}/config/capistrano_servers.yml"
    run "ln -s #{shared_path}/config/capistrano_servers.yml #{release_path}/config/capistrano_servers.yml"
  end
end
namespace :capistrano do
  after 'deploy:finalize_update', 'capistrano:write_roles'

  desc 'Write roles config file'
  task :write_roles do
    config_hash = {}

    roles.each do |role_name, servers|
      config_hash[role_name] = servers.collect { |s| s.host }
    end

    put YAML::dump(config_hash), "#{shared_path}/config/capistrano_roles.yml"
    run "ln -s #{shared_path}/config/capistrano_roles.yml #{release_path}/config/capistrano_roles.yml"
  end
end
--- 
+++ 
@@ -1,5 +1,6 @@
 namespace :capistrano do
   after 'deploy:finalize_update', 'capistrano:write_roles'
+  after 'deploy:finalize_update', 'capistrano:write_servers'
 
   desc 'Write roles config file'
   task :write_roles do
@@ -12,4 +13,22 @@
     put YAML::dump(config_hash), "#{shared_path}/config/capistrano_roles.yml"
     run "ln -s #{shared_path}/config/capistrano_roles.yml #{release_path}/config/capistrano_roles.yml"
   end
+
+  desc 'Write servers config file'
+  task :write_servers do
+    config_hash = {}
+    config_hash['roles'] = {}
+    config_hash['options'] = {}
+
+    roles.each do |role_name, servers|
+      config_hash['roles'][role_name] = servers.collect { |s| s.host }
+
+      servers.each do |server|
+        config_hash['options'][server.host] = server.options
+      end
+    end
+
+    put YAML::dump(config_hash), "#{shared_path}/config/capistrano_servers.yml"
+    run "ln -s #{shared_path}/config/capistrano_servers.yml #{release_path}/config/capistrano_servers.yml"
+  end
 end
Add a yml file that contains the roles and options for servers.
