我尝试使用不同的ssh_options在同一阶段运行capistrano v.3任务.
我的production.rb说:
set :stage, :production
set :user, 'deploy'
set :ssh_options, { user: 'deploy' }
Run Code Online (Sandbox Code Playgroud)
通过这种配置,capistrano与用户部署连接,这对于其余的用户来说是正确的.但是我需要将一个特定任务与一个在服务器中配置良好的an_other_user连接起来.然后我的食谱说:
...
tasks with original user
...
task :my_task_with_an_other_user do
set :user, 'an_other_user'
set :ssh_options, { user: 'an_other_user' }
on roles(:all) do |host|
execute :mkdir, '-p', 'mydir'
end
end
...
other tasks with original user
...
Run Code Online (Sandbox Code Playgroud)
执行时:
cap production namespace:my_task_with_an_other_user
capistrano使ssh conexion与original:user"deploy"(在production.rb中声明的用户).
如何在任务中更改用户和/或ssh_options?