For BGP traffic engineering it’s very important to know which Destination-AS takes which path on your Upstream links. There is a great tool to visualize this: as-stats. It’s too bad that this nice piece of software lacks some very important things: There is no init script available, it does not run as a daemon by itself, it’s not packaged (neither as Debian nor as RPM package) and the directory structure does not follow any standard.
I took this piece of software to gain knowledge on how to create a simple Debian package with FPM and Rake and how to write a simple Upstart job for Ubuntu. Last but not least I created a Puppet module for it. Here is how I did it:
Rake and FPM
For using it, rake has to be installed (obviously):
gem install rake and you’re done. This assumes you have a running Ruby and GEM installation on your system.
rake clean: remove all created dirs
rake prepare[1.36]: downloads and prepares as-stats version 1.36
rake build: creates debian package
Now you have a simple Debian package, built with FPM, saved under
If you want to know how you can use FPM for yourself, my co-worker has written a nice blog post about it: Hubot, Ubuntu and .deb Packages
We use Jenkins at work to build software. I’ve created a parametrized (for the version parameter) Jenkins job which pulls the Rakefile from Git, runs the above three commands and copies the new package to our repository. This allows me to build a new Package if a new version of as-stats arrives with one click in Jenkins. This is really nice.
Because as-stats did not contain a start script, I added an modern Upstart job to the Package. It’s very easy to write one. This is how it looks for as-stats:
This is enough to have a configurable (through
It even runs as it’s own user, this is more secure than running as root.
More information on how to create an Upstart job can be found on upstart.ubuntu.com.
Now we have a nice little Debian package which can be installed and configured with Puppet. Therefor I’ve written a Puppet Module which also is on Github.
The usage is very simple:
$knownlinks is a Puppet Hash. I like this data type because it’s very simple to iterate over it in an ERB template.
With this tools (Rake, FPM, Jenkins, Upstart, Puppet) it’s very easy to deploy a software which is not distributed as package, nor has any startup scripts and even doesn’t run as daemon by itself. This is why I love OpenSource.