<commit_before># ---
# layout: post
# title: Chef Application Cookbooks
# ---

This is a follow up to the blog post [Creating A Chef Cookbook](http://ngerakines.me/2014/05/02/createing-a-chef-cookbook/). Since writing that blog post, I created the [preview](https://github.com/ngerakines/preview) project and several cookbooks for it. With it, I've done a few things differently and believe that they represent some notable trends in the chef community.

## Embed Application Cookbooks in Application Repositories

Instead of having a separate git repository for each cookbook, all of the cookbooks for the preview application are in the [preview](https://github.com/ngerakines/preview) git repository in the 'cookbooks' directory. 

Practically, this doesn't change anything for the cookbook itself. In projects that reference this cookbook that use berkshelf, I have to update the Berksfile to point to the project repository and the subdirectory that contains the cookbook. When a cookbook is uploaded to a chef server, the location is irrelevant.

There is one thing that I do want to make very clear: The application build process doesn't build or prepare the cookbooks. The cookbooks are independently built, tested and released. I've seen projects where the cookbook is "generated" as part of the build process for the application and I feel strongly against that.

## Create Environment Cookbooks

To learn more about the environment cookbook pattern, read the [The Environment Cookbook Pattern](http://blog.vialstudios.com/the-environment-cookbook-pattern/) written by [<NAME>](https://github.com/reset).

In addition to the primary "preview" application cookbook, I created an environment cookbook called "preview_prod". This cookbook is used to represent the default configuration, files and actions needed to release the preview application into a production-like environment.

When looking at environment cookbooks, it is really important to note that these don't contain node information and attributes, but rather represent what a configuration of the application cookbook looks like in a given environment.

In the case of the "preview_prod" cookbook, in the metadata.rb file, I list several attributes that are required by the cookbook:

```ruby
name             'preview_prod'
maintainer       '<NAME>'
maintainer_email '<EMAIL>'
license          'MIT'
description      'Installs/Configures preview_prod'
long_description IO.read(File.join(File.dirname(__FILE__), 'README.md'))
version          '0.2.2'

depends 'preview'<commit_msg>misc fixes<commit_after>---
layout: post
title: Chef Application Cookbooks
---

This is a follow up to the blog post [Creating A Chef Cookbook](http://ngerakines.me/2014/05/02/createing-a-chef-cookbook/). Since writing that blog post, I created the [preview](https://github.com/ngerakines/preview) project and several cookbooks for it. With it, I've done a few things differently and believe that they represent some notable trends in the chef community.

## Embed Application Cookbooks in Application Repositories

Instead of having a separate git repository for each cookbook, all of the cookbooks for the preview application are in the [preview](https://github.com/ngerakines/preview) git repository in the 'cookbooks' directory. 

Practically, this doesn't change anything for the cookbook itself. In projects that reference this cookbook that use berkshelf, I have to update the Berksfile to point to the project repository and the subdirectory that contains the cookbook. When a cookbook is uploaded to a chef server, the location is irrelevant.

There is one thing that I do want to make very clear: The application build process doesn't build or prepare the cookbooks. The cookbooks are independently built, tested and released. I've seen projects where the cookbook is "generated" as part of the build process for the application and I feel strongly against that.

## Create Environment Cookbooks

To learn more about the environment cookbook pattern, read the [The Environment Cookbook Pattern](http://blog.vialstudios.com/the-environment-cookbook-pattern/) written by [<NAME>](https://github.com/reset).

In addition to the primary "preview" application cookbook, I created an environment cookbook called "preview_prod". This cookbook is used to represent the default configuration, files and actions needed to release the preview application into a production-like environment.

When looking at environment cookbooks, it is really important to note that these don't contain node information and attributes, but rather represent what a configuration of the application cookbook looks like in a given environment.

In the case of the "preview_prod" cookbook, in the metadata.rb file, I list several attributes that are required by the cookbook:

```ruby
name             'preview_prod'
maintainer       '<NAME>'
maintainer_email '<EMAIL>'
license          'MIT'
description      'Installs/Configures preview_prod'
long_description IO.read(File.join(File.dirname(__FILE__), 'README.md'))
version          '0.2.2'

depends 'preview'
{'fraction_non_alphanumeric': 0.06364172068355922, 'fraction_numerical': 0.004321351404439206, 'mean_word_length': 4.708520179372197, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 9, 'https://': 6, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '131470', 'n_tokens_mistral': 1264, 'n_tokens_neox': 1213, 'n_words': 648}