如何通过chef安装rvm/ruby/rails ?

时间:2021-02-27 07:15:59

First, I would like to point out that I have read the question located here: Installing RVM/Ruby 1.9.3 via Chef

首先,我想指出的是,我已经阅读了这里的问题:通过Chef安装RVM/Ruby 1.9.3

I am trying to set up a Ruby on Rails environment in Windows using VirtualBox/Vagrant. The installation of VirtualBox and Vagrant are pretty self-explanatory, but delving into the configuration of Vagrant and things like Chef become less clear.

我正在尝试在Windows中使用VirtualBox/Vagrant建立Ruby on Rails环境。安装VirtualBox和Vagrant是非常容易理解的,但是深入研究流浪者的配置以及像Chef这样的东西就不那么清楚了。

I am following instructions from a blog here: http://manuelvanrijn.nl/blog/2013/07/23/developing-ruby-on-rails-on-windows/

我正在遵循一个博客的指示:http://manuelvanrijn.nl//2013/07/23/bloging-ruby-on - rails/windows/

Which include installation of the librarian-chef gem to manage cookbooks, and using the following Cheffile:

其中包括安装“图书馆-厨师创业板”管理食谱,并使用以下文件:

#!/usr/bin/env ruby
#^syntax detection

site 'http://community.opscode.com/api/v1'

cookbook 'apt'
cookbook 'git'
cookbook 'sqlite'
cookbook 'mysql'
cookbook 'postgresql'
cookbook 'database', :git => 'git://github.com/manuelvanrijn/cookbook-database.git', :ref => 'grant-roles'
cookbook 'nodejs'
cookbook 'build-essential'
cookbook 'ruby_build'
cookbook 'rbenv', :git => 'git://github.com/fnichol/chef-rbenv.git', :ref => 'v0.7.2'

My problem is that launching my Vagrant box initially, and the base box (precise64) that I am using comes with ruby 1.8.7p358.

我的问题是最初启动我的流浪盒,我使用的基础盒(precise64)与ruby 1.8.7p358一起。

In order to get a functioning Rails site, I needed to install rvm, install a newer version of Ruby, then install Rails before I was able to run rails new rails_site

为了获得一个正常运行的Rails站点,我需要安装rvm,安装新版本的Ruby,然后在运行Rails新rails_site之前安装Rails

I have found a cookbook for rvm here: https://github.com/fnichol/chef-rvm

我在这里找到了一本rvm的食谱:https://github.com/fnichol/chef-rvm

So what I am hoping to accomplish is, add the rvm cookbook, automatically install a specific version of Ruby, and then install Rails, so that I can have a functional development environment out of the box. I know that I can add the cookbook by adding a line at the end of my Cheffile, but beyond that, how do I also instruct rvm to install a specific version of Ruby, then after that, to install Rails as well?

因此,我希望完成的是,添加rvm cookbook,自动安装特定版本的Ruby,然后安装Rails,这样我就可以获得现成的功能开发环境。我知道我可以通过在我的Cheffile结尾添加一行来添加cookbook,但是除此之外,我还应该如何指示rvm安装一个特定版本的Ruby,然后再安装Rails ?

1 个解决方案

#1


2  

To install rvm, I have used cookbook you specified. What you need is to add it to Cheffile:

要安装rvm,我使用了您指定的cookbook。你需要把它添加到Cheffile:

cookbook 'rvm', :git => 'git://github.com/fnichol/chef-rvm.git', :ref => '24ecbb0'

I have used ref, because last version wasn't working properly(don't know if it was fixed, but you can try my way, then switch and tryout newer). Next step is to add rvm to the role you are using for your node:

我使用了ref,因为上一个版本没有正常工作(不知道它是否被修复了,但是您可以尝试我的方式,然后切换和试用更新)。下一步是将rvm添加到您正在为您的节点使用的角色:

'recipe[rvm::user]',

after you specified this role in nodefile(in your tutorial it is Vagrantfile), you can configure rvm installation like this:

当您在nodefile中指定了这个角色(在您的教程中它是Vagrantfile)之后,您可以这样配置rvm安装:

  'rvm' => {
    'installer_url' => 'https://raw.github.com/wayneeseguin/rvm/master/binscripts/rvm-installer',
    'branch' => 'none',
    'version' => '1.17.10',
    'user_installs' => [{        
      'user' => 'someuser',
      'default_ruby' => 'ruby-1.9.3-p286@mygemsetname'
    }]
  }

thats it. Rvm should be installed for someuser with ruby-1.9.3-p286@mygemsetname gemset. To install Rails in specific dir and other custom actions you will need to learn how to write own cookbooks, it is very easy, you will need to log-in as someuser, cd to dir you need and execute gem install, then rails new(of course if you want to install rvm/rails as a user, not systemwide)

这是它。应该为ruby-1.9.3-p286@mygemsetname gemset的某个用户安装Rvm。安装Rails在特定dir和其他自定义动作,你需要学习如何编写自己的食谱,非常简单,您将需要登录someuser,cd,你需要安装和执行宝石,那么Rails新的(当然如果你想安装区/ Rails作为一个用户,而不是系统)

UPD: To install custom gems you can use chef-rvm or your own cookbook:

UPD:要安装自定义gems,您可以使用chef-rvm或您自己的食谱:

./site_cookbooks/mycookbook/recipes/default.rb

/ default.rb。/ site_cookbooks / mycookbook食谱

execute 'install mysql2 gem' do
  command 'gem install mysql2'
  not_if 'gem list | grep mysql2'
end

#1


2  

To install rvm, I have used cookbook you specified. What you need is to add it to Cheffile:

要安装rvm,我使用了您指定的cookbook。你需要把它添加到Cheffile:

cookbook 'rvm', :git => 'git://github.com/fnichol/chef-rvm.git', :ref => '24ecbb0'

I have used ref, because last version wasn't working properly(don't know if it was fixed, but you can try my way, then switch and tryout newer). Next step is to add rvm to the role you are using for your node:

我使用了ref,因为上一个版本没有正常工作(不知道它是否被修复了,但是您可以尝试我的方式,然后切换和试用更新)。下一步是将rvm添加到您正在为您的节点使用的角色:

'recipe[rvm::user]',

after you specified this role in nodefile(in your tutorial it is Vagrantfile), you can configure rvm installation like this:

当您在nodefile中指定了这个角色(在您的教程中它是Vagrantfile)之后,您可以这样配置rvm安装:

  'rvm' => {
    'installer_url' => 'https://raw.github.com/wayneeseguin/rvm/master/binscripts/rvm-installer',
    'branch' => 'none',
    'version' => '1.17.10',
    'user_installs' => [{        
      'user' => 'someuser',
      'default_ruby' => 'ruby-1.9.3-p286@mygemsetname'
    }]
  }

thats it. Rvm should be installed for someuser with ruby-1.9.3-p286@mygemsetname gemset. To install Rails in specific dir and other custom actions you will need to learn how to write own cookbooks, it is very easy, you will need to log-in as someuser, cd to dir you need and execute gem install, then rails new(of course if you want to install rvm/rails as a user, not systemwide)

这是它。应该为ruby-1.9.3-p286@mygemsetname gemset的某个用户安装Rvm。安装Rails在特定dir和其他自定义动作,你需要学习如何编写自己的食谱,非常简单,您将需要登录someuser,cd,你需要安装和执行宝石,那么Rails新的(当然如果你想安装区/ Rails作为一个用户,而不是系统)

UPD: To install custom gems you can use chef-rvm or your own cookbook:

UPD:要安装自定义gems,您可以使用chef-rvm或您自己的食谱:

./site_cookbooks/mycookbook/recipes/default.rb

/ default.rb。/ site_cookbooks / mycookbook食谱

execute 'install mysql2 gem' do
  command 'gem install mysql2'
  not_if 'gem list | grep mysql2'
end