Chapter 2. Just Enough Ruby to Customize Chef

Tip

If you’re already familiar with object-oriented programming with Ruby, including inheritance, namespaces, exceptions, and the Ruby scoping model, then you may wish to skip this chapter.

As you’ll most likely already have realized while writing cookbooks and recipes, the amount of actual Ruby knowledge needed to write Chef recipes is relatively light. The out-of-the-box resources provided with Chef do an excellent job of abstracting away many of the common tasks required, and a smattering of Ruby basics such as assigning values to variables and writing if statements fill in the gaps. But there’s a lot more going on under the hood to provide those Chef resources, Knife plugins, and libraries, and before we can customize them, it is necessary to understand them.

This chapter will teach you some fundamental Ruby concepts that are essential knowledge for customizing Chef. I’ve tried to make the material in this chapter as accessible as possible to those new to Ruby, but as I only have a limited space in which to present some sizable concepts, don’t worry if it feels like a little too much to take in all at once.

Needless to say, this chapter will not cover everything there is to know about the Ruby programming language, and throughout the course of the book I’ll be introducing some additional Ruby concepts and expanding on those covered here—the aim of this chapter is simply to give you a good foundation to build on as we ...

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.