2012-03-30 264 views
2

我正在使用Capistrano来引导一个空的Ubuntu VM。用capistrano和rvm-capistrano部署

我有一个基础的食谱,安装基础要求:

食谱/ base.rb

def set_default(name, *args, &block) 
    set(name, *args, &block) unless exists?(name) 
end 

namespace :deploy do 
    desc "Install everything onto the server" 
    task :install do 
    run "#{sudo} apt-get -y update" 

    # Common dependencies 
    run "#{sudo} apt-get -y install curl git-core build-essential python-software-properties" 
    run "#{sudo} apt-get -y install sudo apt-get -y install build-essential openssl libreadline6 libreadline6-dev curl git-core zlib1g zlib1g-dev libssl-dev libyaml-dev libsqlite3-dev sqlite3 libxml2-dev libxslt-dev autoconf libc6-dev ncurses-dev automake libtool bison subversion" 

    # Set timezone to UTC 
    run "#{sudo} bash -c 'echo UTC > /etc/timezone'" 
    run "#{sudo} cp /usr/share/zoneinfo/UTC /etc/localtime" 
    run "#{sudo} dpkg-reconfigure -f noninteractive tzdata" 
    end 
end 

我也有安装RVM食谱。我用的是rvm-capistrano宝石本:

食谱/ rvm.rb

set_default(:rvm_ruby_string) { "[email protected]#{application}" } 
set_default(:rvm_install_type, :stable) 
set_default(:rvm_type, :user) 

require 'rvm/capistrano' 

after 'deploy:setup', 'rvm:install_rvm' 
after 'deploy:setup', 'rvm:install_ruby' 

仿佛rvm-capistrano宝石修改每个任务的默认外壳和附加看来:

rvm_path=$HOME/.rvm/ $HOME/.rvm/bin/rvm-shell '[email protected]' 

的反映这是我的基本配方不再有效,因为它在安装rvm之前运行:

cjoudrey (master) app$ cap deploy:install 
    * executing `deploy:install' 
    * executing "sudo -p 'sudo password: ' apt-get -y update" 
    servers: ["33.33.33.10"] 
    [33.33.33.10] executing command 
    [33.33.33.10] rvm_path=$HOME/.rvm/ $HOME/.rvm/bin/rvm-shell '[email protected]' -c 'sudo -p '\''sudo password: '\'' apt-get -y update' 
** [out :: 33.33.33.10] bash: /home/vagrant/.rvm/bin/rvm-shell: No such file or directory 
    command finished in 45ms 
failed: "rvm_path=$HOME/.rvm/ $HOME/.rvm/bin/rvm-shell '[email protected]' -c 'sudo -p '\\''sudo password: '\\'' apt-get -y update'" on 33.33.33.10 
cjoudrey (master) app$ 

deploy.rb

require 'bundler/capistrano' 

load 'config/recipes/base' 
load 'config/recipes/rvm' 
load 'config/recipes/nginx' 
load 'config/recipes/mysql' 
load 'config/recipes/nodejs' 

server '33.33.33.10', :web, :app, :db, primary: true 

set :user, 'vagrant' 
set :application, 'app' 
set :deploy_to, "/home/#{user}/apps/#{application}" 
set :deploy_via, :remote_cache 
set :use_sudo, false 

set :scm, 'git' 
set :repository, '[email protected]:cjoudrey/test.git' 
set :branch, 'master' 

default_run_options[:pty] = true 
ssh_options[:forward_agent] = true 
ssh_options[:keys] = `vagrant ssh-config | grep IdentityFile`.split(' ').last 

after 'deploy', 'deploy:cleanup' 

有没有人有这个问题?有没有办法控制rvm-capistrano修改默认shell的时间?即有没有办法让它不修改deploy:install的默认外壳?

我应该只是制作自己的rvm食谱而不是使用rvm-capistrano

回答

4

我有一个类似的问题,并最终在我的deploy.rb中写了一个disable_rvm_shell函数。我在一个博客文章中记录了这个:Capistrano, system wide RVM and creating gemsets as part of deploy:setup

+2

使它成为宝石 - 非常有用的东西,你也可以做'跑'...“,:shell =>”bash“' – mpapis 2012-03-30 16:58:55

+0

@RyanWilcox blog.wilcoxd.com is down – matt 2012-05-23 08:15:42

+0

我会很感兴趣知道你是如何做到这一点的。我有一个生产系统,我不想安装RVM,但仍想使用相同的配方来控制它......我最终做的是编写一个简单版本的git-shell https:// gist .github.com/2785833并将其安装到〜/ .rvm/bin/rvm-shell – 2012-05-25 04:54:14