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
Panel
- Miah Johnson github, twitter
- Ranjib Dey github, twitter, blog
- Doug Ireton github, twitter, irc: dougireton, blog
- Brandon Burton github, twitter
- Chris McClimans github, twitter
- Joshua Timberman github, twitter, blog
- Seth Vargo github, twitter
- Nathen Harvey github, twitter, irc: nathenharvey, blog
Outline
Doug’s articles on writing LWRPs
- Creating an LWRP, Part 1: The Resource
- Creating an LWRP, Part 2: The Provider
- Creating an LWRP, Part 3
LWRP
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.
Libraries
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.
Simple example for having a module in a Chef recipe
Definitions
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)
Picks
Miah
Ranjib
Doug
Chris
- Ingredients
- Sky Hag IPA - The Beer is as bitter as she is
Seth
Joshua
- Ruby Rogues 87 - Practical Object-Oriented Design in Ruby with Sandi Metz
- #ChefConf
- Roll 20
- Rumble IPA by Great Divide