Friday, April 17, 2026

How can an admin see which resources are being managed by puppet?

  • There are two files on the system that show both resources and classes: /opt/puppetlabs/puppet/cache/state/resources.txt and /opt/puppetlabs/puppet/cache/state/classes.txt
  • You can also use puppet query to consult the puppetdb records (if you have appropriate access)
    puppet-query 'resources[] { certname="myhost.uiowa.edu" }' where myhost.uiowa.edu is the fully qualified hostname of the machine in question.

What are some useful puppet queries for getting information from puppetdb?

  • Voxpupuli maintains a list at https://voxpupuli.org/docs/pql_queries/
  • Find the Os version of systems running chrome 114
    puppet-query 'inventory[certname,facts.os.name] { certname in package_inventory[certname] { package_name ~ "chrome" and version ~ "114" }}'
  • list of systems with one resource but not another
    puppet-query 'inventory[certname] { resources { type="Class" and title="Profile::Base"  } and  ! certname in resources[certname] { type="Class" and title="Profile::Researchserver" }}'