Returning Customers — Login
Call 1.866.720.0208 or contact us
Table of Contents
Although you can use many Chef-based ServerTemplates as-is without any changes, you may need to clone and customize a ServerTemplate at some point in your development cycle. The process of cloning and modifying a ServerTemplate that uses Chef cookbooks and recipes is slightly different than customizing a ServerTemplate that only uses RightScripts. A Chef-based ServerTemplate uses scripts that are defined by a repository or set of repositories. The list of the repositories is defined by a ServerTemplate's RepoPath object. Since a ServerTemplate is typically published with a committed revision of a RepoPath object where each repository is locked down to a specific branch, tag, or commit SHA, you must clone and modify both the ServerTemplate and its RepoPath object to make any type of customization.
Most Chef-based ServerTemplates use a RepoPath that references multiple cookbook repositories. In the example diagram below, the ServerTemplate can only use resources that are available within the cookbooks of the two referenced repositories.

However, if you want to modify the ServerTemplate so that you can modify the cookbooks of those listed repositories or use Chef recipes that are located in another repository, you will need to perform one of the customizations highlighted below.
There are a few different ways to customize a Chef-based ServerTemplate. The appropriate customization method is determined by the type of modification. This document explains the different types of customizations and the recommended best practice for performing each type of change. If you do not follow these recommended guidelines you may have a difficult time upgrading your custom ServerTemplate to incorporate new features and improvements as newer revisions of the original ServerTemplate and/or cookbook repositories become available.
If you are not familiar with the cookbook repository hierarchy rules, see Inheritance of Cookbook Repositories.
The first step is to determine the type of change or enhancement.
Perform minor bug fixes or enhancements that you can contribute back to the original cookbook repository via a Pull Request
Note: In order to submit code submissions, you must complete a RightScale Contributors Agreement found here.
If you are creating new cookbooks that contain new Chef resources such as LWRPs, cookbooks, recipes, etc. that are currently not available in the other repositories, you should create a new repository from scratch.


If you only want to override a few files such as default settings of a Chef resource or modify a configuration file, it's recommended that you create a new repository where its contents only override the select file(s) that you want to modify. In the example diagram below, the contents within the C and D cookbooks of the repository of overrides (e.g. git://github.com/username/overrides.git) will take precendence over the contents of the C and D cookbooks located in the other repositories.
Important! The C and D cookbooks in the repository of overrides should only contain the files that will be overwritten in the other repositories. Paths must be respected, so a file must exist in the same directory as the file its going to override. Any unmodified files in the C and D cookbooks will still be retrieved from the original repositories.

In the example above, perhaps you want to modify the MySQL tuning parameters. By default, RightScale defines the MySQL tuning parameters in the 'my.cnf.erb' file by using values that are calculated based on an algorithm in the 'mysql_tuning.rb' file.
However, after testing your applications, you may want to hardcode certain MySQL tuning parameters instead of using RightScale's algorithm or maybe add additional MySQL tuning parameters that are not included by default. In such cases, you may want to override RightScale's 'my.cnf.erb' file with your own file that has optimized tuning parameters for your application.
In the example above, the modified version of the 'my.cnf.erb' file in your repository of overrides will be used instead of the file with the same name in RightScale's repository. It's important to always maintain the same file path location to ensure that you are going to override the correct file. The metadata files are also required to be present so that the cookbook's contents are properly retrieved from Repose and its contents will be listed in the RightScale Dashboard. Although the README.rdoc is technically not required, it is typically referenced in the header of the metadata, so if it's missing you will get an error. The metadata in the overrides cookbook only needs to contain information about any new inputs, recipes, etc. In the simple example above where no input is being introduced, the metadata would only need to include a basic header.
Example (metadata.rb)
It's strongly recommended that you edit the header to include relevant information about yourself or your company as well as a comment about what files are being overwritten.
maintainer "YOUR_COMPANY_NAME" maintainer_email "YOUR_EMAIL" license "All rights reserved" description "Installs/Configures splunk" long_description IO.read(File.join(File.dirname(__FILE__), 'README.md')) version "0.0.1" # Includes a cookbook override for the 'templates/default/my.cnf.erb' file
Example (directory structure)
In the example above, the overrides repository would have the following directory structure.
/cookbooks/db_mysql/templates/default/my.cnf.erb
/cookbooks/db_mysql/metadata.rb
/cookbooks/db_mysql/metadata.json
/cookbooks/db_mysql/README.md

You can either create your own "overrides" cookbook from scratch or use RightScale's 'cookbooks_override' repository if you want to override some of the common configuration files used in many or RightScale's published LTS and Infinity ServerTemplates.
If you are using ServerTemplates from an LTS or Infinity branch release from RightScale, it's recommended that you use RightScale's specific "override" repository. Instead of creating your own overrides repository from scratch, you can simply fork the following repository, which already contains cookbooks that contain the common configuration files that most users want to override.


You can either use your Chef development environment to push your changes to GitHub or you can modify the file directly as long as you're only changing hard-coded values and not creating new inputs, which would required updated metadata files. If you are only going to change the values of a few parameters, it will be easier to simply make the changes directly in GitHub.

If you need to make a change to an existing cookbook repository such as a minor bug fix or enhancement that you may want to contribute back to the owner of the original repository via a Pull Request, add the changes to a fork of the repository, which will make it easier for the owner of the original repository to merge the submitted changes into the master branch. See Make a Pull Request on GitHub.

