Yes there is a special variable that you can use. This variable ("$ CAPISTRANO: HOST $") should be placed in the destination file name. Capistrano will interpolate it with the name of the host from which it is currently transferring files. *
Your code will now look like this:
namespace :log do desc "Get production log files" task :get_prod, :roles => :app do download("#{shared_path}/log/production.log", "log/production.$CAPISTRANO:HOST$.log") end end
Note that I also used the shared_path variable to make the code more DRY. Itβs good practice to save the configuration in one place.
* The source code for string interpolation is in the line lib / capistrano / transfer.rb 194 (in Capistrano 2.5.19):
... def normalize(argument, session) if argument.is_a?(String) argument.gsub(/\$CAPISTRANO:HOST\$/, session.xserver.host) elsif argument.respond_to?(:read) ...
General advice: if you try to find something primarily on the Internet, and when you do not find it there quite quickly, look at the source code (it does not bite and lets you know how you work with the tool).
source share