Custom Ohai Windows System Information


#1

I’d like to create a custom Ohai attribute using Ruby-wmi, I’m somewhat new to chef and I’m running into some trouble. I found a couple of community plug-ins here, win32_software, and win32_software. The plugins seem to run but when I run Ohai I dont see any of the data. Is there any good documentation on doing this on a Windows box?

Thanks


#2

Is your issue building an Ohai plugin? Using Windows API or Ruby-wmi with Ruby? Deploying an Ohai plugin?

To start with Ohai I’d recommend
https://docs.chef.io/ohai.html
https://docs.chef.io/ohai_custom.html

Or watch

When you have written an Ohai plugin, best to start with Hello World, deploy it manually and test it.
The use Ruby’s interactive tools (irb or pry) to experiment with the code you want, if you are using Ruby-wmi you will need to make sure this gem is installed.
In fact what are you using Ruby-wmi to do? There might already be a solution out there or a PowerShell equivalent o you can shell_out in your Ohai plugin.

Finally, when you have your plugin you will need to deploy it, the easiest way to do that is use the Ohai community cookbook.
https://supermarket.chef.io/cookbooks/ohai


#3

Thanks Chris, fairly new to Chef and Ruby but I’m strong with Powershell. Are you saying I could make a Powershell query and send it to Ohai?

Thanks!