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