The year was 2007. Cats and all manner of animals on the Internet were reaching out to us, to say hello, in big, bold letters: OH HAI!
When I heard Nathen Harvey greet the class in my first Chef training at SURGE 2013, I was taken aback and tickled. He explained that Ohai, not ‘OH HAI!’, is a core tool of Chef. I daydreamed the kind of whimsical community behind creating such a delightful moment.
Nathen taught me that Ohai collects data about your system when run stand-alone or executed as one of the first steps during a chef-client run. Then, all that useful platform data is available through the node object within your recipes.
Later, when I learned about attribute precedence, my face nearly melted. But what helped me scrape it all back up, was learning that nothing messes with Ohai attributes. They are the foundations of the node, like CPU, memory, and disk space. So, of course, you could not override them.
This important detail became useful months later when I took Chef Intermediate training. Michael Goetz walked our class through creating Ohai plugins. It was from him that I learned the significance an Ohai plugin plays in managing infrastructure in a situation like detecting and repairing Shellshock, or deploying on virtualization.
Shortly after that course, my curiosity got the better of me and I was diving head first into the gem; exploring how plugins were organized inside the project and how each one did what it did for each platform. When I finally came up for air, I thought I was done. I had learned everything there is to learn about Ohai! Then, I was I asked: Can you test Ohai plugins?
The question came up while teaching a class about creating Ohai plugins and testing recipes with ChefSpec. The student expressed their frustration with the slow testing process with Ohai plugins (Edit plugin. Save file. Upload cookbook. Converge node.) and how little output you got when the plugin failed. I agreed. As a group, we had finished up early so there was plenty of time to explore. I opened a new terminal session, opened the Ohai gem, and started to piece together what eventually became the chefspec-ohai gem. This gem provides additional helpers to RSpec to be used in conjunction with ChefSpec to test your plugins.
Creating Ohai plugins got even more delightful when Tim Smith released (and continues to release) version 4 of the ohai cookbook; implementing a new, more expressive ohai_plugin resource while addressing the outstanding issues.
While hearing the name Ohai doesn’t tickle me quite like it did the first time, the peers and friends that I have found along way continue to endure. I realize now that I got some of it right, some of it wrong, and underestimated the amount of delight generated by this community.
I plan to do my part this February 1, 2017 at 10 AM PST. Join me as I present Build a Custom Ohai Plugin in a live webinar. During the hour, I will explain Ohai’s plugin structure, show you how to build and test a custom plugin, and, my favorite part, answer your questions.