published on in Featured Geekyness CouchDB FreeBSD Puppet

couchdb and ruby on freebsd

I’ve been using Puppet at work for the handful of FreeBSD and, recently, Ubuntu desktops.

Aside from some very simple system configuration management (I’ve not yet dived too deep into puppet. I mostly use it for configuring system authentication and ensuring a particular computer security baseline), I though it would have been great to store the client’s “facts” into a accessable database.

Sometime last year, Puppet added the ability to store facts into a Couch Database:

I’m not using CentOS/RHEL or a Yum backed package system. I’m using FreeBSD with its Ports tree, so here is the equivalent command:

$ portinstall databases/couchdb

Why one instead of the 3? Because Ruby 1.8 already exists on the system, as it get installed with the necessary tools such as portupgrade. That also includes the gem tool.

The next component the article listed was the couchrest rubygem:

$ gem install couchrest -v1.0.0

That is where I had a slight problem. FreeBSD has a bunch of rubygem-* Ports, but not this one.

It is not that I can’t install the couchrest gem this way, FreeBSD can use Gem’s just like any OS. My problem is when you move out of the package management system your updating process ends up fragmented. I try very hard not to let this happen.

So how do I continue? I make a Port!

This was actually REALLY simple. First, I found another rubygem based port and copied it to a new structure called databases/rubygem-couchrest. I pulled up the FreeBSD’s Porters Handbook and followed the quick instructions.

What is pretty handy about the Ports tree is all the heavy lifting it does for you. For example, if a project is hosted on SourceForge, you can define the MASTER_SITE variable as:


And it will look up the project on SF (using other variables such as PORTNAME and PORTVERSION).

Ruby Forge is also supported, so I just had to set the MASTER_SITES to RG and define the name and version. It took all but 5 minutes to make, build a checksum, and create this shell archive:

# This is a shell archive.  Save it in a file, remove anything before
# this line, and then unpack it by entering "sh file".  Note, it may
# create directories; files and directories will be owned by you and
# have default permissions.
# This archive contains:
#	rubygem-couchrest
#	rubygem-couchrest/Makefile
#	rubygem-couchrest/distinfo
#	rubygem-couchrest/pkg-descr
echo c - rubygem-couchrest
mkdir -p rubygem-couchrest > /dev/null 2>&1
echo x - rubygem-couchrest/Makefile
sed 's/^X//' >rubygem-couchrest/Makefile << '656a34e951167ae5d8b3571b3b30bce9'
X# Ports collection makefile for:	rubygem-couchrest
X# Date created:				20 June 2011
X# Whom:						Mike Carlson (
XPORTNAME=	couchrest
XCATEGORIES=	databases rubygems
XCOMMENT=	provides a simple interface on top of CouchDBs RESTful HTTP API
XRUN_DEPENDS=	rubygem-json>=${PORTVERSION}:${PORTSDIR}/devel/rubygem-json \
X		rubygem-mime-types>=${PORTVERSION}:${PORTSDIR}/misc/rubygem-mime-types \
X		rubygem-rest-client>=${PORTVERSION}:${PORTSDIR}/www/rubygem-rest-client
XUSE_RUBY=   yes
X.include <>
echo x - rubygem-couchrest/distinfo
sed 's/^X//' >rubygem-couchrest/distinfo << 'fed48567690d00cc0666b4be7236926b'
XSHA256 (rubygem/couchrest-1.0.2.gem) = 55b62424feedba1cb936d7187c94875fbea8daf17962813deba0cf0c41c93c72
XSIZE (rubygem/couchrest-1.0.2.gem) = 45056
echo x - rubygem-couchrest/pkg-descr
sed 's/^X//' >rubygem-couchrest/pkg-descr << '72aefcf6ac70736e90967f68ab1bb671'
XCouchRest provides a simple interface on top of CouchDB's RESTful HTTP API, as well as including some utility scripts for managing views and attachments.

After running the gamut of “make” tests listed in the handbook, I submitted a PR with the command-line tool called send-pr(1) that is build in to FreeBSD. You can see it in the queue here

I don’t know if it will get approved, or how long it will take, but I’m happy that I took a step in contributing to the project. I’ve filed a few bugs, and I write about FreeBSD a lot, so this seems to be a good logical progression.

The end result is now I can follow the Puppet Blog entry on setting up and maintaining a CouchDB store for facts, and have a consistent updating method (via Ports that is). My hope is to have this become a source for our configuration management tool, and help us reconcile and keep hardware and OS information up to date.