Managing Systems with Chef: Sandbox Play

Chef is an awesome tool for centralized management of systems and resources. Chef recipes are best consumed in a sandbox, first, before being deployed. Below, I describe a simple sandbox setup using VirtualBox and Debian Lenny.

Using VirtualBox, define a new virtual machine. I used the business card ISO to install a bare minimum Debian, without even the base system packages installed, which can be deselected from within tasksel during the install.

Once your Debian instance is running, you’ll want to install a few additional packages. (Imagine sudo is used below if it makes you feel more comfortable.)

# apt-get install build-essential linux-headers-$(uname -r) \
  ruby1.8 ruby1.8-dev rdoc1.8 ri1.8 ssh libopenssl-ruby1.8 couchdb \
  less netcat psmisc vim-nox sudo
# update-alternatives --install /usr/bin/ruby ruby /usr/bin/ruby1.8 500 \
  --slave /usr/share/man/man1/ruby.1.gz ruby.1.gz \
  /usr/share/man/man1/ruby.1.8.gz \
  --slave /usr/bin/ri ri /usr/bin/ri1.8 \
  --slave /usr/bin/irb irb /usr/bin/irb1.8

Thereafter, follow the installation guide for Debian based systems. I used update-alternatives again for the gem command.

# update-alternatives --install /usr/bin/gem gem /usr/bin/gem1.8 500

If you need more than NAT — you can run chef on a guest by itself and use chef-client against it for testing purposes — for applying recipes to nodes in addition to the chef-server node, you can configured bridged networking on a virtual network. Tolaris has a great guide on configuring VirtualBox for networking using bridge-utils. I decided to use maradns and udhcpd instead of dnsmasq, though. The former will easily allow you to use a bogus TLD.

On the system running VirtualBox:

# apt-get install bridge-utils maradns udhcpd

Two files are necessary for maradns to host a sandbox domain. One for the server, /etc/maradns/mararc:

maradns_uid = 115
ipv4_bind_addresses = ""
chroot_dir = "/etc/maradns"
recursive_acl = ""
csv2 = {}
csv2["net.chef."] = ""

A zone file,

# askmara

# Querying the server with the IP
# Question: +86400 a
# NS replies:
#net.chef. +86400 ns
# AR replies: +86400 a

Finally, the configuration for udhcpd in /etc/udhcpd.conf:

max_leases      245
interface vnet0
opt     dns
opt     subnet
opt     router

The above alleviates the need for manually configuring each guest’s IP, default route, and DNS server, making it easier to use a single cloned, immutable disk image for all testing needs. The IP assigned can be tied to the virtual machine’s virtual ethernet mac address, too.

With that complete, a FQDN can be used for Chef hosts and SSL certs.

Post a Comment

Your email is never shared. Required fields are marked *