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.
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.
RightScale's own Git repository contains several examples of this pattern. (https://github.com/rightscale/rights...ster/cookbooks)
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.
© 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.