Installing chef server on CentOS via rpms

This installation as described is based on a stock CentOS 5.3 install with only the 'Server' group of packages installed, anything different may require modification to the bootstrap. If that's the case you can clone my cookbooks repo as a starting point and roll your own.

Warning: Only attempt this install on a server you can stand to lose. The bootstrap assumes you want to give control of the machine to chef. At the very least it will ruin any existing apache configuration. For evaluation of chef I suggest a virtual machine.

Run each step as root:

1. First we need to disable SELinux as the bootstrap currently only works with it off. If you're using the default firewall you'll also need to open port 443. Both can be accomplished by running

system-config-securitylevel

and changing the appropriate settings.

2. Next we remove httpd so that chef can install it later in the bootstrap process. Unfortunately the apache2 cookbook currently only works from the ground up. Much of what CentOS installs by default will get in the way.

yum remove httpd

3. Install the EPEL repository.

4. Install the ELFF repository.

5. Now we can install chef! This will bring down a bunch of dependencies (currently 14 on a stock install)

yum install rubygem-chef

6. Now we are ready to setup chef-solo to run our cookbooks that will setup the server

echo 'file_cache_path "/tmp/chef-solo"
cookbook_path "/tmp/chef-solo/cookbooks"' > solo.rb

7. And the initial attributes for our recipes. You'll want to edit these.

echo '{
  "chef": {
    "path": "/var/lib/chef",
    "server_fqdn": "chef.example.com",
    "server_ssl_req": "/C=US/ST=Several/L=Locality/O=Example/OU=Operations/CN=chef.example.com/emailAddress=demo@example.com"
  },
  "packages": {
    "dist_only": true
  },
  "recipes": "chef::server"
}' > chef.json

if you're just experimenting with chef and using a fake fqdn, be sure to add chef.example.com to 127.0.0.1 in /etc/hosts, you'll need it later when registering the server as the first chef-client.

8. Now we can fire up chef-solo against the bootstrap that's been tested against CentOS. Alternately you can wget this file and run it locally. The current md5sum is 82cae27257c5a8c5fb3f4f714b9a108a. chef will execute the contents of this file as root, so be sure you're comfortable with the contents of the bootstrap.

chef-solo -c solo.rb -j chef.json -r http://chef.viviti.com/files/others/bootstrap.tar.gz 

The CentOS bootstrap is pretty much the same as the Debian/Ubuntu except that instead of using gem to install rubygems, we use rpm packages instead. We also skip over runit as well since it's not support and instead drop init scripts into the appropriate locations.

9. Sit back and wait, this is going to take a minute or two. The bootstrap should complete without error.

10. Try hitting https://chef.example.com you should get the chef gui. If not, try /var/log/httpd and /var/log/chef for some answers.

11. Login using an existing openid provider or signup for an account via a service like myopenid.com.

12. Register the chef server as the first client, you can use the token in server.rb

chef-client -t change_this_token

and you should see the node registered in the chef server gui. Check /var/log/chef/client.log for any issues. The client should be already running in the background as it was started during the bootstrap.

13. Follow the instructions on setting up a chef repository and create a simple cookbook. Make sure to copy your /etc/chef/{server,client}.rb configs into the git checkout, as the install rake task will overwrite them.