EDIT: rephrasing the question
Say you have two tasks. The first one determines a host name dynamically, and wants to invoke the second class only on that host.
task :first_task do
host_name = ...
second_task, :hosts => hostname
end
task :second_task do
run "some stuff"
end
As far as I can tell passing in :hosts doesn't work. Assigning the new host_name to a role, and having the second task use those roles would work, but that won't work on existing tasks. This does seem to be possible as the default deploy:setup works on passing in a HOSTS variable, but I can't figure out how that works.