It depends on your version of Capistrano.
In the case you're using the version 3, here is blog article explaining it: https://jtway.co/capistrano-3-passing-parameters-to-your-task-e22cc9f659c3.
Basically you pass arguments like you would do with rake tasks, so passing them between brackets ([]
):
cap staging mynamespace:mytask[argument1,argument2]
Then in your task, you can catch them like so:
namespace : mynamespace do
desc 'Description of my task here'
task :mytask do |task, args|
puts "Arguments: #{args.inspect}"
end
end
In your example you would have to execute Capistrano that way:
cap staging namespace:task[target_host]
First argument would be the target hostname.