Getting started with (vanilla) Chef Solo
A quick start guide for using Chef Solo.
There is lots of material on the Opscode site about how to use Chef in its various forms. The new Chef Quickstart Guide is a good place to start learning. But this page is for people who are impatient, and just want to get on with it. The assumption is that you have a basic understanding of Linux system administration, and that you have sufficient access to run "root" privilege commands using "sudo".
Whenever you do things using Chef (or indeed, any other system administration tool!) there is the potential for causing irretrievable damage to the system you are administering.
- When using "sudo", be careful, and make sure you understand what you are doing before you do it. There is no magic "undo" button!!
- Try things out first on a test machine or virtual. For example, use your NeCTAR trial project to create a "throw away" virtual, or use Vagrant to spin up a virtual on your own desktop.
- Before doing something potentially dangerous on a production virtual (i.e. one that you can't afford to trash), make sure that you have an up-to-date backup to restore from, or a snapshot to revert to.
Getting started with Chef Solo
Here's a quick "cheat sheet" to get yourself started with Chef Solo and a "vanilla" chef-repo that includes copies of all dependent cookbooks.
Note: the procedure below requires a vanilla chef-repo, and won't work with a "Berkshelf". If you are using a Berkshelf, the "getting started" procedure is described in "Getting started with Chef Solo & Berkshelf".
Install the git tools; for example
sudo yum install git
sudo apt-get install git
Install the latest version of the Chef client tools. (This uses the "Omnibus install" approach):
The above will create a chef installation in "/opt/chef", complete with an "embedded" Ruby installation. The Chef tools are then added to a standard "bin" directory so that they appear on your command path.
sudo bash -c "curl -L https://www.opscode.com/chef/install.sh | bash"
Create a directory for doing Chef Solo work.
sudo mkdir /var/chef-solo
sudo chown <your-id> /var/chef-solo
Clone the Git repository for your "chef-repo". (This needs to include all dependent cookbooks in either the "cookbooks" or "site-cookbooks" directory. We don't maintain one in that form anymore.)
git clone <url>
Create a node definition by copying the example file provided:
cp solo/sample-node.json mynode.json
You can edit 'mynode.json' to add override attributes, change the runlist and so on, but the file provided is usable in its current form.
Run the recipes using chef-solo:
sudo chef-solo -c solo/solo.rb -j mynode.json