IPv6 address facts in older versions of facter

Facter is a companion tool to the puppet configuration management system that allows you to retrieve metadata about the system puppet is running on. This is then made available to puppet for use in config file templates or making informed decisions on how to go about configuring a system.

One thing I noticed when going through the list of variables output by facter was that no IPv6 address information was being reported. This was a bit of a roadblock as the majority of our systems are dual-stacked (IPv4 and IPv6), with many configuration files needing to know what IPv6 addresses to listen on. Whilst an ipaddress6 fact was added to facter 1.59, I’m working with a somewhat older version of Puppet (0.25) and Facter (1.56), these both ship with Ubuntu 10.04 LTS so I’d rather stick with them if at all possible, rather than resorting to a backports repository.

Luckily, the puppet guide provided a quick solution – custom facts. It was a simple matter of grabbing the relevant code from github and dropping it into a directory in the $FACTERLIB path. Running the facter command will now print out an ipaddress6 variable:

 $ facter ipaddress6

Of course, this only makes the fact available to the environment you are testing on. If you are running a puppetmaster server, you’ll need to follow the guide to distributing plugins as modules if you want to distribute the fact around your network. This can be done on a per-module basis, or globally as a top-scope variable by creating a skeleton module with a blank init.pp and the ipaddress6.rb file in the lib/facter directory.

To test if the variable is available, add the following to your site.pp manifest on the puppetmaster server:

 class puppet_v6_marker {
      file {
            ensure => present,
            mode   => 600,
            owner  => root,
            content => $::ipaddress6,
            group  => root

include puppet_v6_marker

Your puppet clients should now output their IPv6 address to /tmp/puppet-v6.

Backporting debian packages

Sometimes, you need a newer version of a package than is available in your debian/ubuntu install.

There’s a number of ways to do it, for example using tools such as Prevu, but here is the step by step process.

We are going to backport the latest version of Unbound from Ubuntu Jaunty (1.2.1 at the time of writing) to an Ubuntu Hardy system. As a prerequisite, we need the build-essential package installed as we are going to compile some software, we also need the fakeroot package in order to build debian packages:

aptitude install build-essential fakeroot

Firstly, we need to enable the Jaunty source repositories in our /etc/apt/sources.list file, and comment out the Hardy source repositories (any of the other lines beginning with deb-src). You should run aptitude update after this step:

deb-src http://ie.archive.ubuntu.com/ubuntu jaunty restricted main multiverse universe

The next step is to gather what we need to compile Unbound, the build dependencies:

apt-get build-dep unbound

Now, we retrieve the “debianised” source code for unbound:

apt-get source unbound

Then cd into the unbound source directory (it should be something like unbound-1.2.1) and run the following command:

dpkg-buildpackage -rfakeroot -b -uc -us

This will compile unbound and build the debian package in one go. The resultant package is deposited in the parent directory. You can install it by doing:

dpkg -i ../unbound_1.2.1-0ubuntu1_i386.deb

If all goes well you should be able to install this package on other i386 Ubuntu Hardy systems as needed.