Ask Your Question

How to view all modules in use by a given node

asked 2016-01-26 09:54:43 -0500

jlent gravatar image

Given a node name (and environment) with root access to either the puppet masters or puppet db, what's a good way to pull down all modules/classes in use by a given node, recursively?

Let's say is assigned to module baz. Ideally, we'd print out module baz, then check all includes and inherits statements and recursively print all other modules. If it matters, we're simply using 10_nodes.pp as our node classifier.

I swear I've done this before through PuppetDB but cannot remember how to pull this off. Any suggestions would be appreciated. I'd rather not have to rely on a git checkout of our configs and then parse through that if it can be avoided. I was hoping for something built-in. Thanks!

edit retag flag offensive close merge delete

1 answer

Sort by » oldest newest most voted

answered 2016-01-26 10:11:31 -0500

updated 2016-01-26 10:12:02 -0500

A few options spring to mind.

There are files /var/lib/puppet/state/classes.txt and /var/lib/puppet/state/resources.txt that already list all the classes and resources managed on a node, as well as /var/lib/puppet/state/state.yml.

Failing that, you can simply compile the catalog for that node (I wrote a blog post on how to do this not long ago here). You can then open up the catalog in a text editor and find all the included classes and resources.

Otherwise, you'll be needing to call Puppet's internals to do this, looking in how the compiler works.

edit flag offensive delete link more


Thanks Alex, the local files are enough for my purposes. Altering my original question slightly, is there a way on the puppetmasters/puppetdb servers to answer the question "what nodes are using class X"? thanks!

jlent gravatar imagejlent ( 2016-01-26 10:47:24 -0500 )edit

Take a look at puppetdbquery by Eric Dalén - maybe that will give you some hints how to query PuppetDB for the information you want.

Henrik Lindberg gravatar imageHenrik Lindberg ( 2016-02-07 18:37:14 -0500 )edit

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools


Asked: 2016-01-26 09:54:43 -0500

Seen: 75 times

Last updated: Jan 26 '16