TL;WR: go here
First I want to give huge props to the guys at RiotGames. Berkshelf is shaping up to be an awesome tool in the chef toolbox.
Second I want to say that Tim Dysinger’s chef-box was what gave me the idea, and this is largely borrowed from the concept he started there, but with Berkshelf, Vagrant chef provisioner, and cookbooks instead of custom scripts.
This is a tiny git repo that you can check out, run vagrant, and have a working chef-server and client up in no time. I am using this right now as a skeleton for testing and developing other things. It uses Berkshelf and Vagrant with minor special sauce for managing client/validation keys and knife configs.
I needed to get a quick chef server + 1 client up for testing some cookbooks. I can’t do this in test-kitchen, and test-kitchen is using librarian (all my infra is berkshelf).
Complex Test Scenario
In working to build datacenter infra over and over on a CI pipeline. I need model complex multi-node interactions in my dev and testing.
I also wanted to have an easy thing that can use for teaching other people chef without the hassle of getting a server installed and a knife client created.
I wanted to see how berkshelf was integrating with vagrant, and this seemed like a simple project.
Before you move forward make sure the following prerequisites are satisfied.
- Bundler is installed
- VirtualBox is installed
- ruby 1.9 (tho may work on 1.8 I just haven’t tested it)
Pull down the git source
git clone https://github.com/spheromak/chef-sandbox
Install the gems required
cd chef-sandbox bundle install
bundle exec vagrant up
If you’re familiar with vagrant all the vagrant stuff is the same, if you’re not familiar with vagrant go do so
Basic Vagrant stuff
Note that vagrant destroy will remove the client from the chef-server as well as delete the node form the chef server.
Login To Client
bundle exec vagrant ssh client1
bundle exec vagrant destroy client1
The chef/knife.rb file sets up a relative configuration that should work inside your server vm as well as in the base directory of your host. So you can run all your knife commands, and it will talk to your server vm.
The server install run_list runs a recipe that generates the knife credentials and stores them in /vagrant/chef. As well as copying the validation.pem there so that the subsequent clients can register with the server. When you remove a client via vagrant destroy the client and node will be removed from the server.
Spinning more clients
You can mod the Vagrant file to spin as many clients as you wish. I will probably add in some stuff down the road to make this easier.
I may work out some simple externalization of run_lists and box type/url. This would provide a simple primitive for building up your own test framework around vagrant.