Creating infrastructure from scratch is fun, but what about community code? Robin introduces the Chef Supermarket and the MySQL cookbook.
- [Instructor] Building cookbooks from scratch is great, especially for learning purposes, however, when you want to work with more complex deployments, you may not know where to start or the best practices surrounding the piece of software you're trying to setup. That's where the chef supermarket comes in. The chef supermarket, you can think of as the GitHub of all things chef. Here we can find community code that allows us to get started on projects and implement some best practices around whatever you're trying to configure. For example, we're going to look for the supermarket's HTTPD cookbook to help us with our web server setup.
In the search bar on supermarket.chef.io you can search for a cookbook that might fit your needs, or give you a nice starting point to work from. HTTPD is what I'm going to type into the search bar and you'll see a number of results pop up. Keep in mind many of these cookbooks have been created and uploaded through time, and similar to GitHub, not all of these will be maintained. The first cookbook HTTPD is relatively well maintained as of the filming of this video.
And you can see it's at version 0.4.5. Opening this up it states that it provides HTTPD service, HTTPD config, and HTTPD module resources. So what does that mean? Your presented with the cookbooks readme. When you open it up and here you can see information about who created this cookbook and who contributes to it. You'll notice that chef itself helps maintain this cookbook through time.
Now a note about the supermarket. Community cookbooks are uploaded and maintained by individuals. And this means that chef as an organization does not vet, verify, or approve the cookbooks that end up on the supermarket. Even though they might contribute to many of the cookbooks, they are not necessarily responsible for how they might function within your infrastructure. This means that community cookbooks like other publicly accessible code may not work for a variety of reasons, however, it's a great launch pad for you and gives you a place to start from when you're building out a new feature or a new piece of your infrastructure.
Back on the readme here, you'll notice scrolling through it, a number of platforms that are supported and then they mention the scope of the cookbook and what it's used for. This cookbook is concerned with the Apache HTTP server. Looking through it further you'll see platform support, and you'll notice that Ubuntu 14.04 will be supported with these particular platforms. Scrolling through the cookbook further, you'll see cookbook dependencies and usage. The usage section is a nice little overview of how to get started with this cookbook, and what you'll notice is that inside of our recipes, we're going to have access to a couple custom resources, HTTPD service and config.
What I want you to be aware of is that these are what we call custom resources. These resources do not ship with the chef client, meaning, in order to have access to them, we must be using this cookbook that creates them. To phrase more simply, you can build your own chef resources, and this cookbook is one that does that. Scrolling further into the readme, they'll give you an overview of how to use each of the resources, what the actions are that are associated with them and eventually a list of the parameters or properties that this resource might accept.
The reason I'm particularly interested in this resource, is that it provides a property called MPM. This allows us to setup an Apache module that will let us deploy our PHP application easily. Now, remember, this code is a launch pad for us, and it gives you some examples to get started. We're going to use this cookbook to build a more complex Apache deployment, but keep in mind troubleshooting cookbooks is something you do continuously, and like we mentioned, your code might break too.
So keep in mind, you're meant to treat a cookbook as a living document. You will be updating these through time, as the conditions change, within your organization.
This intermediate-level course provides insights into the Chef architecture through practical examples and demos, including the deployment of a PHP application on top of a LAMP stack. Instructor Robin Beck walks through recipe development and the various prebuilt cookbooks available from the Chef community Supermarket, and reviews best practices for building wrapper cookbooks that allow you to access recipes from different cookbooks. He also shows how to work more efficiently with knife commands for managing clients, cookbooks, and data.
- Building a setup recipe
- Using cookbooks to organize recipes
- Using community recipes
- Uploading cookbooks
- Using the database cookbook
- Adding PHP to the mix
- Searching with knife
- Testing cookbooks with Kitchen