Chapter 7. Definitions and Libraries
Possibly the most customizable aspect of Chef is the recipe code we run on our nodes, and the resources that comprise them. Because our recipes form the backbone of our infrastructure code, here more than ever itâs important that Chef provides us with the flexibility and power to write infrastructure code to fit our requirements. Part of this flexibility involves making sure that cookbook authors who want to create a simple cookbook resource are able to do so without having to become an expert in Chefâs internal classes, while making sure that more experienced users are able to do just that should they wish.
In this chapter, weâre going to revisit the underlying structure of cookbooks in Chef before looking at two of the simpler customization types, definitions and libraries. Donât make the mistake of assuming that simple means that these customization types arenât powerful, howeverâit just means that their fundamentals are quite straightforward to explain. As with many aspects of customizing Chef, the real power comes from what you use that fundamental knowledge to implement.
In this chapter, weâre going to learn:
- How cookbooks in Chef are structured and where each component part sits in this structure
- How to prepare a test environment to safely run our recipe customizations
- What definitions are and how to create and use them
- What libraries are and how to create and use them
As always, weâll work through a number of code examples ...
Get Customizing Chef now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.