在 capify 中运行另一个任务并指定主机
编辑:重新表述问题
假设您有两项任务。第一个类动态确定主机名,并且只想在该主机上调用第二个类。
task :first_task do
host_name = ...
second_task, :hosts => hostname
end
task :second_task do
run "some stuff"
end
据我所知,传入 :hosts 不起作用。将新的 host_name 分配给角色,并让第二个任务使用这些角色是可行的,但这不适用于现有任务。这似乎是可能的,因为默认的部署:设置可以传入 HOSTS 变量,但我不知道它是如何工作的。
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.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
好吧,有点晚了,但是......你可以尝试:
Well, a bit late for it to matter, but... You could try:
如果你仔细观察的话,传入一个 HOSTS 变量是 ENV['HOSTS'] 。
Passing in a HOSTS variable is ENV['HOSTS'] if you look more closely.