2
votes

I am trying to install a global version of ruby that other chef recipes will recognize as the system ruby. I am attempting to do this with chef-rbenv which seems to work on a user level but does not work when chef runs ohai. I say it doesn't work when chef runs ohai because cookbooks like passenger_apache2 reference node['languages']['ruby']['ruby_bin'] which points to "/usr/bin/ruby". However when I run ohai logged in as a user I get the rbenv shim location. Am I missing something in my rbenv configuration to see this behavior?

Additional Info:

Platform - amazon (ami-05355a6c)

run_list:

recipe[ruby_build]
recipe[ohai]
recipe[rbenv::system]
recipe[build-essential]
recipe[apache2]
recipe[passenger_apache2]
recipe[passenger_apache2::mod_rails]

--UPDATE

I never got the chef-client ohai to pick up my rbenv settings but this is no longer a problem because I ended up overriding the node attributes in a role. This was only possible due to a recent change (passenger_apache2 commit -a0a32fda0b56228d6e54163c98f6736e17cad12c).

Note: omnibus would likely have solved my problems too.

2
Why do you want to do this? Chef comes with an embedded copy of ruby which you should favour as it increase reliability. Software like passenger should favour the system ruby. Perhaps your question should focus on getting systems like passenger to use rbenv, rather than the cookbook recipes.Mark O'Connor
I am doing this because I have legacy applications that require ree-1.8.7. Getting passenger to use rbenv is as easy as hard coding the path in the config file. I'd prefer for the paths to be determined by ohai like it's currently coded in the passenger cookbook. (That is if it's possible)MikeV

2 Answers

0
votes

This cookbook has an Ohai plugin that does that. You could:

  • Switch cookbooks for this one;
  • Have a look in the rbenv::ohai_plugin recipe and reproduce it in your environment (like in a wrapper cookbook).

The first option might not satisfy your needs due to differences in the cookbooks, while the second one might prove more difficult than it seems (I haven't tried...)

0
votes

you could overwrite the default attribute at the recipe or node level

i think this is the syntax

...
"languages": {
  "ruby": {
    "ruby_bin" : "/usr/bin/ruby42"}
},
...