Ask Your Question
0

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

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

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
0

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

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.

#!/opt/puppet/bin/ruby

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


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

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

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

# 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
Usage:
        #{$0} [options]
where [options] are zero or more of:
EOS
    opt :environment, "puppet environment", :default => 'production'
    opt :filter, "class filter.", :default => "*"
  end
  puppet_resources(opts[:filter], opts)
end
edit flag offensive delete link more
0

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

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

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

Stats

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

Seen: 141 times

Last updated: Dec 02 '15