在 capify 中运行另一个任务并指定主机

发布于 2024-08-16 05:17:48 字数 336 浏览 3 评论 0原文

编辑:重新表述问题

假设您有两项任务。第一个类动态确定主机名,并且只想在该主机上调用第二个类。

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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

风筝有风,海豚有海 2024-08-23 05:17:48

好吧,有点晚了,但是......你可以尝试:

task :first_task do
  host_name = ... 
  set :hosts, host_name
  second_task
end

task :second_task do
  run "some stuff", :hosts => fetch(:hosts)
end

Well, a bit late for it to matter, but... You could try:

task :first_task do
  host_name = ... 
  set :hosts, host_name
  second_task
end

task :second_task do
  run "some stuff", :hosts => fetch(:hosts)
end
草莓味的萝莉 2024-08-23 05:17:48

如果你仔细观察的话,传入一个 HOSTS 变量是 ENV['HOSTS'] 。

Passing in a HOSTS variable is ENV['HOSTS'] if you look more closely.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文