Ask Your Question

Is there any puppet command to get the list of classes and their params?

asked 2015-12-02 05:35:47 -0600

LokeshN gravatar image

Is there any puppet command to get the list of classes and for each class what are the parameters?

edit retag flag offensive close merge delete

2 Answers

Sort by ยป oldest newest most voted

answered 2015-12-02 07:45:18 -0600

to get a list of classes do:

puppet config --section agent print classfile /var/opt/lib/pe-puppet/classes.txt

Output may vary dependent on your puppet version.

to get the parameters for each class...that I'm not to sure of - only way I can think of is to go through the classes.txt file and look through code..

edit flag offensive delete link more

answered 2015-12-02 19:49:57 -0600

lavaman gravatar image

Here is a script that we use to do exactly that. It outputs in json format, but you can modify that for your needs.


require 'puppet/face'
require 'trollop'
require 'json'

def puppet_resources(filter='*', options={})
  default = {
   :environment => 'production'

  opt = default.merge(options)
  resources =  Puppet::Face[:resource_type, :current].search(filter, {:extra => { 'environment' => opt[:environment] }})

  data = {}
  resources.each do |resource|
    data[] = resource.arguments
  puts data.to_json

# Execute this part when the file is run as a script
if __FILE__ == $0
  opts = Trollop::options do
    banner <<-EOS
#{$0} is a command-line tool to show puppet classes and parameters
        #{$0} [options]
where [options] are zero or more of:
    opt :environment, "puppet environment", :default => 'production'
    opt :filter, "class filter.", :default => "*"
  puppet_resources(opts[:filter], opts)
edit flag offensive delete link more

Your Answer

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

Add Answer

Question Tools

1 follower


Asked: 2015-12-02 05:35:47 -0600

Seen: 230 times

Last updated: Dec 02 '15