11

Is it possible to tell puppet to compile a catalog for one (or all) node(s) and save that particular data somewhere?

I'm specifically interested in getting all needed packages and their versions per node, but a general approach for getting any data is also suitable.

warren
  • 17,829
  • 23
  • 82
  • 134
Michal Bryxí
  • 417
  • 2
  • 7
  • 17

2 Answers2

13

UPDATE

This original answer is now out of date. The updated command for Puppet 3.x is:

puppet resource package

If you're looking for all the packages and versions installed on a node regardless of whether they're installed by Puppet or not, the following command is built in and can be run on any Puppet node:

ralsh package

This will output the data in a Puppet manifest form to stdout.

Ralsh will work for any resource type that has the instances method implemented (users, groups, etc.).

If you're looking to centrally inspect the YAML catalog for all resources defined in Puppet manifests, your Puppetmaster already caches this information in /var/lib/puppet/client_yaml/catalog and you just need to parse it with your YAML parser of choice. The Puppet Inventory Service that was introduced fairly recently may also be a good option for you; you can make do with storeconfigs if you're running on an older version like 0.25.x.

jgoldschrafe
  • 4,385
  • 17
  • 18
  • One problem with this approach is that it doesn't allow for multiple versions of the same package, as is common with the kernel package on Red Hat-based distros. – Paul Gear Aug 31 '12 at 03:57
  • I'm not sure this really answers the question: The command lists the currently _installed_ packages, not the packages required by Puppet. I'm interested in a list of the latter to feed it to `rpmorphan`. – Tim Landscheidt Nov 12 '13 at 16:21
  • @TimLandscheidt, are you asking about the full list of `package` resources that Puppet lists in the catalog for a node? Unless you feel up to parsing the cached catalog, your best bet would be to query PuppetDB. The query API is available [here](http://docs.puppetlabs.com/puppetdb/1.5/api/query/v3/resources.html]). – jgoldschrafe Nov 14 '13 at 14:50
  • @jgoldschrafe Finally got around to installing PuppetDB, and indeed it does what I want. I can query for all package resources that have "ensure" not equal to "absent" for a specific host, and use the JSON result to feed a list to rpmorphan. Thanks! – Tim Landscheidt Oct 08 '14 at 01:17
0

Honestly, this is the sort of thing that mcollective was built to do. Specifically, the package provider for mcollective: http://projects.puppetlabs.com/projects/mcollective-plugins/wiki/AgentPackage

This completely skips puppet, and doesn't even require that puppet is installed.

Justin Ellison
  • 718
  • 5
  • 9