开发者

Inherit roles from parent tasks in Capistrano callbacks

开发者 https://www.devze.com 2023-03-25 07:46 出处:网络
I have several tasks which all must check that the machines serving as roles have a certain file with certain contents.The logic is reasonable to separate into a prerequisite, or a callback.

I have several tasks which all must check that the machines serving as roles have a certain file with certain contents. The logic is reasonable to separate into a prerequisite, or a callback.

开发者_运维百科
task t1, :roles => [:r1] do
  ...
end

task t2, :roles => [:r2,:r3] do
  ...
end

before <what?> do
  # must only run on :r1 when triggered by t1,
  # and only on :r2 and :r3 when triggered by t2!
  <ensure role given to parent task has a given file>
end

How do we do that in Capistrano?


It turns out that a before callback can invoke a regular def, in which case it runs for the roles of the parent task. If, however, you call a task there, and that task has no roles, all roles will be used to run it. The real question is where are the dependencies across tasks...

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号