Posts Tagged ‘package’

Fixing hanging Crypto Stick (and other USB peripherals) problems

Wednesday, December 28th, 2011

As you may or may not know, we use the Crypto Stick as our SSH authentication mechanism. Lately, some of us are experiencing ‘hanging’ every now-and-again. Yesterday, I found a blogpost on Ludovic Rousseau’s blog, detailing that this problem stems from a race condition in libusb. This problem is fixed in an experimental branch of libusb. As a full upgrade of libusb (from an experimental branch no less) is out of the question, I backported the patch to Ubuntu 11.04 (natty) and 11.11 (oneiric). These packages indeed solve the problem of the ‘hanging’ Crypto Stick (and probably every other ‘hanging’ USB device). Binary and source packages are available here in our repository. Or, you can add our repo to your sources.list:

  • Natty: deb http://debian.kumina.nl/ubuntu/ natty-kumina main
  • Oneiric: deb http://debian.kumina.nl/ubuntu/ oneiric-kumina main

Puppet Tips&Tricks: Getting the version from a package

Monday, March 1st, 2010

Sometimes you need to know the version of a package before you can do anything useful. For example, we need to make sure the augeas-lenses package is 0.6.0 or newer, otherwise it doesn’t include the aptpreferences lens. We need that lens to modify /etc/apt/preferences in a nice way.

It would be very nice if there was some sort of function that could check on the client which version a certain package was, but during the design of puppet it was decided that puppet is not allowed to execute functions on a client, all functions are executed on the puppetmaster. So that’s not a valid option.

Another solution would be to create puppet facts for every package installed containing their version. Although that would help, it would clutter the facts a bit and probably make each puppetd run quite a bit longer. Also, all those facts would have to be stored in the database, if you’re using storeconfigs, which would add a lot of useless data there (although I can imagine setups which would actually appreciate this). So I chose for a simpler way, creating a fact specifically for augeas-lenses.

Getting the version from the commandline is easy on Debian, simply execute dpkg-query -W -f='${Version}' augeas-lenses. Creating a fact from that, is in its turn easy too:

if  FileTest.exists?("/usr/bin/dpkg-query")
	Facter.add("augeas_version") do
		setcode do
			%x{/usr/bin/dpkg-query -W -f='${Version}' augeas-lenses}
		end
	end
end

I created a file in our common module, lib/facter/augeas_version.rb, since that module is included on every host and the fact isn’t specific for a certain module. Preferably, you should add the fact to the module which uses it, of course, to keep things separated.

Now I can simply do:

# We need to compare the current augeas version, to see if we have the
# aptpreferences lens available. It's only been included since 0.6.0.
if versioncmp($augeas_version, '0.6.0') < 0 {
  # Work with templates and concatenated files
  notify { "Using concatenated files, augeas-lenses version $augeas_version":; }
} else {
  # Work with augeas
  notify { "Using augeas, augeas-lenses version $augeas_version":; }
}

Awesome puppet! Hope this helps someone.