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 > End User > RightScale Support of Chef > Where are cookbooks stored?

Where are cookbooks stored?

Objective

To understand where Chef cookbooks are stored.

Note: This document describes functionality that is supported by RightImages v5.7 and newer.

Table of Contents

Overview

Chef cookbooks are stored in several locations. It's important to understand the relationship between each one, as well as where the cookbooks are actually stored in each location.

  • Source Control Management (e.g. GitHub)
  • Repose
  • Chef Development Machine 
  • Client Server 

 

Relationship Diagram

diag-CookbookLocations-v2.png

Chef Development Machine

If you are developing your own Chef cookbooks or modifying existing ones, you will need to have a machine that you will use for Chef development purposes. Typically, you will either configure your own laptop or use a server in the cloud. When you create and modify Chef cookbooks on your development machine you will regularly push changes up to your repositories that are hosted on your source control management system (e.g. GitHub).

Source Control Management

The most commonly used source control management system for hosting Chef cookbook repositories is GitHub. (http://github.com)  RightScale uses GitHub to store all of its own cookbook repositories. However, you can use other source control management systems (e.g. SVN) to host your Chef cookbooks.

Repose

Repose is RightScale's own repository caching service for hosting Chef cookbooks and other assets that are used by ServerTemplates to launch and configure servers in the RightScale management platform. See Repose.

Client Server

When you launch a server using ServerTemplates, the cookbooks that are required by the scripts of a Chef run list will be retrieved from Repose and saved locally to the instance. Only the cookbooks (and any cookbook dependencies) that are required to execute a Chef run list will be copied to the server instance. When you launch a server, only the cookbooks that are required to run the boot script list (as defined by the ServerTemplate) will be copied to the instance. Cookbooks that are required by operational or decommission scripts will only be copied to the instance if and when they are needed to execute a queued run list. For subsequent Chef runs on an instance, any existing cookbooks may be overwritten, but will never be deleted.

To view where they are stored, you can SSH into an instance and navigate to the following locations:

  • /var/cache/rightscale/
    • /chef
      • /checksums
    • /cookbooks
      • /default
        • /05fe0e9401da912fdb518fe37b3a8c5393e3883d
          • /<cookbook-name>
            • MANIFEST
            • /definitions
              • <definition>.rb
            • /files
              • default
              • centos
              • ubuntu
              • redhat
              • packages
            • metadata.json
            • metadata.rb
            • /recipes
              • default.rb
              • <recipe-name>.rb     (e.g. do_action.rb)
            • /templates
              • default.rb
        • /518a303fa5da2edff695ecfaa081c1684a8d3d70
    • /right_scripts
      • /default
        • /right_scripts_cookbook
          • /recipes
            • <rightscript-name>.rb
            • <rightscript-name> 
/var/cache/rightscale/chef

The 'chef' directory contains content required to execute a Chef run on the instance. 

/var/cache/rightscale/cookbooks/default

In this directory you will find a list of all the cookbooks that were required to run the most recently executed Chef run list. The run list could consist of a single recipe (e.g. Operational Script) or a runlist that consists of multiple recipes (e.g. Boot/Decommission Sequence). For example, if you look at this directory after launching a server (who's ServerTemplate contained Chef recipes in its Boot Sequence) for the first time, you will see a SHA for each cookbook that was used in the boot sequence. In the example below, 8 different cookbooks were used. Notice how each cookbook is located in a directory based upon the SHA it's assigned in Repose. The selection of cookbooks that are retrieved from Repose and downloaded to this directory on the instance is based upon the cookbooks attached to the ServerTemplate. 

# cd /var/cache/rightscale/cookbooks/default
# ls
0f00a4137d32727689073eb6c6d9ef2d  6107f8979a4a6d6e3a207d3bea25a3c8
285e6c48a8d5cbea487c44a17c40885e  b127fc13b6e1e1bdd142c70360e2cc82
3c2e825a89052cb719ebb346dd6d3ab7  b6c7b4d885241287542bc8639cdf740f
4fb6f36944e2aa2236ae9ba924a024f2  f5ed36fd7a463f2261029d84232dd5cf

# ls 0f00a4137d32727689073eb6c6d9ef2d
iptables

 

The contents of this directory will be updated each time a single script or series of scripts (e.g. boot/decommission sequence) is executed on the server. Note: If you run a RightScript (not a Chef recipe) as an Operational Script, the contents of the above directory will be deleted.

Remember, a recipe can depend on variables set by recipes in other cookbooks. Therefore, in order for a recipe to run successfully on an instance, any cookbook dependencies will also be retrieved and copied to the instance's local disk. For example, if you run 'app::setup_app' and it references a recipe ('db::setup_db') from another cookbook, both the 'app' and 'db' cookbooks are copied in their entirety to the instance. In such cases, a cookbook's metadata must clearly declare any cookbook dependencies.

Note: Cookbook dependencies are defined in a cookbook's metadata. See Chef Metadata for details.

/var/cache/rightscale/right_scripts

There may be scenarios where a ServerTemplate contains both RightScripts and Chef recipes. In such cases, each RightScript will ultimately be run as a Chef recipe as part of a Chef run list. For RightScripts that are listed in the boot or decommission scripts list inbetween Chef recipes, they will be executed in the correct, sequential order as they are listed under the ServerTemplate's Scripts tab. RightScripts are converted into Chef recipes and saved to the instance's local disk in this directory. Two files will be created for each RightScript.

  • <rightscript-name> - the source file which contains the actual RightScript code. (e.g. bash)
  • <rightscript-name>.rb - the ruby file that is executed as part of a Chef run list.
You must to post a comment.
Last modified
16:10, 25 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.