May 1, 2019 · Exploration

Learning Chef In 30 Days: Busboy to Sous Chef

My spare cycles for the month of April were dedicated to learning all I could about Chef, an infrastructure-as-code configuration management tool. On April 1st, I knew next to nothing about how to write and structure cookbooks, the basic building block of using Chef.

Now, today, May 1st, I'm confident that I could put together a cookbook to do almost anything, given enough time to implement it.

Cookbooks are Chef Infra's core offering: write a cookbook for configuring a single server or thousands of them, and the chef-client will run it again and again to always ensure your nodes are still set up exactly the way you intended.

Learning Chef can look daunting at first – but don't fret! There are a lot of resources out there to help. I began learning Chef with a course on Lynda (Learning Chef). This set me up to understand the basics without introducing topics like kitchen just yet.

From there, I found a low-stakes application server in our organization that had not yet been automated with Chef. I started with this thought in mind:

If I were going to set up this server from scratch, what would I need to install and what settings would I need to configure to make this server operate exactly the same as it does now?

Once I'd done that, I began crafting a basic recipe to set up the server. A typical cookbook is made up of recipes and attributes. Attributes are like global variables, or preferences, the values of which get used in the recipes.

In my (Windows) recipe, I installed a Chocolatey package and set some very specific values in the registry. For this application (PDQ Deploy) that was all I needed to do.

Here's that cookbook over on GitHub.

Next, I challenged myself to locate a use case that the community at large might use as a dependency in other cookbooks to accomplish one step in a larger recipe.

This kind of cookbook exports a Chef custom resource. In this case, I built a resource that can perform an installation and configuration action for DelProf2.

And here's the results of that effort!

Hopefully this helps someone start down the path of learning Chef to benefit themselves and their organization's infrastructure.

And if you're already using Chef, perhaps I'll see you at ChefConf this year in Seattle!