Ohai Custom Plugins

I have written an Ohai custom plugin that determines the site and vlan of
the node.
I need this information to define attrs for other cookbooks.

My problem is a chicken and egg scenario. The chef-run borks on the
attribute the ohai plugin is supposed to return as a string because it is
not being set at compile time when I test the attr in a case. When the
attr evaluates the attribute it is nil when it expects a string.

Any thoughts on how to get around this?


Thanks,

Mark

The first "Chef extension" code I ever wrote was just such a plugin! I
think we even showed some of the code at ChefConf. It did some stupid
things until someone contributed some extremely simple code that basically
set all of the data to "Unknown" values if no match was found for any of
the node's IPs. We fixed a bunch of cookbook errors with that.

(We're working through processes to get clearance to open-source some
things, BTW... that plugin probably won't be the first thing but it's on
the list somewhere.)

Anyway, it sounds like your test suite needs to load and run your custom
Ohai plugin during setup. I believe the community Ohai plugin cookbook
shows you how to do this...

On Wed, Jul 24, 2013 at 5:48 AM, Mark Pimentel markpimentel22@gmail.comwrote:

I have written an Ohai custom plugin that determines the site and vlan of
the node.
I need this information to define attrs for other cookbooks.

My problem is a chicken and egg scenario. The chef-run borks on the
attribute the ohai plugin is supposed to return as a string because it is
not being set at compile time when I test the attr in a case. When the
attr evaluates the attribute it is nil when it expects a string.

Any thoughts on how to get around this?

--
Thanks,

Mark