Monday Morning System Administrator
Not long ago I purchased a virtual private server from Linode. At the time, the most recent Ubuntu release was Maverick Meerkat (10.10). The first Sunday after purchasing, I sat down for a few hours and configured every aspect of the machine manually — it was going to be my personal web and application server. Feeling like I had accomplished something, I logged out and nodded in approval.
Fast-forward five months and Ubuntu’s most recent release is Natty Narwhal (11.04). Naturally, I wanted to upgrade, but a clean install would require another couple of hours on a Sunday afternoon. If I was going to invest time in configuring the server again, how could I configure it in a way that would apply for the next release? The answer I settled on was Chef.
Chef
Chef is an open source framework that allows you to build infrastructure from code. Explained another way, Chef allows you to checkout code from a repository and execute it against a base operating system install — producing a fully operational web server, database server, etc. No replaying steps off of a build document. No complex combinations of Perl and Bash scripts. No more manual configuration.
Chef comes in two flavors: server and solo. With Chef Server, a client (your laptop) sends configuration directives to a central server and that server propagates those directives to target nodes. The server can exist within your data center, or you can leverage Opscode’s Platform (Chef Server as a service). The alternative is Chef Solo. Chef Solo operates without Chef Server by sending directives directly to target nodes.
In the end I chose Chef Solo, but don’t let that impact your evaluation of Chef Server. Opscode makes it easy to test drive their platform by giving you up to five free target nodes.
Forward Progress
Coming back to the story I began in the section above, I opened up my laptop on a Saturday morning and launched VMware Fusion to run through the installation of Ubuntu 11.04. Following the installation, I rebooted the virtual machine and created a snapshot (restoring to the snapshot provided an easy way to rapidly reproduce a freshly installed operating system). After a few hours on Saturday and two to three on Sunday, I had put together several Chef cookbooks. When executed, the cookbooks turned a totally bare virtual machine into a fully functional web server.
On Monday morning I created a snapshot of my Linode VPS and wiped the virtual disks. Then, I instructed Linode to rebuild my VPS with its custom Ubuntu 11.04 image. When the machine came back up I replayed my Chef cookbooks against it — in a little under six minutes HTTP requests were being served.
Conclusion
With around six hours worth of work, I was able to write code that could successfully redeploy a machine in under six minutes. I had been exposed to Chef before, but actually going through the steps to build a server from start to finish enlightened me — I don’t think I’ll ever want to manually configure a server again. Build documents are a good starting point for consistently spinning up machines, but when a machine is configured with Chef I can be absolutely sure that its configuration matches its cookbooks. I have never been able to say the same for a manually configured machine based on build documents.