Some of ohai's plugins rely on certain gems or apps to be installed.
If the dependency doesn't exist, the plugin dies quietly and ohai
moves along to the next one.
For example, it'll try to figure out what version of perl is
installed. If you don't have perl installed, you get no data. If you
do, node[:languages][:perl] exists and has stuff in it.
Typically you'll want to install the dependency in a recipe and, if
you really need the data right away instead of on the next Chef run,
you might trigger a reload of ohai. (ohai.reload_plugins, I think?
I'm pretty sure there's a resource that does this, too... ).
Or you could install those dependencies as part of the bootstrap.
There's a philosophical argument at work here -- should you do stuff
in the bootstrap or should you build up your Chef recipes to the point
where Chef can handle all that stuff itself?
The latter could be a bit of a headache if you had a gem dependency
which a _Chef_ library (any code in a cookbook's libraries
subdirectory) needed in order to run, because libraries get loaded as
soon as the cookbook is loaded. You can dabble with begin/rescue/end
blocks in the library code or you can use the "chef_gem" resource,
which immediately installs the gem into *Chef's* Ruby instance. (This
is an important distinction if you're running Chef from the omnibus
installer -- chef_gem != gem_package, in that case!)
Anyway, it sounds like that might be the best solution for you. But
chef_gem is only available in Chef 0.10.10 and newer!
Info on chef_gem is at the bottom of the "Package" resource
documentation on the almighty Chef wiki:
http://wiki.opscode.com/display/chef/Resources#Resources-PackageHope this helps.
On Fri, Oct 12, 2012 at 2:42 AM, Vladimir Girnet
<
> wrote:
Hi Gents,
Chef-omnibus 10.14.4, with Ohai 6.14.0, on CentOS 6.3 on Rackspace
I've started 4 servers, and today I've noticed that I'm missing cloud/rackspace attributes on servers.
Running "chef-client -l debug" showed this error:
----------------------
[2012-10-12T08:42:01+00:00] DEBUG: Loading plugin cloud
[2012-10-12T08:42:01+00:00] DEBUG: Loading plugin rackspace
[2012-10-12T08:42:01+00:00] DEBUG: Loading plugin ohai_time
[2012-10-12T08:42:01+00:00] DEBUG: Loading plugin network_listeners
[2012-10-12T08:42:01+00:00] DEBUG: Plugin network_listeners threw exception #<LoadError: cannot load such file -- sigar> /opt/chef/embedded/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:36:in `require'
/opt/chef/embedded/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:36:in `require'
/opt/chef/embedded/lib/ruby/gems/1.9.1/gems/ohai-6.14.0/lib/ohai/plugins/network_listeners.rb:19:in `from_file'
----------------------
Running "/opt/chef/embedded/bin/gem install sigar", and chef-client once again fixed the issue, cloud/rackspace attributes appeared back.
It looks like "sigar" gem is required for Ohai, but not installed by default.
Is this expected or a bug?
--
Vladimir Girnet
Infrastructure Engineer
Tacit Knowledge
http://www.tacitknowledge.com