Capistrano似乎没有适当地处理角色 - 至少我怎么理解他们。我不能让下面的简单Capfile按预期工作:capistrano角色和主机问题/错误?
role :test1, "[email protected]"
role :test2, "[email protected]"
task :full_test, :roles => [:test1,:test2] do
log_test1
log_test2
end
task :log_test1, :roles => :test1 do
logger.info "TEST1 !!!"
run "echo `hostname`"
end
task :log_test2, :roles => :test2 do
logger.info "TEST2 !!!"
run "echo `hostname`"
end
当我尝试用角色的角色限制=执行:为test1,在log_test2是未声明为同一台主机上仍会执行作为角色的一部分:test2!卡皮斯特拉诺的预期行为是?如果预期的话,有什么办法可以防止这种情况发生?
ROLES=test1 cap full_test
* executing `full_test'
* executing `log_test1'
** TEST1 !!!
* executing "echo `hostname`"
servers: ["beta-app-01"]
[[email protected]] executing command
** [out :: [email protected]] ec2-*****.compute-1.amazonaws.com
command finished in 350ms
* executing `log_test2' <<<< shouldn't that be filtered ? because of :roles => :test2 ?
** TEST2 !!!
* executing "echo `hostname`"
servers: ["beta-app-01"]
[[email protected]] executing command
** [out :: [email protected]] ec2-*****.compute-1.amazonaws.com
command finished in 410ms
由于提前,相关条目(http://stackoverflow.com/questions/754015/creating-a-capistrano-task-that-performs-different-tasks-based-on-role)我可以发现似乎并没有涵盖这个问题......
谢谢!那就是诀窍... – zuzur 2011-04-27 05:28:03