Capistrano deploying to different servers with different authentication methods

核能气质少年 提交于 2019-12-24 05:42:38

问题


I need to deploy to 2 different server and these 2 servers have different authentication methods (one is my university's server and the other is an amazon web server AWS)

I already have running capistrano for my university's server, but I don't know how to add the deployment to AWS since for this one I need to add ssh options for example to user the .pem file, like this:

ssh_options[:keys] = [File.join(ENV["HOME"], ".ssh", "test.pem")] 
ssh_options[:forward_agent] = true

I have browsed starckoverflow and no post mention about how to deal with different authentication methods this and this

I found a post that talks about 2 different keys, but this one refers to a server and a git, both usings different pem files. This is not the case.

I got to this tutorial, but couldn't find what I need.

I don't know if this is relevant for what I am asking: I am working on a rails app with ruby 1.9.2p290 and rails 3.0.10 and I am using an svn repository

Please any help os welcome. Thanks a lot


回答1:


You need to use capistrano multi-stage. There is a gem that does this or you could just include an environments or stage file directly into the capfile.

You will not be able to deploy to these environments at the same time, but you could sequentially.

desc "deploy to dev environment"
 task :dev do
 set :stage_name, "dev"
 set :user, "dev"
 set :deploy_to, "/usr/applications/dev"
 role :app, "10.1.1.1"
end

desc "deploy to aws environment"
 task :aws do
  set :stage_name, "aws"
  set :user, "aws"
  set :deploy_to, "/usr/applications/aws" 
  ssh_options[:keys] = [File.join(ENV["HOME"], ".ssh", "test.pem")] 
  ssh_options[:forward_agent] = true
  role :app, "10.2.2.2"
 end

You would run:

cap dev deploy; cap aws deploy

You can expand this complexity to open VPNS, users, gateways, etc.



来源:https://stackoverflow.com/questions/11113520/capistrano-deploying-to-different-servers-with-different-authentication-methods

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!