Skip to content

Instantly share code, notes, and snippets.

@ktheory
Created December 14, 2012 19:14
Show Gist options
  • Save ktheory/4287857 to your computer and use it in GitHub Desktop.
Save ktheory/4287857 to your computer and use it in GitHub Desktop.
Chef workflow

Cookbook workflow

Prereqs:

Install chef gem (for knife command):

gem install chef

Create a new cookbook:

knife cookbook create my_cookbook

This generates a skeleton cookbook locally.

Edit a cookbook

After you make a change to a cookbook, be sure to bump the version number in cookbooks/my_cookbook/metadata.rb. That way you can test your changes on ad-hoc environments before staging & production.

When you're ready to run your cookbook on ad-hoc environments, run:

knife cookbook upload my_cookbook

This makes the chef server aware of your changes.

Upgrading staging & production

When you're comfortable with your changes, commit & push them to git.

Upload the cookbook one more time with the --freeze option to prevent others from overwriting it:

knife cookbook upload my_cookbook --freeze

Edit environments/staging.rb to use your new cookbook version.

Upload the environment to the chef server:

knife environment from file staging.rb

Once you've checked that the new cookbook works well on staging, upgrade environments/production.rb similarly.

In git, commit & push your changes to the environments files.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment