Installing RVM/Ruby 1.9.3 via Chef

笑着哭i 提交于 2020-01-17 07:40:12

问题


I'm just getting started with trying to move my infrastructure over to Chef, and I think I must be missing something obvious.

I'm using the chef-rvm cookbook to install RVM, and I'd like it to install Ruby 1.9.3p125 and set that as the default.

Here's my base server role:

name "base"
description "Basic configuration for all nodes"
run_list(
  'recipe[git]',
  'recipe[sudo]',
  'recipe[ubuntu]',
  'recipe[rvm]',
  'recipe[postgresql::client]'
)

override_attributes(
  :authorization => {
    :sudo => {
      :users => ["ubuntu"],
      :passwordless => true
    }
  },
  :rvm => {
    :rubies => ["ruby-1.9.3-p125"],
    :default_ruby => "ruby-1.9.3-p125",
    :global_gems => ['bundler', 'rake']
  }
)

This runs without any problems, but if I ssh into the server after it's finished, rvm doesn't list any installed rubies:

ubuntu@test.server:~$ rvm list

rvm rubies


# No rvm rubies installed yet. Try 'rvm help install'.

Is this even the correct way to specify that certain rubies be installed? If not, what is the correct way? If so, what am I doing wrong?


回答1:


There's nothing wrong with your code. The problem lies in the fact that you never told Chef to install the Rubies that you defined in your role.

You have included recipe[rvm] in the role's run_list, which translates to recipe[rvm::default]. Looking into the cookbook's documentation, you find that this recipe:

Installs the RVM gem and initializes Chef to use the Lightweight Resources and Providers (LWRPs). Use this recipe explicitly if you only want access to the LWRPs provided.

What you want can be best achieved by substituting recipe[rvm] for recipe[rvm::system] in the run_list:

Installs the RVM codebase system-wide (that is, into /usr/local/rvm) and installs Rubies, global gems, and specific gems driven off attribute metadata. This recipe includes default and system _ install. Use this recipe by itself if you want RVM system-wide with Rubies installed, etc.



来源:https://stackoverflow.com/questions/18242695/installing-rvm-ruby-1-9-3-via-chef

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