n8gard
n8gard

Reputation: 1970

RVM installing but no Rubies with Chef-solo and Vagrant?

I am using Chef-solo, Berkshelf and Vagrant to try to build a development environment. I have other recipes working but the 'chef-rvm' cookbook is giving me trouble for getting a ruby version installed.

To be clear, RVM is installing but when I 'vagrant ssh' into the vbox and type 'rvm list' it says there are no rubies installed. I can type 'rvm install 2.1.1' and it works so I'm not sure why Chef isn't installing it.

Vagrantfile:

config.vm.provision :chef_solo do |chef|
  chef.run_list = %w[
    recipe[apt::default]
    recipe[rvm::user_install]
    recipe[rvm::vagrant]
  ]
end

recipes/default.rb:

include_recipe 'apt'
include_recipe 'rvm::user_install'

attributes/default.rb:

    node.set['rvm']['user_installs'] = [
    { 'user'            => 'vagrant',
      'upgrade'         => 'head',
      'default_ruby'    => '2.1.1',
      'rvm_gem_options' => '',
      'rubies' => ['2.1.1', '2.0.0-p481'],
      'global_gems'     => [
          { 'name'    => 'bundler',
            'version' => '1.6.2'
          },
          { 'name'    => 'rake' },
          { 'name'    => 'rails' },
          { 'name'    => 'rubygems-bundler',
            'action'  => 'remove'
          }
      ]
    }
]

Upvotes: 0

Views: 415

Answers (1)

Fernando Vieira
Fernando Vieira

Reputation: 3333

I thought it should be the default action, but I have the same problem as you. My solution was to include the "install_ruby" property in the json config:

node.set['rvm']['user_installs'] = [
    { 'user'            => 'vagrant',
       install_rubies: true,
       ...
    }
]

Upvotes: 1

Related Questions