namespace :package do
task :install, :packages do |task, args|
on roles(:all) do
execute :sudo, "apt-get install -y #{args[:packages]}"
end
end
end
namespace :git do
task :install do
# 1 code
invoke 'package:install', 'git-core' # works but I want this installed only on the :app role
# 2 code
on role(:app) do
invoke 'package:install', 'git-core' # errors
end
end
end
注意:我没有运行#1
和#2
,我正在运行#1
或#2
。
是否有办法invoke
任务和指定执行哪个role
?