Creating Chef Cookbooks
To Manage Cloud Infrastructure

Tammy Butow
Girl Geek Academy
Published in
3 min readJun 28, 2015

--

I’ve always loved building web applications, and then I completely fell in love with infrastructure. Chef turns infrastructure into code. So that’s awesome ❤ With Chef, you can automate how you build, deploy, and manage infrastructure.

Configure a Chef Server

The first thing you will need to create for your Chef Configuration Management System is a Chef Server. You can read how to do that over here: [Chef Server Tutorial].

When you have finished that tutorial you will have something similar to:

Yay a Chef Server ❤

Configure a Chef Workstation

Next you will need to create a Chef Workstation. Infrastructure configuration is done on the Chef workstation, which then uploads the data to the Chef Server. You can read how to do that over here: [Chef Workstation Tutorial].

Yay a Chef Workstation ❤

Bootstrapping a New Node with Knife

We can now use Chef to configure new servers within our infrastructure. We do this by installing a Chef client executable and the organizational validator key on the new node. The new node then contacts the Chef server and will be setup for future configuration management. Read about how to bootstrap a node over here [Bootstrapping a client node]

Yay a bootstrapped Chef node ❤

Look at all the things you created:

Adding nodes with cloud-config

You can easily add additional nodes to your Chef managed cloud infrastructure environment by using Cloud-Config, you can read more about that here: [Automatically Adding Nodes With Chef And Cloud-Config]

Creating your first Cookbook

Next we are going to create a Chef Cookbook on our Chef Workstation. Our end result will be a node which displays an image of a cake below using Nginx as the web server.

Yay! A Chef Workstation, Chef Server and Bootstrapped Node ❤

We will create the cookbook following this guide over here: [Create simple Chef Cookbooks]. Let’s take a look at our first Chef Recipe.

A Chef Recipe that installs Nginx and creates an index.html page

Manage a node with a Chef Cookbook

Next you will want your fresh node that created earlier to be managed by your new Cookbook. That’s not going to take long at all, just type:

sudo chef-client

Yay our node is ready ❤

Check out what you created

Voila ❤

Further Reading

I found the Chef documentation to be super helpful! Totally check that out.

Visit girlgeekacademy.com ❤

--

--