Search code examples
chef-infrarhelrbenvknifeknife-solo

How to configure chef rbenv and ruby-build cookbooks?


Although no errors are thrown upon initial deploy using this run-list:

"run_list": [ "recipe[ruby_build]", "recipe[rbenv::system_install]", "recipe[main]" ]

... subsequent deploys throw multiple rsync errors like:

rsync: delete_file: unlink(ruby-build/share/ruby-build/1.9.3-p392) failed: Permission denied (13)

It seems the permissions of /tmp/chef-solo are set to root.

What's the right way to configure the rbenv and ruby-build cookbooks using knife-solo?

EDIT:

This question is really just about how to properly configure and use these two cookbooks, for example to do a user_install.


Solution

  • I think I was using outdated cookbook versions. And I didn't really know how the run list worked.

    To install rbenv and ruby_build via their respective cookbooks, see the following file configuration...

    Cheffile:

    site 'http://community.opscode.com/api/v1'
    cookbook 'rbenv', :git => 'https://github.com/fnichol/chef-rbenv', :ref => 'master' 
    cookbook 'ruby_build', :git => 'https://github.com/fnichol/chef-ruby_build', :ref => 'master'
    

    make sure to librarian-chef install after updating the Cheffile

    site-cookbooks/my_cookbook/recipes/default.rb:

    depends 'ruby_build'
    depends 'rbenv'
    

    nodes/dna.json:

    {
      "rbenv": {
        "rubies":["1.9.3-p484"],
        "global":"1.9.3-p484",
        "gems":{
          "1.9.3-p484":[
            {"name": "bundler"},
            {"name":"rails", "version": "4.0.2"},
            {"name": "rake", "version": "10.1.1"}
          ]
        }
      },
      "run_list":[
        "ruby_build", // required by "rbenv::system"
        "rbenv::system", // installs rubies and gems from dna, takes a while to finish the first time; see configuration options at https://github.com/fnichol/chef-rbenv#attributes
        "my_cookbook::default"
      ]
    }
    

    Setting these configuration variables in a recipe using node.default["var_name"] = "value_name" as suggested by the cookbook docs, did not work for me.