Last updated October 11, 2012
I have lots of Ubuntu hosts and sometimes I need to see on which host(s) a specific version of a package is installed (say, the day a vulnerability is announced). It’s also helpful to have a record of when specific packages are installed and upgraded on a given host. So I wrote a small utility to examine the installed packages on a Debian or Ubuntu host and output the result as JSON. E.g.:
Installation is simple:
If you want to include a per-host unique identifier to avoid relying
on FQDN, create a file /etc/dpkginv.conf
containing:
You could, for example, set this to the value of
/sys/class/dmi/id/product_uuid
Since it’s just JSON you could do something like keep a daily record of inventory in CouchDB, e.g.:
Source is here. It’s implemented as a plugin for Chef’s Ohai, so you could also use it in a larger Chef context.