Managing multiple computers will get out of hands sooner or later if you do not have a certain level of automation. With virtualization and the cloud it is getting easier and easier to create new virtual machines and the number of environments you have to keep up-to-date increases constantly. You can write your own custom automation scripts, install an SSH manager that supports running commands on multiple computers like Gnome Connection Manager or ClusterSSH but at the end you will just run into further problems. If you want to be able to manage a complex Linux based infrastructure, look into automation software like Puppet or Chef. Puppet is great but Chef offers a hosted edition that allows you to manage five servers for free (each virtual machine or cloud instance counts as server) which makes it easy to get started. Here is how.
Sign up for Hosted Chef
To get started with Chef create an account for Hosted Chef at http://www.opscode.com/hosted-chef/ by registering for the Free Trial. You will need to download your user key, your organization validation key and a so called knife configuration file. Knife is the command line client of Chef. If you can’t find them, please take a look at http://wiki.opscode.com/display/chef/Setup+Opscode+User+and+Organization.
Set up your computer to manage Chef installations
You can install Chef on your local workstation with the command
curl -L https://www.opscode.com/chef/install.sh | sudo bash
You will also need Git on your workstation which you can install with apt-get install git or yum install git depending on your Linux distribution. Then download a copy of the Chef repository to your home directory and create a hidden subfolder with the name chef in the newly created chef-repo directory.
cd git clone git://github.com/opscode/chef-repo.git mkdir chef-repo/.chef
Now copy the user key, organization key and the knife.rb file from the sign-up process into the .chef directory.
Set up chef on a server
If you are running Debian or Ubuntu you can use apt-get to install Chef and keep it up-to-date, see http://wiki.opscode.com/display/chef/Installing+Chef+Client+on+Ubuntu+or+Debian for details. For CentOS, Fedora, Windows and others click here.
After the installation, login to Hosted Chef, go to Clients and create a new client. Enter the server name as client name and download the API key. Upload the API key to your server and place it in the /etc/chef folder as client.pem. Restart the chef-client.
Remotely execute scripts on your client
The chef client on the server will now execute scripts that you submit via your workstation. These scripts are called recipes in Chef and the execution will not be immediate. By default in the Ubuntu installation, the client will only look up if he has some recipes to run every 1800 seconds (30 minutes), but this interval can be changed in /etc/default/chef-client.
A sample run could look like this: Go to your workstation’s chef installation, create or download a recipe (here a sample from the quick start guide that will just create a text file on the server), upload the recipe to Hosted Chef and add the recipe to the server’s to-do list.
cd ~/chef-repo knife cookbook site install getting-started knife cookbook upload getting-started knife node run_list add YOURSERVERNAME 'recipe[getting-started]'
That’s it. In a few hours you can have a working Chef infrastructure and a basic understanding about how Chef works. There are a lot of guides with further examples at http://wiki.opscode.com/display/chef/Guides. Start cooking!