[英]Executing commands based on the role inside a task in capistrano
I have a pseudo as follows 我有一个伪如下
task :my_task, roles => [:role1, :role2] do
command 1
command 2
command 3
command 4
end
I want to run command 1 & command 2, only for role1, command 3 & command 4,for role2. 我只想为角色1运行命令1和命令2,为角色2运行命令3和命令4。 Is this possible in capistrano?
capistrano有可能吗?
I tried, 我试过了,
task :my_task, roles => [:role1, :role2] do
on roles(:role1) do
command 1
command 2
end
on roles(:role2) do
command 3
command 4
end
end
But didn't seem to work for me..Please help :) 但似乎没有为我工作..请帮助:)
Btwn, I'm using Capistrano v2.15.5 Btwn,我正在使用Capistrano v2.15.5
Thanks in advance 提前致谢
This may not be a great way of solving it..but this was all I could and it worked for me. 这可能不是解决问题的好方法。但这就是我所能做的,并且对我有用。
task :my_task do
task_1
task_2
end
task :task_1, :roles => [:role1] do
command 1
command 2
end
task :task_2, :roles => [:role2] do
command 3
command 4
end
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.