A hack to configure workstations with chef
One of things that I used to hear a lot from people was, "How can we use chef to configure developer workstations?" or other kinds of unmanaged hosts.
BackgroundMost of the solutions I have come across don't fit my use case for one of the following reasons:
- They require adding the workstation as a node to the chef server. This adds unnecessary complexity.
- They use chef-solo instead of chef-zero, which is less flexible and harder to test.
- They don't leverage Berkshelf for cookbook mangement, which makes it harder to customize things.
My SolutionI use chef-zero and Berkshelf to execute chef-client locally. This can be done in a couple of commands on a workstation or "dumb" VM. Assuming a Debian or Debian derivative host:
apt-get install ruby rake git sudoThe configuration defaults can either be edited directly in the attributes/default.rb file (if you are lazy like me), or the Right Way by editing the zero.json file. I'd imagine if anyone else were to use this they would fork the repo and set up their defaults as needed.
git clone https://github.com/christopherdeutsch/devbox.git
My Use Cases
- Developer laptop. It's a pain for a developer to add a node to a chef server, generate a client key, and so on. It's relatively easy to git clone and edit a JSON file.
- Dumb VirtualBox VM. I am a UNIX guy but I have a Windows computer at home I use primarily for gaming. I have no interest in installing ChefDK under windows for chef development; I'd rather just install Debian on a VirtualBox and do the chef development there.
Other SolutionsThis problem has been attacked several times over the years. See also:
- http://technology.customink.com/blog/2012/05/28/provision-your-laptop-with-chef-part-1/ - this was the first example I came across of using chef for this purpose
- https://github.com/Nordstrom/chefdk_bootstrap - a ChefDK setup solution
- https://github.com/joemiller/workstation-bootstrap - OSX bootstrap with chef