Here's a little script that finds all .pp files in an environment
parse them an print all the found classes.

I didnt test if it works for .pp files with more than 1 class in them

Just point it at your module path and environment at the top

--------
require 'puppet'
require 'find'

Puppet.settings[:modulepath] = "/etc/puppet/manifests/common/modules"
parser = Puppet::Parser::Parser.new(Puppet::Node::Environment.new("production"))

klasses = []

Find.find(Puppet.settings[:modulepath]) do |f|
  next unless f =~ /\.pp$/

  parser.file = f
  ast = parser.parse

  ast.instantiate('').each do |resource_type|
    klasses << resource_type.namespace if resource_type.file == f
  end

end

klasses.sort.each{|k| puts k}
----------

----- Original Message -----
> From: llow...@oreillyauto.com
> To: puppet-users@googlegroups.com
> Sent: Thursday, July 12, 2012 9:55:55 PM
> Subject: Re: [Puppet Users] How can I list classes available on the puppet 
> master?
> 
> 
> Comments inline
> On Thursday, July 12, 2012 3:29:27 PM UTC-5, Ygor wrote:
> 
> http://docs.puppetlabs.com/man/doc.html
> 
> I use a command like this:
> 
> puppet doc --outputdir <yadda...yadda>/apache/htdocs/puppetmaster
> --mode rdoc --manifestdir /etc/puppet/manifests --modulepath
> /etc/puppet/modules
> 
> And I get a fantastic web-tree describing every class on my
> PuppetMaster
> 
> It does require you to document your code, but it is worth it IMNSHO
> :)
> 
> 
> 
> I had tried this before, unsuccessfully. But it is working on my dev
> environment (perhaps my prod and test masters don't have rdoc
> installed? Shall have to look into that later).
> 
> So I am glad that part is working.
> 
> Now I just need to find a good ay to get the info into dashboard.
> 
> 
> “Sometimes I think the surest sign that intelligent life exists
> elsewhere in the universe is that none of it has tried to contact
> us.”
> Bill Waterson (Calvin & Hobbes)
> 
> 
> 
> 
> --
> You received this message because you are subscribed to the Google
> Groups "Puppet Users" group.
> To view this discussion on the web visit
> https://groups.google.com/d/msg/puppet-users/-/OFj4YYtBmBwJ .
> To post to this group, send email to puppet-users@googlegroups.com.
> To unsubscribe from this group, send email to
> puppet-users+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/puppet-users?hl=en.
>

-- 
You received this message because you are subscribed to the Google Groups 
"Puppet Users" group.
To post to this group, send email to puppet-users@googlegroups.com.
To unsubscribe from this group, send email to 
puppet-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/puppet-users?hl=en.

Reply via email to