Food Fight

The Podcast where DevOps chefs do battle


Show Date: Wednesday, March 13, 2013

In this episode, we sat down with Miah Johnson, Ranjib Dey, Doug Ireton, Chris McClimans, Joshua Timberman, and Seth Vargo to discuss Libraries, Definitions and LWRPs.

Watch Now



Doug’s articles on writing LWRPs


A lightweight resource is a custom resource that creates an abstract approach for defining a set of actions and (for each action) a set of attributes and validation parameters. A lightweight resource relies on a lightweight provider to take the necessary steps to bring a piece of the system to a desired state.

A lightweight provider is a custom provider that is designed to take the steps that are required to bring a piece of the system into a specific state based on an action that is defined by a lightweight resource.

About Lightweight Resources…


A library allows arbitrary Ruby code to be included in a cookbook, either as a way to extend the Chef language or to implement a new class directly. A library is defined in /libraries/library_name.rb for each cookbook. A library that is included in a cookbook is automatically required and will be available to all recipes, attributes, file definitions, providers, and definitions. A library is defined in the library_name.rb, which is found in the libraries folder for each cookbook. The contents of a library will determine the potential uses of that library in a cookbook.

About Libraries…

Simple example for having a module in a Chef recipe


A definition is used to create a resource by stringing together one (or more) existing resources. A definition is not a resource and it does not take any actions by itself. A definition is replaced by one (or more) resources, and it then takes actions on behalf of those resources. There is no limit to the number of resources that can be part of a definition. All definitions within a cookbook must be located in the definitions/ folder. A definition is never declared into a cookbook. A definition is best-used when:

  • Data needs to be passed from one (or more) recipes into a single definition
  • A repeating usage pattern exists for one (or more) resources
  • An action does not need to be sent directly to a resource (when it does, it should be sent to a provider)

About Definitions…