short thoughts‎ > ‎

Basic client/server Chef setup with Mac OSX, Windows and Opscode Platform

posted May 29, 2011, 8:08 AM by Steve Craig   [ updated Aug 7, 2012, 6:05 PM ]
This posting is a natural follow-on from "Why Chef configuration management? Why not puppet?" at  I'd suggest you start there.  And, once you finish this basic setup, you should be ready to move on to the next guide in the series, which will show you how to go from zero to N+1 chef-managed linux Amazon EC2 instances in less than 60 minutes

Before you can jump right in and start cooking with Chef for configuration management, you have to setup your local environment.  Personally, I use Mac OSX (10.5, i386 to be precise) running vmware Fusion and a Windows 2003 Server virtual machine as my primary desktop{s}, and have found this setup to be excellent for cooking with Chef!  So, after you have made the decision to use Chef (see for how I made the decision to go with Chef for configuration management), lets hits the basic steps to setup your development "kitchen".

We will largely follow the Opscode web quickstart!  There's no need to re-invent the wheel, people.  The web quickstart was created for a reason, and that reason is to get you up and running as quickly as possible while still hitting the topic highlights you will be investigating in greater detail later.

The Opscode quickstart works well; however, I have made a few clarifications and modifications.  If you'd like: follow the slightly modified steps here!  I'll provide meta-data for the main points on the quickstart guide here:

- Opscode Platform
The most powerful and flexible chef setup is client/server, and as such, requires chef-client as well as chef-server.  For those who want to get started cooking quickly with this powerful and flexible approach to configuration management and would rather not spend time setting up yet another server, grab a free chef-server account from (the creators of Chef, natch) on their "Opscode Platform".  As if having someone maintain uptime for your chef-server wasn't good enough, the people at will give you a five-node chef-server for free!  Trust me, this is good enough to get started and decide if Chef is the configuration management tool for you.  This is a no-brainer; seriously.  Register for a free five node account here.  Now you can focus on setting up your chef-client configuration, rather than worrying about if chef-server is working correctly.

- Operating System
Because I am in the rather interesting situation of being a predominantly-Linux person who was wrangled into supporting a pure-Windows production environment for #smashrun , I've got a Mac OSX desktop running vmware Fusion with a Windows 2003 server virtual machine.  I'm also on the Opscode Platform.  For the purposes of this Quickstart guide, that all means for my basic install, I've got the opscode platform as my chef-server, I've got the local copy of my chef repository on my Mac, and I'll be installing chef-client primarily onto the Windows 2003 virtual machine.

- Development Tools
This is straightforward, right?  I need Xcode on my Mac as a necessary pre-requisite because of Chef's huge dependency on Ruby and Rubygems.  After Xcode, I need git (we'll be using this modern, open-source version control tool for our chef cookbooks) Ruby and Rubygems, and finally the chef gem.

Therefore, our modified order of operations (the opscode wiki quickstart has more detail if you need it) for "Assumptions: Necessary software" is:
1. instead of setting up chef-server, setup an opscode platform account here:
2. if running Mac OSX as your base development workstation OS, install Xcode:
3. install git for version control:
4. Install Ruby (already installed on most OS, use your OS package management to check)
5. Install Rubygems 1.3.7+ (already installed on most OS)
6. Install Chef

- Customizing the User Environment
Once the base software is installed from "Development Tools," it is time to hook it all together and put it to use!  Numerous items will need customization: your Opscode Platform account, your local Chef Repository, your .chef configuration directory for "knife" and finally your first chef-client cookbook!

Our modified order of operations for "Customizing the User Environment" is:
1. Customize your Opscode Platform account:
  - create your "organization" (this string is important, one word / no spaces is easiest)
  - download the organization validation key (WARNING this is a PRIVATE KEY and permits chef-client nodes to be managed via the chef-server: with it, 3rd parties could directly register a 3rd party chef-client node under your organization and then retrieve all meta-data associated with your chef installation, which is quite extensive)
  - download your organization user key (WARNING this is a PRIVATE KEY and authenticates you to the chef-server: with it, 3rd parties could masquerade as you and issue knife commands to the chef-server with your level of access)
  - download your knife configuration file (substitute YOURORGANIZATIONNAME)
2. Create a local Chef Repository (all changes are made locally, committed to version control and then uploaded to the chef-server)
3. Create a .chef directory inside your userhome directory and copy the keys and configuration from step one into it
4. Verify you are able to connect to the Opscode Platform (chef-server)!

- Setup chef-client
If you were able to connect to the Opscode Platform (chef-server) once your local User Environment was customized, it is now time to setup a new node as a chef-client!  Chef comes with some very easy methods to "bootstrap" (semi-automatic install of most required software and settings for Chef configuration management) chef-client onto *NIX nodes, and I will not go into them now.  Remember: I have the need to manage Windows chef-client nodes, and that is where I'll focus for this section.  Also, Chef v >= 0.10 comes with improved ability to bootstrap windows chef-clients.  I'll going to skip that for now as well.  Consider this next section my meta-data on the Opscode wiki section for "Chef Client Installation on Windows".

1. Install pre-requisites: ruby 1.8.7
2. Install pre-requisites: RubyDev kit
3. Install pre-requisites: extra Rubygems for Windows (win32-open3 ruby-wmi rdp-ruby-wmi win32-process win32-service windows-api windows-pr ffi )
4. Install gems: Chef and ohai
5. Configure the new node's chef "client.rb"
6. Copy your organization's validation.pem private key to the proper location on the node
7. Run Chef client!
8. Your new node should show up on the Opscode control panel "Node List":

At this point, you've got your organization up on the Opscode Platform (your chef-server), you've got your first node associated with your organization running the chef-client and successfully checking in with with the chef-server, and your local development environment is ready to accept chef "cookbook" files full of "recipe" (specifications of resources to manage) and "attribute" (values used throughout your configuration management system) declarations.

You now need to write your own cookbooks, grab some from github, or leverage cookbooks from Opscode.  I started with Doug MacEachern's windows cookbooks.  In the next post I'll show how I evolved some of Doug's basic Windows recipes into something a little more specific for my project, and hopefully post my github information so that you can see my cookbooks.