Kamal Fariz Mahyuddin on Ruby on Rails, Ember.js and other web development geekery.

You should follow me on twitter here.

Creating a Custom dpkg Search Index for Chef 0.7.x

I wanted to search across all my nodes that they have the latest Chef client package installed. The default indexer doesn’t index installed debian packages, so I whipped out a custom dpkg indexer based on the sample code from the wiki.

Here it is:

It’s a lot longer than the sample because I had to do the whole client authentication dance (most of it was copied directly from lib/chef/client.rb). Good news is that authentication will change dramatically in the upcoming Chef 0.8.x release which should simplify creating custom clients.

Once you run the indexer, your search screen on chef-server will now see a new query form for dpkg. Here’s an example of querying for packages that match the name attribute “chef” and returning only the “version” and “status” attributes.

Chef Server Search Screen

Fork me on GitHub