llowder@oreillyauto.com
2012-Jul-12 15:54 UTC
[Puppet Users] How can I list classes available on the puppet master?
Is there a way to get a list of all the classes available from the puppet master? I have 2 goals for this - one is documentation in a human readable form, and the other is potentially importing that data into dashboard. I did find some info on the rest API (http://docs.puppetlabs.com/guides/rest_api.html#resource-types ) but I can''t make any sense of the output from it. Thanks. Lee -- 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/-/wmJFsgZDA8sJ. To post to this group, send email to puppet-users@googlegroups.com. To unsubscribe from this group, send email to puppet-users+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/puppet-users?hl=en.
Nick Cammorato
2012-Jul-12 16:50 UTC
[Puppet Users] Re: How can I list classes available on the puppet master?
You could do something like this, it''s not the cleanest in the world(I barely ever use sed anymore), but as something quick and dirty: curl -k -H "Accept: yaml" https://puppet:8140/mgmt/resource_types/class | more | grep " name: " | sed -e ''s/^ *name: //;s/&id.* //'' | sort | uniq It''ll have some bad data you''ll have to parse out(built-in classes like notify, fail, etc.), but should work. On Thursday, July 12, 2012 11:54:25 AM UTC-4, llo...@oreillyauto.com wrote:> > Is there a way to get a list of all the classes available from the puppet > master? > > I have 2 goals for this - one is documentation in a human readable form, > and the other is potentially importing that data into dashboard. > > I did find some info on the rest API ( > http://docs.puppetlabs.com/guides/rest_api.html#resource-types ) but I > can''t make any sense of the output from it. > > Thanks. > > Lee >On Thursday, July 12, 2012 11:54:25 AM UTC-4, llo...@oreillyauto.com wrote:> > Is there a way to get a list of all the classes available from the puppet > master? > > I have 2 goals for this - one is documentation in a human readable form, > and the other is potentially importing that data into dashboard. > > I did find some info on the rest API ( > http://docs.puppetlabs.com/guides/rest_api.html#resource-types ) but I > can''t make any sense of the output from it. > > Thanks. > > Lee >On Thursday, July 12, 2012 11:54:25 AM UTC-4, llo...@oreillyauto.com wrote:> > Is there a way to get a list of all the classes available from the puppet > master? > > I have 2 goals for this - one is documentation in a human readable form, > and the other is potentially importing that data into dashboard. > > I did find some info on the rest API ( > http://docs.puppetlabs.com/guides/rest_api.html#resource-types ) but I > can''t make any sense of the output from it. > > Thanks. > > Lee >On Thursday, July 12, 2012 11:54:25 AM UTC-4, llo...@oreillyauto.com wrote:> > Is there a way to get a list of all the classes available from the puppet > master? > > I have 2 goals for this - one is documentation in a human readable form, > and the other is potentially importing that data into dashboard. > > I did find some info on the rest API ( > http://docs.puppetlabs.com/guides/rest_api.html#resource-types ) but I > can''t make any sense of the output from it. > > Thanks. > > Lee >-- 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/-/m4XmKKAYwtkJ. To post to this group, send email to puppet-users@googlegroups.com. To unsubscribe from this group, send email to puppet-users+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/puppet-users?hl=en.
Ryan Coleman
2012-Jul-12 20:08 UTC
Re: [Puppet Users] How can I list classes available on the puppet master?
One way to approach this (for documentation) is to build a file resource backed by a template. The template would contain something like the following. It prints out all the classes defined in that agents catalog. <% classes.each do |klass| -%> The class <%= klass %> is defined <% end -%> This example could be used to build something like /etc/motd on each system with the list of defined classes. As for Dashboard, if you chose to use it as your ENC, the class information is already there. Otherwise, that''s not something you can really do (afaik) outside of a custom fact that each machine populates into the Dashboards inventory service. HTH, --Ryan On Thu, Jul 12, 2012 at 8:54 AM, llowder@oreillyauto.com <llowder@oreillyauto.com> wrote:> Is there a way to get a list of all the classes available from the puppet > master? > > I have 2 goals for this - one is documentation in a human readable form, and > the other is potentially importing that data into dashboard. > > I did find some info on the rest API > (http://docs.puppetlabs.com/guides/rest_api.html#resource-types ) but I > can''t make any sense of the output from it. > > Thanks. > > Lee > > -- > 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/-/wmJFsgZDA8sJ. > To post to this group, send email to puppet-users@googlegroups.com. > To unsubscribe from this group, send email to > puppet-users+unsubscribe@googlegroups.com. > For more options, visit this group at > http://groups.google.com/group/puppet-users?hl=en.-- Ryan Coleman | about.me/ryc Modules & Forge @ Puppet Labs -- 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+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/puppet-users?hl=en.
Ryan Coleman
2012-Jul-12 20:08 UTC
Re: [Puppet Users] How can I list classes available on the puppet master?
Crap, I forgot to mention my source: http://docs.puppetlabs.com/guides/templating.html#access-to-defined-tags-and-classes On Thu, Jul 12, 2012 at 1:08 PM, Ryan Coleman <ryan@puppetlabs.com> wrote:> One way to approach this (for documentation) is to build a file > resource backed by a template. The template would contain something > like the following. It prints out all the classes defined in that > agents catalog. > > <% classes.each do |klass| -%> > The class <%= klass %> is defined > <% end -%> > > This example could be used to build something like /etc/motd on each > system with the list of defined classes. > > As for Dashboard, if you chose to use it as your ENC, the class > information is already there. Otherwise, that''s not something you can > really do (afaik) outside of a custom fact that each machine populates > into the Dashboards inventory service. > > HTH, > --Ryan > > On Thu, Jul 12, 2012 at 8:54 AM, llowder@oreillyauto.com > <llowder@oreillyauto.com> wrote: >> Is there a way to get a list of all the classes available from the puppet >> master? >> >> I have 2 goals for this - one is documentation in a human readable form, and >> the other is potentially importing that data into dashboard. >> >> I did find some info on the rest API >> (http://docs.puppetlabs.com/guides/rest_api.html#resource-types ) but I >> can''t make any sense of the output from it. >> >> Thanks. >> >> Lee >> >> -- >> 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/-/wmJFsgZDA8sJ. >> To post to this group, send email to puppet-users@googlegroups.com. >> To unsubscribe from this group, send email to >> puppet-users+unsubscribe@googlegroups.com. >> For more options, visit this group at >> http://groups.google.com/group/puppet-users?hl=en. > > > > -- > Ryan Coleman | about.me/ryc > Modules & Forge @ Puppet Labs-- Ryan Coleman | about.me/ryc Modules & Forge @ Puppet Labs -- 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+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/puppet-users?hl=en.
llowder@oreillyauto.com
2012-Jul-12 20:21 UTC
Re: [Puppet Users] How can I list classes available on the puppet master?
Comments inline. On Thursday, July 12, 2012 3:08:10 PM UTC-5, Ryan Coleman wrote:> > One way to approach this (for documentation) is to build a file > resource backed by a template. The template would contain something > like the following. It prints out all the classes defined in that > agents catalog. > >I''m not really wanting a listing of classes currently applied to a given node. I am wanting to get a listing of every class that is defined and available to be used in node defs.> <% classes.each do |klass| -%> > The class <%= klass %> is defined > <% end -%> > > This example could be used to build something like /etc/motd on each > system with the list of defined classes. > > As for Dashboard, if you chose to use it as your ENC, the class > information is already there. Otherwise, that''s not something you can > really do (afaik) outside of a custom fact that each machine populates > into the Dashboards inventory service. > >The class info is not already there, it only sees and can use classes that you define either through it''s web UI or by inserting directly into it''s DB.> HTH, > --Ryan > > On Thu, Jul 12, 2012 at 8:54 AM, llowder wrote: > > Is there a way to get a list of all the classes available from the > puppet > > master? > > > > I have 2 goals for this - one is documentation in a human readable form, > and > > the other is potentially importing that data into dashboard. > > > > I did find some info on the rest API > > (http://docs.puppetlabs.com/guides/rest_api.html#resource-types ) but I > > can''t make any sense of the output from it. > > > > Thanks. > > > > Lee > > > > -- > > 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/-/wmJFsgZDA8sJ. > > To post to this group, send email to puppet-users@googlegroups.com. > > To unsubscribe from this group, send email to > > puppet-users+unsubscribe@googlegroups.com. > > For more options, visit this group at > > http://groups.google.com/group/puppet-users?hl=en. > > > > -- > Ryan Coleman | about.me/ryc > Modules & Forge @ Puppet Labs >-- 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/-/aQ2szZ_TnUcJ. To post to this group, send email to puppet-users@googlegroups.com. To unsubscribe from this group, send email to puppet-users+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/puppet-users?hl=en.
Nigel Kersten
2012-Jul-12 20:21 UTC
Re: [Puppet Users] How can I list classes available on the puppet master?
On Thu, Jul 12, 2012 at 8:54 AM, llowder@oreillyauto.com <llowder@oreillyauto.com> wrote:> Is there a way to get a list of all the classes available from the puppet > master?We''ve actually addressed this more directly in the upcoming Telly branch, where we''ve extended the resource_type REST API to make this simpler: https://projects.puppetlabs.com/issues/14137 You''ll be able to directly ask the question via an API of "what classes exist in this environment?" Note you can do this already prior to Telly, but you need to do filtering yourself on the returned output to just grab class information.> > I have 2 goals for this - one is documentation in a human readable form, and > the other is potentially importing that data into dashboard. > > I did find some info on the rest API > (http://docs.puppetlabs.com/guides/rest_api.html#resource-types ) but I > can''t make any sense of the output from it. > > Thanks. > > Lee > > -- > 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/-/wmJFsgZDA8sJ. > To post to this group, send email to puppet-users@googlegroups.com. > To unsubscribe from this group, send email to > puppet-users+unsubscribe@googlegroups.com. > For more options, visit this group at > http://groups.google.com/group/puppet-users?hl=en.-- Nigel Kersten | http://puppetlabs.com | @nigelkersten Schedule Meetings at: http://tungle.me/nigelkersten -- 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+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/puppet-users?hl=en.
R.I.Pienaar
2012-Jul-12 20:22 UTC
Re: [Puppet Users] How can I list classes available on the puppet master?
----- Original Message -----> From: "Ryan Coleman" <ryan@puppetlabs.com> > To: puppet-users@googlegroups.com > Sent: Thursday, July 12, 2012 9:08:55 PM > Subject: Re: [Puppet Users] How can I list classes available on the puppet master? > > Crap, I forgot to mention my source: > http://docs.puppetlabs.com/guides/templating.html#access-to-defined-tags-and-classes > > On Thu, Jul 12, 2012 at 1:08 PM, Ryan Coleman <ryan@puppetlabs.com> > wrote: > > One way to approach this (for documentation) is to build a file > > resource backed by a template. The template would contain something > > like the following. It prints out all the classes defined in that > > agents catalog. > > > > <% classes.each do |klass| -%> > > The class <%= klass %> is defined > > <% end -%>that classes array is built up during parsing so when used like this it wont be complete till the end of the compile, so its not reliable. same reason that defined() doesnt work. Best way is to check classes.txt on the node. this code: ----- class one { } class two { } include one notice(inline_template("<%= classes.inspect %>")) include two notice(inline_template("<%= classes.inspect %>")) ----- does: ----- notice: Scope(Class[main]): ["settings", "one"] notice: Scope(Class[main]): ["settings", "one", "two"] notice: Finished catalog run in 0.04 seconds ----- you can see the contents depend on the parse order and will only be complete at the end of the compile. if you supply a class list from an ENC the whole ENC received list will be in there from the start though -- 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+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/puppet-users?hl=en.
Dan White
2012-Jul-12 20:29 UTC
Re: [Puppet Users] How can I list classes available on the puppet master?
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 :) “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) ----- llowder@oreillyauto.com wrote:> Is there a way to get a list of all the classes available from the puppet > master? > > I have 2 goals for this - one is documentation in a human readable form, > and the other is potentially importing that data into dashboard. > > I did find some info on the rest API > (http://docs.puppetlabs.com/guides/rest_api.html#resource-types ) but I > can''t make any sense of the output from it. > > Thanks. > > Lee > > -- > 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/-/wmJFsgZDA8sJ. > To post to this group, send email to puppet-users@googlegroups.com. > To unsubscribe from this group, send email to puppet-users+unsubscribe@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+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/puppet-users?hl=en.
Walter Heck
2012-Jul-12 20:32 UTC
Re: [Puppet Users] How can I list classes available on the puppet master?
It''s pretty ghetto, but we''ve used this script before, which I can confirm still works on Puppet 2.7.17: http://www.devco.net/archives/2010/02/26/what_does_puppet_manage_on_a_node-2.php cheers, Walter On Fri, Jul 13, 2012 at 4:22 AM, R.I.Pienaar <rip@devco.net> wrote:> > > ----- Original Message ----- > > From: "Ryan Coleman" <ryan@puppetlabs.com> > > To: puppet-users@googlegroups.com > > Sent: Thursday, July 12, 2012 9:08:55 PM > > Subject: Re: [Puppet Users] How can I list classes available on the > puppet master? > > > > Crap, I forgot to mention my source: > > > http://docs.puppetlabs.com/guides/templating.html#access-to-defined-tags-and-classes > > > > On Thu, Jul 12, 2012 at 1:08 PM, Ryan Coleman <ryan@puppetlabs.com> > > wrote: > > > One way to approach this (for documentation) is to build a file > > > resource backed by a template. The template would contain something > > > like the following. It prints out all the classes defined in that > > > agents catalog. > > > > > > <% classes.each do |klass| -%> > > > The class <%= klass %> is defined > > > <% end -%> > > that classes array is built up during parsing so when used like this it > wont be > complete till the end of the compile, so its not reliable. > > same reason that defined() doesnt work. > > Best way is to check classes.txt on the node. > > this code: > ----- > class one { } > class two { } > > include one > > notice(inline_template("<%= classes.inspect %>")) > > include two > > notice(inline_template("<%= classes.inspect %>")) > ----- > > does: > ----- > notice: Scope(Class[main]): ["settings", "one"] > notice: Scope(Class[main]): ["settings", "one", "two"] > notice: Finished catalog run in 0.04 seconds > ----- > > you can see the contents depend on the parse order and will only be > complete at the end of the compile. > > if you supply a class list from an ENC the whole ENC received list > will be in there from the start though > > -- > 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+unsubscribe@googlegroups.com. > For more options, visit this group at > http://groups.google.com/group/puppet-users?hl=en. > >-- Walter Heck -- Check out my startup: Puppet training and consulting @ http://www.olindata.com Follow @olindata on Twitter and/or ''Like'' our Facebook page at http://www.facebook.com/olindata -- 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+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/puppet-users?hl=en.
llowder@oreillyauto.com
2012-Jul-12 20:55 UTC
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+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/puppet-users?hl=en.
R.I.Pienaar
2012-Jul-12 21:04 UTC
Re: [Puppet Users] How can I list classes available on the puppet master?
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: llowder@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+unsubscribe@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+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/puppet-users?hl=en.
Nan Liu
2012-Jul-13 00:17 UTC
Re: [Puppet Users] Re: How can I list classes available on the puppet master?
So this is turning it into a small coding contest =). I needed something similar to this, and there''s a pretty easy way to do this with the puppet resource_type face. require ''puppet'' require ''puppet/face'' Puppet::Face[:resource_type,:current].search(''*'').find_all {|x| x.type==:hostclass}.collect{|x| x.name}.sort You can do some interesting things, such as get all the classes parameters as well: Puppet::Face[:resource_type,:current].search(''*'').find_all {|x| x.type==:hostclass}.collect{|x| {x.name=>x.arguments.keys}} Here''s an example of classes and parameters it accept: [{"apt::backports"=>["release", "location"]}, {"apt::debian::testing"=>[]}, {"apt::debian::unstable"=>[]}, {"apt::params"=>[]}, {"apt::release"=>["release_id"]}, {"apt::update"=>[]}, {"apt"=> ["purge_sources_list_d", "purge_sources_list", "always_apt_update", "proxy_host", "proxy_port", "purge_preferences_d", "disable_keys"]}, ... Thanks, Nan On Thu, Jul 12, 2012 at 9:50 AM, Nick Cammorato <nick_cammorato@terc.edu> wrote:> You could do something like this, it''s not the cleanest in the world(I > barely ever use sed anymore), but as something quick and dirty: > curl -k -H "Accept: yaml" https://puppet:8140/mgmt/resource_types/class | > more | grep " name: " | sed -e ''s/^ *name: //;s/&id.* //'' | sort | uniq > > It''ll have some bad data you''ll have to parse out(built-in classes like > notify, fail, etc.), but should work. > > > On Thursday, July 12, 2012 11:54:25 AM UTC-4, llo...@oreillyauto.com wrote: >> >> Is there a way to get a list of all the classes available from the puppet >> master? >> >> I have 2 goals for this - one is documentation in a human readable form, >> and the other is potentially importing that data into dashboard. >> >> I did find some info on the rest API >> (http://docs.puppetlabs.com/guides/rest_api.html#resource-types ) but I >> can''t make any sense of the output from it. >> >> Thanks. >> >> Lee > > > On Thursday, July 12, 2012 11:54:25 AM UTC-4, llo...@oreillyauto.com wrote: >> >> Is there a way to get a list of all the classes available from the puppet >> master? >> >> I have 2 goals for this - one is documentation in a human readable form, >> and the other is potentially importing that data into dashboard. >> >> I did find some info on the rest API >> (http://docs.puppetlabs.com/guides/rest_api.html#resource-types ) but I >> can''t make any sense of the output from it. >> >> Thanks. >> >> Lee > > > On Thursday, July 12, 2012 11:54:25 AM UTC-4, llo...@oreillyauto.com wrote: >> >> Is there a way to get a list of all the classes available from the puppet >> master? >> >> I have 2 goals for this - one is documentation in a human readable form, >> and the other is potentially importing that data into dashboard. >> >> I did find some info on the rest API >> (http://docs.puppetlabs.com/guides/rest_api.html#resource-types ) but I >> can''t make any sense of the output from it. >> >> Thanks. >> >> Lee > > > On Thursday, July 12, 2012 11:54:25 AM UTC-4, llo...@oreillyauto.com wrote: >> >> Is there a way to get a list of all the classes available from the puppet >> master? >> >> I have 2 goals for this - one is documentation in a human readable form, >> and the other is potentially importing that data into dashboard. >> >> I did find some info on the rest API >> (http://docs.puppetlabs.com/guides/rest_api.html#resource-types ) but I >> can''t make any sense of the output from it. >> >> Thanks. >> >> Lee > > -- > 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/-/m4XmKKAYwtkJ. > > To post to this group, send email to puppet-users@googlegroups.com. > To unsubscribe from this group, send email to > puppet-users+unsubscribe@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+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/puppet-users?hl=en.
Nigel Kersten
2012-Jul-13 18:41 UTC
Re: [Puppet Users] Re: How can I list classes available on the puppet master?
Nan, I just assigned https://projects.puppetlabs.com/issues/7079 to you, it would be awesome if you could let us know in that ticket if your sample code suffers the same problem of classes with the same name as a node masking the existence of that node. On Thu, Jul 12, 2012 at 5:17 PM, Nan Liu <nan@puppetlabs.com> wrote:> So this is turning it into a small coding contest =). I needed > something similar to this, and there''s a pretty easy way to do this > with the puppet resource_type face. > > require ''puppet'' > require ''puppet/face'' > > Puppet::Face[:resource_type,:current].search(''*'').find_all {|x| > x.type==:hostclass}.collect{|x| x.name}.sort > > You can do some interesting things, such as get all the classes > parameters as well: > > Puppet::Face[:resource_type,:current].search(''*'').find_all {|x| > x.type==:hostclass}.collect{|x| {x.name=>x.arguments.keys}} > > Here''s an example of classes and parameters it accept: > > [{"apt::backports"=>["release", "location"]}, > {"apt::debian::testing"=>[]}, > {"apt::debian::unstable"=>[]}, > {"apt::params"=>[]}, > {"apt::release"=>["release_id"]}, > {"apt::update"=>[]}, > {"apt"=> > ["purge_sources_list_d", > "purge_sources_list", > "always_apt_update", > "proxy_host", > "proxy_port", > "purge_preferences_d", > "disable_keys"]}, > ... > > Thanks, > > Nan > > On Thu, Jul 12, 2012 at 9:50 AM, Nick Cammorato <nick_cammorato@terc.edu> wrote: >> You could do something like this, it''s not the cleanest in the world(I >> barely ever use sed anymore), but as something quick and dirty: >> curl -k -H "Accept: yaml" https://puppet:8140/mgmt/resource_types/class | >> more | grep " name: " | sed -e ''s/^ *name: //;s/&id.* //'' | sort | uniq >> >> It''ll have some bad data you''ll have to parse out(built-in classes like >> notify, fail, etc.), but should work. >> >> >> On Thursday, July 12, 2012 11:54:25 AM UTC-4, llo...@oreillyauto.com wrote: >>> >>> Is there a way to get a list of all the classes available from the puppet >>> master? >>> >>> I have 2 goals for this - one is documentation in a human readable form, >>> and the other is potentially importing that data into dashboard. >>> >>> I did find some info on the rest API >>> (http://docs.puppetlabs.com/guides/rest_api.html#resource-types ) but I >>> can''t make any sense of the output from it. >>> >>> Thanks. >>> >>> Lee >> >> >> On Thursday, July 12, 2012 11:54:25 AM UTC-4, llo...@oreillyauto.com wrote: >>> >>> Is there a way to get a list of all the classes available from the puppet >>> master? >>> >>> I have 2 goals for this - one is documentation in a human readable form, >>> and the other is potentially importing that data into dashboard. >>> >>> I did find some info on the rest API >>> (http://docs.puppetlabs.com/guides/rest_api.html#resource-types ) but I >>> can''t make any sense of the output from it. >>> >>> Thanks. >>> >>> Lee >> >> >> On Thursday, July 12, 2012 11:54:25 AM UTC-4, llo...@oreillyauto.com wrote: >>> >>> Is there a way to get a list of all the classes available from the puppet >>> master? >>> >>> I have 2 goals for this - one is documentation in a human readable form, >>> and the other is potentially importing that data into dashboard. >>> >>> I did find some info on the rest API >>> (http://docs.puppetlabs.com/guides/rest_api.html#resource-types ) but I >>> can''t make any sense of the output from it. >>> >>> Thanks. >>> >>> Lee >> >> >> On Thursday, July 12, 2012 11:54:25 AM UTC-4, llo...@oreillyauto.com wrote: >>> >>> Is there a way to get a list of all the classes available from the puppet >>> master? >>> >>> I have 2 goals for this - one is documentation in a human readable form, >>> and the other is potentially importing that data into dashboard. >>> >>> I did find some info on the rest API >>> (http://docs.puppetlabs.com/guides/rest_api.html#resource-types ) but I >>> can''t make any sense of the output from it. >>> >>> Thanks. >>> >>> Lee >> >> -- >> 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/-/m4XmKKAYwtkJ. >> >> To post to this group, send email to puppet-users@googlegroups.com. >> To unsubscribe from this group, send email to >> puppet-users+unsubscribe@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+unsubscribe@googlegroups.com. > For more options, visit this group at http://groups.google.com/group/puppet-users?hl=en. >-- Nigel Kersten | http://puppetlabs.com | @nigelkersten Schedule Meetings at: http://tungle.me/nigelkersten -- 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+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/puppet-users?hl=en.
Nan Liu
2012-Jul-13 21:57 UTC
Re: [Puppet Users] Re: How can I list classes available on the puppet master?
It doesn''t seem to have the issue: Puppet::Face[:resource_type,:current].search(''*'').collect{|x| x.type} => [:hostclass, :node] Puppet::Face[:resource_type,:current].search(''demo'').collect{|x| x.type} => [:hostclass, :node] Nan On Fri, Jul 13, 2012 at 11:41 AM, Nigel Kersten <nigel@puppetlabs.com> wrote:> Nan, I just assigned https://projects.puppetlabs.com/issues/7079 to > you, it would be awesome if you could let us know in that ticket if > your sample code suffers the same problem of classes with the same > name as a node masking the existence of that node. > > On Thu, Jul 12, 2012 at 5:17 PM, Nan Liu <nan@puppetlabs.com> wrote: >> So this is turning it into a small coding contest =). I needed >> something similar to this, and there''s a pretty easy way to do this >> with the puppet resource_type face. >> >> require ''puppet'' >> require ''puppet/face'' >> >> Puppet::Face[:resource_type,:current].search(''*'').find_all {|x| >> x.type==:hostclass}.collect{|x| x.name}.sort >> >> You can do some interesting things, such as get all the classes >> parameters as well: >> >> Puppet::Face[:resource_type,:current].search(''*'').find_all {|x| >> x.type==:hostclass}.collect{|x| {x.name=>x.arguments.keys}} >> >> Here''s an example of classes and parameters it accept: >> >> [{"apt::backports"=>["release", "location"]}, >> {"apt::debian::testing"=>[]}, >> {"apt::debian::unstable"=>[]}, >> {"apt::params"=>[]}, >> {"apt::release"=>["release_id"]}, >> {"apt::update"=>[]}, >> {"apt"=> >> ["purge_sources_list_d", >> "purge_sources_list", >> "always_apt_update", >> "proxy_host", >> "proxy_port", >> "purge_preferences_d", >> "disable_keys"]}, >> ... >> >> Thanks, >> >> Nan >> >> On Thu, Jul 12, 2012 at 9:50 AM, Nick Cammorato <nick_cammorato@terc.edu> wrote: >>> You could do something like this, it''s not the cleanest in the world(I >>> barely ever use sed anymore), but as something quick and dirty: >>> curl -k -H "Accept: yaml" https://puppet:8140/mgmt/resource_types/class | >>> more | grep " name: " | sed -e ''s/^ *name: //;s/&id.* //'' | sort | uniq >>> >>> It''ll have some bad data you''ll have to parse out(built-in classes like >>> notify, fail, etc.), but should work. >>> >>> >>> On Thursday, July 12, 2012 11:54:25 AM UTC-4, llo...@oreillyauto.com wrote: >>>> >>>> Is there a way to get a list of all the classes available from the puppet >>>> master? >>>> >>>> I have 2 goals for this - one is documentation in a human readable form, >>>> and the other is potentially importing that data into dashboard. >>>> >>>> I did find some info on the rest API >>>> (http://docs.puppetlabs.com/guides/rest_api.html#resource-types ) but I >>>> can''t make any sense of the output from it. >>>> >>>> Thanks. >>>> >>>> Lee >>> >>> >>> On Thursday, July 12, 2012 11:54:25 AM UTC-4, llo...@oreillyauto.com wrote: >>>> >>>> Is there a way to get a list of all the classes available from the puppet >>>> master? >>>> >>>> I have 2 goals for this - one is documentation in a human readable form, >>>> and the other is potentially importing that data into dashboard. >>>> >>>> I did find some info on the rest API >>>> (http://docs.puppetlabs.com/guides/rest_api.html#resource-types ) but I >>>> can''t make any sense of the output from it. >>>> >>>> Thanks. >>>> >>>> Lee >>> >>> >>> On Thursday, July 12, 2012 11:54:25 AM UTC-4, llo...@oreillyauto.com wrote: >>>> >>>> Is there a way to get a list of all the classes available from the puppet >>>> master? >>>> >>>> I have 2 goals for this - one is documentation in a human readable form, >>>> and the other is potentially importing that data into dashboard. >>>> >>>> I did find some info on the rest API >>>> (http://docs.puppetlabs.com/guides/rest_api.html#resource-types ) but I >>>> can''t make any sense of the output from it. >>>> >>>> Thanks. >>>> >>>> Lee >>> >>> >>> On Thursday, July 12, 2012 11:54:25 AM UTC-4, llo...@oreillyauto.com wrote: >>>> >>>> Is there a way to get a list of all the classes available from the puppet >>>> master? >>>> >>>> I have 2 goals for this - one is documentation in a human readable form, >>>> and the other is potentially importing that data into dashboard. >>>> >>>> I did find some info on the rest API >>>> (http://docs.puppetlabs.com/guides/rest_api.html#resource-types ) but I >>>> can''t make any sense of the output from it. >>>> >>>> Thanks. >>>> >>>> Lee >>> >>> -- >>> 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/-/m4XmKKAYwtkJ. >>> >>> To post to this group, send email to puppet-users@googlegroups.com. >>> To unsubscribe from this group, send email to >>> puppet-users+unsubscribe@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+unsubscribe@googlegroups.com. >> For more options, visit this group at http://groups.google.com/group/puppet-users?hl=en. >> > > > > -- > Nigel Kersten | http://puppetlabs.com | @nigelkersten > Schedule Meetings at: http://tungle.me/nigelkersten > > -- > 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+unsubscribe@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+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/puppet-users?hl=en.
Kamil Winczek
2012-Jul-16 11:57 UTC
Re: [Puppet Users] How can I list classes available on the puppet master?
On 12 Jul 12 08:54 -0700, llowder@oreillyauto.com wrote:> Is there a way to get a list of all the classes available from the puppet > master? > I have 2 goals for this - one is documentation in a human readable form, > and the other is potentially importing that data into dashboard.Hi, How about simple: find . -name ''*.pp'' -exec awk ''/^class [a-zA-Z]/ {print $2}'' {} \; ? -- Kamil Winczek, Gentoo Linux user, post no: 1443 GG:888677, M:kamil[at]winczek.com, JID:crs[at]jabster.pl For a list of all the ways technology has failed to improve the quality of life, please press three. - Alice Kahn -- 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+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/puppet-users?hl=en.
Ohad Levy
2012-Jul-22 13:03 UTC
Re: [Puppet Users] How can I list classes available on the puppet master?
On Mon, Jul 16, 2012 at 2:57 PM, Kamil Winczek <kamil@winczek.com> wrote:> On 12 Jul 12 08:54 -0700, llowder@oreillyauto.com wrote: > > Is there a way to get a list of all the classes available from the > puppet > > master? > > I have 2 goals for this - one is documentation in a human readable > form, > > and the other is potentially importing that data into dashboard. > > Hi, > > How about simple: > > find . -name ''*.pp'' -exec awk ''/^class [a-zA-Z]/ {print $2}'' {} \; >You can also use foreman Proxy [1] to get that info for you :) Ohad [1] - http://theforeman.org/projects/smart-proxy/wiki [1]> > ? > -- > Kamil Winczek, Gentoo Linux user, post no: 1443 > GG:888677, M:kamil[at]winczek.com, JID:crs[at]jabster.pl > For a list of all the ways technology has failed to improve > the quality of life, please press three. - Alice Kahn > > -- > 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+unsubscribe@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+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/puppet-users?hl=en.
Seemingly Similar Threads
- Puppet Forge question
- Certificate problems.
- Error 400 on SERVER: Puppet::Parser::AST::Resource failed with error ArgumentError: Invalid resource type ruby::gemInstall at myFile.pp:82
- problem using apache & passenger to run dashboard
- rspec-puppet and puppet doc conflicts