How to get stand-alone ohai to recognize custom plugin_path?

295 Views Asked by At

I have chef configured to add "/etc/chef/ohai_plugins" to Ohai::Config[:plugin_path]. However, the Chef documentation says:

"The Ohai executable ignores settings in the client.rb file when Ohai is run independently of the chef-client."

So, how can I get a stand-alone run of ohai to load and use the plugins in that custom path?

(Background: I have a custom plugin that reports some information that we keep track of for a fleet of servers, like whether a server has been patched for heartbleed or shellshock. I want to be able to run "ssh somehost ohai", parse the JSON that gets sent back, and extract the information I need.)

Thanks.

2

There are 2 best solutions below

1
On BEST ANSWER

Outside of chef, you can add an additional plugin path using the -d switch, e.g.

$ ohai -d /etc/chef/ohai_plugins

The relevant source code is at:

The option to specify a custom config file for Ohai was sadly removed last year with https://github.com/chef/ohai/commit/ebabd088673cf3e36d600bd96aeba004077842f1

Hope this answers your question.

0
On

This will be possible soon via the implementation of Chef RFC 53: https://github.com/chef/chef-rfc/blob/master/rfc053-ohai-config.md