Note: Please go to docs.rightscale.com to access the current RightScale documentation set. Also, feel free to Chat with us!
Home > Guides > Chef Cookbooks Developer Guide > Developer > Cookbook Development Resources > Chef Cookbook Design Patterns > Abstract Cookbook Pattern

Abstract Cookbook Pattern


Overview

What is the Abstract Cookbook Pattern?

RightScale also uses an abstract design pattern across its repository of cookbooks. Although related Chef Lightweight Resources and Providers (LWRP) are typically located in the same cookbook, Chef supports the ability to use resources defined in other cookbooks.

The Abstract Cookbook Pattern consists of two different types of cookbooks. 

  • Abstract Cookbook - Contains a resource that defines a set of general actions such as initializing, backing up, and restoring a database, as well as a set of recipes that use these actions. (e.g. db) The default.rb recipe in abstract cookbooks sets up the provider and all provider-specific inputs and installs the client. The install_server.rb recipe sets all generic server inputs, includes the default.rb recipe and installs the server.
  • Concrete Cookbook - Contains Chef providers that perform the actions for a specific variety of abstract cookbooks. (e.g. db_mysql, db_postgres) and a setup_server.rb recipe that sets up server inputs and hard codes the provider name and version of the server.

To group abstract cookbooks with their concrete cookbooks, each concrete cookbook is prefixed with the name of the abstract cookbook. this repeats throughout our collection with groupings such as "app", "db", "lb", "logging", "repo", etc.

 

Important! The Abstract Cookbook Pattern is used in ServerTemplatesRightScale's v12 and v13 ServerTemplate releases. See ServerTemplates.

How does RightScale use the Abstract Cookbook Pattern?

Example

RightScale's own Git repository contains several examples of this pattern. (https://github.com/rightscale/rights...ster/cookbooks)

screen_Concrete-Abstract_v1.png

 

In the example screenshot above, there is a generic cookbook ('db') that contains several recipes that perform the same generic actions on the different types of supported databases (MySQL and PostgreSQL). For example, here are a few of the 'db' cookbook's recipes.

 

In the future, when support is added for a new type of database (e.g. Oracle), the same set of 'db' recipes will be executable on the database server as long as the related abstract cookbook (e.g. db_oracle) is available. The Abstract Cookbook Pattern provides a scalable framework for integrating support for new software and functionality without having to duplicate a large portion of code.

You must to post a comment.
Last modified
14:57, 23 Sep 2013

Tags

This page has no custom tags.

Classifications

This page has no classifications.

Announcements

None


© 2006-2014 RightScale, Inc. All rights reserved.
RightScale is a registered trademark of RightScale, Inc. All other products and services may be trademarks or servicemarks of their respective owners.