How to deploy ohai plugin

Hello,

I'm a little confused by how custom ohai plugins should be "deployed" on the target servers on which they are required. The docs say in order to install the plugin, you create an ohai directory in the cookbook, and move the plugin in there.

When I create a cookbook with this ohai directory (and no recipes) and add this cookbook to my policy, I receive an error

Error: Failed to generate Policyfile.lock
Reason: (ChefCLI::CookbookDoesNotContainRequiredRecipe) The installed cookbooks do not contain all the recipes required by your run list(s):
Cookbook ... is missing the following required recipes:
* default

When I add an empty recipes/default.rb file, the policy gets created, and when it executed, the cookbook is synchronized with ohai/plugin.rb file in the cache, the runlist shows the plugin default recipe and the plugin ran.

So, is this the correct way to deploy an ohai plugin to all servers using a policy, using an empty default recipe?

Yes, that's it. Generally, it is expected that if you are using Policyfiles, you will have a cookbook recipe of some kind.

If you just want to deploy ohai plugins, your example would be a way to do it while using Policyfiles.