简体   繁体   English

最新的红宝石厨师食谱

[英]Up-to-date Chef cookbook for ruby

Is there an up-to-date cookbook for ruby? 是否有最新的红宝石食谱? I wasn't able to find one on the opscode cookbook site. 我无法在opscode cookbook网站上找到一个。 ie ruby 1.9.3 or 1.9.2p280. 即红宝石1.9.3或1.9.2p280。

I just finished updating Carlo Zottman's ruby 1.9.x cookbook (noticed this question while having lunch, prior to writing a pull request, lol...) 我刚刚更新了 Carlo Zottman的红宝石1.9.x食谱 (在吃午餐时注意到这个问题,在写一个拉动请求之前,哈​​哈...)

The only dependencies are the standard build-essential and apt cookbooks from the opscode cookbook site. 唯一的依赖是来自opscode cookbook网站的标准build-essential和apt cookbook。

As for the discussion about when a cookbook such as this one might be needed, I'm using it to upgrade from ruby 1.8 to ruby 1.9 on my 12.04.01 vagrant boxes before using the rbenv cookbook (and various others). 关于何时可能需要这样的食谱的讨论,我在使用rbenv食谱(以及其他各种食谱) 之前使用它从我的12.04.01流浪盒上的ruby 1.8升级到ruby 1.9。

I realize that I ought to be able to use the rbenv cookbook to install 1.9.3, but after futzing with that unsuccessfully for a couple of hours, I realized that I was happier with the source installation anyway, as it makes my whole recipe stack less brittle. 我意识到我应该能够使用rbenv cookbook来安装1.9.3,但是经过几个小时的不成功,我意识到我对源安装感到更满意,因为它使我的整个食谱堆栈不那么脆弱。 And a shell script to rbenv install 1.9.3 as the vagrant user was trivial to write. 并且rbenv安装1.9.3的shell脚本作为流浪者用户写起来很简单。

Update 更新

I found an alternative approach that has even fewer dependencies (yes!) I'm using Fletcher Nichol's cookbooks: 我找到了一种替代方法,它具有更少的依赖性(是的!)我正在使用Fletcher Nichol的烹饪书:

  • ruby_build from the opscode community page ruby_build从Opscode公司社区页面
  • chef-rbenv from github (Not the same as the rbenv cookbook at opscode) 来自github的chef-rbenv (与opscode的rbenv cookbook不同)

Strictly speaking, of course, you could just use ruby_build to install your preferred 1.9 and stop, but I want rbenv as well. 当然,严格来说,你可以使用ruby_build安装你喜欢的1.9并停止,但我也想要rbenv。

I've included some snippets from my setup (there's more to the Berksfile and Vagrantfile, of course, but these are the relevant bits.) The only truly tricky part is that the local name of the chef-rbenv cookbook has to be rbenv if you want to use any of the off-the-shelf recipes that include other off-the-shelf recipes from the cookbook, as it refers to itself as rbenv. 我已经在我的设置中包含了一些片段(当然,还有更多的Berksfile和Vagrantfile,但这些是相关的部分。)唯一真正棘手的部分是chef-rbenv cookbook的本地名称必须是rbenv if你想要使用任何现成的食谱,包括来自食谱的其他现成食谱,因为它将自己称为rbenv。 Berkshelf made that trivial. Berkshelf做了那件小事。

Berksfile : Berksfile

group :ruby do
  cookbook 'ruby_build'
  cookbook 'rbenv', git: 'https://github.com/fnichol/chef-rbenv'
end

Vagrantfile: Vagrantfile:

config.vm.provision :chef_solo do |chef|
  chef.cookbooks_path = 'chef/cookbooks'
  chef.roles_path     = 'chef/roles'
  chef.json           = {
    'rbenv' => {
      'global' => '1.9.3-p194',
      'rubies' => [ '1.9.3-p194' ],
      'gems'   => {
        '1.9.3-p194' => [
          { 'name'   => 'bundler' }
        ]
      }
    }
  }
  chef.add_role 'ruby'
end

chef/roles/ruby.json: 厨师/角色/ ruby​​.json:

{
  "name": "ruby",
  "description": "Install ruby and rbenv",
  "chef_type": "role",
  "json_class": "Chef::Role",

  "run_list": [
    "recipe[ruby_build]",
    "recipe[rbenv::system]"
  ]
}

A final comment is that once I figured the solution out, I realized that Victor's answer is likely the chef server version of the same thing. 最后的评论是,一旦我解决了解决方案,我意识到Victor的答案很可能是同一件事的厨师服务器版本。 I have only used chef-solo so far, so I am not sure. 到目前为止我只使用过厨师独奏,所以我不确定。

I'm not sure whether you'll find one for updating the system version of Ruby, as chef is built on top of Ruby, and would therefore be updating itself whilst running, which I'm not sure is possible. 我不确定你是否会找到一个更新Ruby的系统版本,因为厨师是建立在Ruby之上的,因此在运行时会自行更新,我不确定是否可行。

However, I've definitely seen Chef cookbooks for Ruby version managers such as RBenv and RVM, such as this one for rbenv , and this one for RVM . 但是,我确实看到过RBenv和RVM等Ruby版本管理器的Chef cookbook,比如rbenv的这个 ,以及RVM的这个 Is this for a Server or an OSX dev box? 这是服务器还是OSX开发箱? if it's for the later, then I've found Smeagol to be a pretty handy shortcut when configuring machines. 如果它适用于后者,那么在配置机器时我发现Smeagol是一个非常方便的快捷方式。

I think the easiest is to use two cookbooks: ruby_build and rbenv. 我认为最简单的方法是使用两本烹饪书:ruby_build和rbenv。 In your role ( <proj>/roles/role_name.rb ): 在你的角色( <proj>/roles/role_name.rb ):

name "your-role-name"

description "All the shelves!"

run_list(
  "recipe[ruby_build]",
  "recipe[rbenv::system]"
)

override_attributes(
  'rbenv' => {
    'global' => '1.9.2-p280',
    'rubies' => [
      '1.9.2-p280'
    ]
  }
)

Adding this role (preferably before other roles that would require these rubies) to your run list should do it. 将此角色(最好在需要这些红宝石的其他角色之前)添加到运行列表中应该这样做。

To edit a run list: knife node edit <node name> 编辑运行列表: knife node edit <node name>

Don't forget to update the role! 别忘了更新角色! knife role from file role_name.rb

Lastly, rubyenv may be a slightly cleaner way of managing rubies than rvm. 最后,rubyenv可能比rvm更轻松地管理红宝石。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM