Note: This post is quite old. There are probably better methods for this now.
There are a number of ways to setup your infrastructure so that you can refer to machines by hostname. I currently prefer the “dynamically generated hosts file” approach because it’s simple to understand and setting up a DNS server is intimidating (as well as a single point of failure).
Shlomo Swidler has a great article comparing different DNS configurations as well as some sample code for dynamically updating hosts files. However, if you’re already using Chef you can achieve the same thing with a very simple cookbook.
First, create a new cookbook:
Place the following in site-cookbooks/hosts/recipes/default.rb:
Then create the template, site-cookbooks/hosts/templates/default/hosts.erb:
Add the recipe to your node’s run_list and run chef-client and your /etc/hosts should contain all the Chef nodes on your network. Note that one downside to this approach is that updates will be slow (since chef-client only runs every 30 minutes by default).
Now what if you wanted to point at a specific service, like having chef.example.com point at your Chef master? Just search for it in your recipe (and add it to the variables list):
If you haven’t heard of Redis before, it’s a key-value store similar to memcached with support for more complex data types like lists, sets, and hashes. collectd is a stats collection daemon which recently added support for plugins written in Python. This is great because there’s no way I’d write a plugin in C! Anyway, you can use this plugin to collect data about your Redis server like number of active connections, database size, commands processed per second, and memory usage. You can then use a tool like drraw to generate nice graphs:
More info and installation instructions on the GitHub page.
When using Apache’s DirectoryIndex directive make sure you don’t separate the values with commas. If you do, Apache will be looking for filenames ending in commas!