Agile Testing: Chef installation and minimal configuration
Chef installation and minimal configuration I started to play with Chef the other day. The instructions on the wiki are a bit confusing, but help on twitter (thanks @jtimberman) and on the #chef IRC channel (thanks @kallistec) has been great. I am at the very minimal stage of having a chef client talking to a chef server. I hasten to write down what I’ve done so far, both for my own sake and for others who might want to do the same. My OS is Ubuntu 10.04 32-bit on both machines.
First of all: as the chef wiki says, make sure you have FQDNs correctly set up on both client and server, and that they can ping each other at a minimum using the FQDN. I added the FQDN to the local IP address line in /etc/hosts, so that ‘hostname -f’ returned the FQDN correctly. In what follows, my Chef server machine is called chef.example.com and my Chef client machine is called client.example.com.
Installing the Chef server
Here I went the Ruby Gems route, because the very latest Chef (0.9.4) had not been captured in the Ubuntu packages yet when I tried to install it.
a) install pre-requisites
# apt-get install ruby ruby1.8-dev libopenssl-ruby1.8 rdoc ri irb build-essential wget ssl-cert
# wget production.cf.rubygems.org/rubygems/rubygems-1.3.7.tgz
# tar xvfz rubygems-1.3.7.tgz
# cd rubygems-1.3.7
# ruby setup.rb
# ln -sfv /usr/bin/gem1.8 /usr/bin/gem
c) install the Chef gem
d) install the Chef server by bootstrapping with the chef-solo utility
d1) create /etc/chef/solo.rb with contents:
file_cache_path “/tmp/chef-solo”
cookbook_path “/tmp/chef-solo/cookbooks”
recipe_url “s3.amazonaws.com/chef-solo/bootstrap-latest.tar.gz”
#knife configure -i
Where should I put the config file? [~/.chef/knife.rb]
Please enter the chef server URL: [localhost:4000] chef.example.com
Please enter a clientname for the new client: [root]
Please enter the existing admin clientname: [chef-webui]
Please enter the location of the existing admin client’s private key: [/etc/chef/webui.pem]
Please enter the validation clientname: [chef-validator]
Please enter the location of the validation key: [/etc/chef/validation.pem]
Please enter the path to a chef repository (or leave blank):
f) create an intial Chef repository
I created a directory called /srv/chef/repos , cd-ed to it and ran this command:
# git clone git://github.com/opscode/chef-repo.git
At this point, you should have a functional Chef server, although it won’t help you much unless you configure some clients.
Installing a Chef client
Here’s the bare minimum I did to get a Chef client to just talk to the Chef server configured above, without actually performing any cookbook recipe yet (I leave that for another post).
The first steps are very similar to the ones I followed when I installed the Chef server.
Note that the only difference so far between the Chef server and the Chef client bootstrap files is the one directive at the end of chef.json, which is bootstrap::server for the server and bootstrap::client for the client.
Caveat for this step: if you mess up and bootstrap the client using the wrong chef.json file containing the bootstrap::server directive, you will end up with a server and not a client. I speak from experience — I did exactly this, then when I tried to run chef-client on this box, I got:
WARN: HTTP Request Returned 401 Unauthorized: Failed to authenticate!
/usr/lib/ruby/1.8/net/http.rb:2097:in `error!’: 401 “Unauthorized” (Net::HTTPServerException)
posted by Grig Gheorghiu at 4:34 PM

July 18, 2010 | Posted by
Categories:
Tags: