Created
June 4, 2013 15:37
-
-
Save jsierles/5706903 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Currently this repo only supports using *chef-solo* which doesn't access any remote components. Later you can migrate this setup to use *chef-client* with a *Chef Server* as needed. | |
A *run list* is a json file defining which recipes get run on a server. | |
# File layout | |
*Berksfile* is like a Gemfile for Chef cookbooks. See *bin/berks* for more info. | |
*config* contains Ruby config files for command line clients like chef-solo. | |
*cookbooks* is where our *upstream* community cookbooks live. This is created by the *Berkshelf* command. | |
*data_bags* contains directories, Data Bags, which contain json files. Each file represents an item like an SSL certificate or a user. They're usually loaded into a Chef Server, but we can access them from the filesystem using chef-solo. | |
*nodes* contains the json run lists for specific servers. | |
*roles* contains json files defining what to run on servers assigned to specific roles. | |
# Setup | |
First, install [Virtualbox](https://www.virtualbox.org/). | |
Then we need all the development gems. | |
``` | |
bundle install --binstubs | |
``` | |
Boot up the Ubuntu Precise virtual machine. | |
``` | |
bin/vagrant up | |
``` | |
We now have a VM running with the current directory mounted at */chef*, and an IP of *33.33.33.10*. | |
*Knife* is chef's command line tool. We'll use a plugin that bootstraps a server for Chef. It installs a full Ruby runtime in */opt/chef*. | |
``` | |
bin/knife solo prepare [email protected] -i ~/.vagrant.d/insecure_private_key | |
``` | |
Now the VM should be prepped for Chef. | |
Next, let's get our upstream cookbooks in place. The *path* argument is for vendoring cookbooks, but also works here to let us examine the cookbooks. | |
Note that any changes made to cookbooks here will be _overwritten_ by the next *berks install*. To modify upstream cookbooks, clone them and point to them in your Berksfile. | |
``` | |
berks install --path cookbooks | |
``` | |
*Chef-solo* is the server-side command that configures the server based on a Chef *run list*. | |
``` | |
cat nodes/development.json | |
``` | |
Here we have a basic run list telling chef to load our *app* cookbook. Let's login to the VM and do the first Chef run. | |
``` | |
vagrant ssh | |
``` | |
On the VM we'll do a chef run. | |
``` | |
sudo chef-solo -c /chef/config/solo_dev.rb -j /chef/nodes/development.json | |
``` | |
This runs the default recipe in the app cookbook, see *site-cookbooks/app/recipes/default.rb*. | |
# Bootstrapping an EC2 instance | |
Your AMIs will execute the contents of the user metadata if its a shell script. | |
See *bootstrap.sh* for details. | |
TODO: Describe userdata boot process in more detail |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment