The course is part of this learning path
Getting Started With Chef
If you were working in IT even ten years ago, then unless you were working for a large company, you probably didn’t need to think about how to manage infrastructure in a scalable way. Back then servers were often on-premises, or in some nearby co-location data center; deployments were infrequent and were kind of like a section of chain, with each link made of a different material, with no consideration of how that link fit into the chain as a whole. At any moment one or more links were bound to break, leaving the deployment is some unforeseen state, that could at best, be described as “broken.”
Luckily for all of us, tools started to evolve out of primordial ooze that was, a random collection of Perl, Python, Ruby, and VBScript, among the other, more esoteric languages. Among those tools was Chef. It not only was among the earliest to evolve, but it has continued to evolve even today.
Chef helps companies around the world manage their infrastructure, in a scalable way. What makes Chef such a useful tool is that it provides a consistent way to interact with nodes, across your entire infrastructure. It also provides a way to test the infrastructure code, which allows you to apply years of software engineering best practices to your infrastructure.
In this course you’ll learn how to use Chef to manage your servers. You’ll learn about how to create your own recipes to configure a server to meet your desired state. You’ll also learn about using community created cookbooks from the Chef Supermarket. By the end of this course you’ll have a solid foundation, to get you started working with Chef.
Getting Started With Chef: What You'll Learn
|Lecture||What you'll learn|
|Intro||What will be covered in this course|
|Overview||What is Chef and who uses it?|
|A High Level Architecture||A 30,000 foot view|
|The Anatomy of a Cookbook||How cookbooks are structured|
|The Recipe DSL||How recipes work|
|Setup||Setting up the workstation|
|Your First Recipe||Creating a recipe|
|Refactoring Your Recipe||Making the recipe cross-platform friendly|
|Deploying a Web Application||Deploying a LAMP based application|
|Setting Up The Chef Server||Preparing a Chef Server|
|Setting Up Nodes||Preparing some nodes to configure|
|Configuring The Nodes||Configuring The Nodes|
|Roles and Data Bags||Managing nodes with roles and accessing global data with data bags|
|Next Steps||How to keep learning|
GitHub - Chef Code
The code used in the course can be found here on GitHub:
If you have thoughts or suggestions for this course, please contact Cloud Academy at firstname.lastname@example.org.
Welcome back! In this lesson, I want to summarize what has been covered throughout the course. Hopefully by this point in the course you have good understanding of the components of Chef, and how to use it to configure nodes.
There’s a lot to Chef as you’ve seen, and I’ve only scratched the surface. Learning something like Chef takes time. And I hope what you’ve learned here has given you enough of a foundation to continue expending on your knowledge.
The learning objectives I listed off at the start of this course were that by the end of the course you’ll be able to:
Understand the use cases for Chef
Explain the Chef architecture
Describe the components of Chef
Create a simple cookbook
Let’s go through each objective to see how it was covered, starting with: Understand the use cases for Chef
At the start of the course I explained that Chef is tool used to automate infrastructure management. I talked about how you can configure servers based on your desired state. And then I talked about some of the companies using Chef, so you could understand how it’s used in the real world.
The next objective was that by the end of the course you’d be able to explain the Chef Architecture. There are a lot of components to Chef, however in the lesson on the Chef Architecture, I covered the three main high level components. Which are the Chef Workstation, where the development kit resides; the Chef Server, which is the central hub containing all of the cookbooks, attributes, node information and more. And then the nodes, which are devices capable of running the chef-client executable.
The following lessons covered the next objective, which is to help you to learn about the different components of Chef. Now this is closely related to the previous objective of understanding the Chef architecture. However, it goes a bit deeper in that you should have an understand of the components that make up the Workstation, the Chef Server and a node.
You may recall that the workstation contains the Chef Developer Kit; it’s where you develop cookbooks, as well as where you manage the Chef Server from, via the command line tools.
I covered tools such as knife, kitchen, berkshelf, as well as the chef generators.
I covered the Chef Server, and explained that it’s basically an API that’s backed by a Postgres database. I talked about how to interact with the Chef Server via the Management Web UI, as well as the knife command. I showed how to get started with a Chef Server using the hosted option from the AWS Marketplace. And then I showed how to get knife configured on the workstation so that it can communicate with the Chef Server.
After that I showed how to use knife to bootstrap the chef-client on the node, which gets the software installed, and then registers the node with the Chef Server. Then I showed how to use the knife SSH command to issue commands against a node, including the chef-client command.
The final objective was that you’d be able to create a basic cookbook. To help towards the goal I walked through creating a simple cookbook with you, and then refactored it to be more cross-distribution friendly.
After that I showed how you can use community cookbooks to save development time. I showed how to Berkshelf to manage cookbook dependencies and upload the cookbooks to the Chef Server. And then I covered roles and data bags to make sure you could get the most of out your cookbooks.
There was a lot of information throughout the course, and still a lot more to cover. Chef is an extremely power tool, and learning how to use it well takes time and effort. So how do you keep learning more?
First, I recommend reading the official documentation. It’s full of useful info, and hopefully now that you have a basic understanding of how Chef works reading the docs will make more sense to you.
My second recommendation is to read the source code for some of the more popular cookbooks on the Chef Supermarket. These are maintained by the community, and many of the contributors have been working with Chef for years. If you see something in the code that you don’t understand, fire up your favorite search engine and look it up!
My final recommendation is to setup the developer kit and test things out at least locally. Hands on learning with tools such as Chef is always a great learning experience. To help with the hands on here’s something you could do.
Do you remember when I started testing the cookbook on both Ubuntu 14.04 and CentOS, earlier in the course? I configured the .kitchen.yml file to allow Kitchen to launch both of those images inside a VM so that when it came time to run this on the nodes in my AWS production environment I could be sure everything would work.
Well, remember that Ubuntu 16.04 instance I started up on AWS? You probably thought I had forgotten about it. Here’s what happens when I run the learn_chef_cookbook against Ubuntu 16.04.
It makes it all the way to the part where it tries to install the MySQL client and it fails. It throws the error ‘Unsupported MySQL client version.”
I want to leave you with an objective of your own. Get this working on Ubuntu 16.04, 14.04 and Centos 7.3. Here’s a hint to get you started should you be interested: add a new platform to the .kitchen.yml file for 16.04 so you can start testing. The process of troubleshooting problems like this tend to teach you a lot of about how things work. So if you try it out for yourself, good luck!
I hope this course was helpful in teaching you the enough about Chef to get you started working with it on your own. Either way, I hope you’ll reach out and let me know what you thought. Feedback, both positive and negative helps us instructors to create better content.
So, thanks for watching! Good luck with your continued learning, and I hope to hear from you on the Cloud Academy community forums!
See you in a future course!
Ben Lambert is a software engineer and was previously the lead author for DevOps and Microsoft Azure training content at Cloud Academy. His courses and learning paths covered Cloud Ecosystem technologies such as DC/OS, configuration management tools, and containers. As a software engineer, Ben’s experience includes building highly available web and mobile apps. When he’s not building software, he’s hiking, camping, or creating video games.