Ohai is missing sigar?


#1

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:inrequire’
/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


#2

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-Package

Hope this helps.

On Fri, Oct 12, 2012 at 2:42 AM, Vladimir Girnet
vgirnet@tacitknowledge.com 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:inrequire’
/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


#3

These things are known to me, and I understand how Ohai works.
Probably, my question was too generic.

  1. Should we install “sigar” rubygem on rackspace servers to let ohai detect correctly private/public IP addresses?
    1.1 Shouldn’t “sigar” rubygem be installed by default if ohai depends on it?

  2. Should we create “/etc/chef/ohai/hints/rackspace.json” to instruct ohai that we are on rackspace (OHAI-344) ?

I’m sure more people will or have the same issue, and a correct way of doing things will help everyone.

PS: “knife rackspace server create …” fails on UK Rackspace, because it searches for “.com” DNS, while UK is “.co.uk” (this can be easily changed in knife rackspace plugin, not a problem for this mail).
Because “knife rackspace server create” fails to bootstrap the server, server is bootstrapped later with “knife bootstrap”, but without knowledge that is a Rackspace server.

Thanks,

On Oct 13, 2012, at 1:20 AM, steve . wrote:

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-Package

Hope this helps.

On Fri, Oct 12, 2012 at 2:42 AM, Vladimir Girnet
vgirnet@tacitknowledge.com 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:inrequire’
/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


Vladimir Girnet
Infrastructure Engineer
Tacit Knowledge
http://www.tacitknowledge.com


#4

On Monday, October 15, 2012 at 4:56 AM, Vladimir Girnet wrote:

These things are known to me, and I understand how Ohai works.
Probably, my question was too generic.

  1. Should we install “sigar” rubygem on rackspace servers to let ohai detect correctly private/public IP addresses?
    1.1 Shouldn’t “sigar” rubygem be installed by default if ohai depends on it?

Sigar is optional. For most people, ohai gets the information they need without it. People who want or need the additional information can install sigar to get it.

Ohai should probably have a more structured mechanism for this kind of thing, perhaps something like knife plugins’ rubygems integration, but that’s how it is for now.


Daniel DeLeo