facebook / grocery-delivery

The Grocery Delivery utility for managing cookbook uploads to distributed Chef backends.
Apache License 2.0
154 stars 55 forks source link

Grocery Delivery

Continuous Integration

Intro

Ohai!

Welcome to Grocery Delivery, software to keep cookbooks, roles, and databags in sync between a VCS repo and a chef server. The idea is that if you have multiple, distinct Chef server instances that should all be identical, they can all run this script in cron. The script uses proper locking, so you should be able to run it every minute.

However, there are several things to know:

Grocery Delivery is pretty customizable. Many things can be tuned from a simple config file, and it's pluggable so you can extend it as well.

Prerequisites

Grocery Delivery is a particular way of managing your Chef infrastructure, and it assumes you follow that model consistently. Here are the basic principals:

We recommend enabling attributes whitelisting to prevent node attributes being saved back to the server. In recent versions of Chef (past Chef 11), this feature is built-in. For older versions, we recommend using the whitelist_node_attrs cookbook.

Dependencies

Config file

The default config file is /etc/gd-config.rb but you may use -c to specify another. The config file works the same as client.rb does for Chef - there are a series of keywords that take an argument and anything else is just standard Ruby.

The following configuration options are available:

Plugin

The plugin should be a ruby file which defines several class methods. It is class_eval()d into a Hooks class.

The following functions can optionally be defined:

This code will run once we've read our config and loaded our plugins but before anything else. We don't even have a lock yet. Dryrun is a bool which indicates if we are in dryrun mode.

This is run after we've gotten a lock, written a pidfile and initialized our repo object (but not touched the repo yet)

This is code to run after we've updated the repo, but before we've done any work to parse it.

After we've parsed the updates to the repo and uploaded/deleted the relevant items from the local server. Success is a bool for whether we succeeded, and msg is the status message - either the revision we sync'd or an error.

Same as postrun, but is registered as an atexit function so it happens even if we crash.

License

See the LICENSE file in this repo.