Riju Francis
2013-Nov-06 04:50 UTC
[Puppet Users] Puppet resource details using http api or puppetdb api
Is there a way to get the package version or service status using the puppet api calls? Following resource commands show version/status in the output: puppet resource package iptables puppet resource service iptables Can the api be used to get similar output? Thanks Riju -- You received this message because you are subscribed to the Google Groups "Puppet Users" group. To unsubscribe from this group and stop receiving emails from it, send an email to puppet-users+unsubscribe@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/puppet-users/2558f187-5336-4c87-adc0-6d6428768998%40googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.
Nan Liu
2013-Nov-06 18:10 UTC
Re: [Puppet Users] Puppet resource details using http api or puppetdb api
On Tue, Nov 5, 2013 at 8:50 PM, Riju Francis <rijufrancis@gmail.com> wrote:> Is there a way to get the package version or service status using the > puppet api calls? > > Following resource commands show version/status in the output: > puppet resource package iptables > puppet resource service iptables > > Can the api be used to get similar output? >Puppet resource command is a face, so you can query via:> require ''puppet'' > require ''puppet/indirector/face''> puts Puppet::Face[:resource, ''0.0.1''].find(''package/linecache'').to_pson{"title":"linecache","exported":false,"tags":["package","linecache"],"type":"Package","parameters":{"provider":"gem","configfiles":"keep","loglevel":"notice","ensure":["0.46"]}} Look in the source code and there''s additional examples such as listing all resource of a type: all_users = Puppet::Face[:resource, ''0.0.1''].search("user") Thanks, Nan -- You received this message because you are subscribed to the Google Groups "Puppet Users" group. To unsubscribe from this group and stop receiving emails from it, send an email to puppet-users+unsubscribe@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/puppet-users/CACqVBqBa_v4%3D3uHDR2h8SpwDb0kjdYJW%2BHLDz-icxETrsry5Ag%40mail.gmail.com. For more options, visit https://groups.google.com/groups/opt_out.
Nan Liu
2013-Nov-06 18:26 UTC
Re: [Puppet Users] Puppet resource details using http api or puppetdb api
On Wed, Nov 6, 2013 at 10:10 AM, Nan Liu <nan.liu@gmail.com> wrote:> On Tue, Nov 5, 2013 at 8:50 PM, Riju Francis <rijufrancis@gmail.com>wrote: > >> Is there a way to get the package version or service status using the >> puppet api calls? >> >> Following resource commands show version/status in the output: >> puppet resource package iptables >> puppet resource service iptables >> >> Can the api be used to get similar output? >> > > Puppet resource command is a face, so you can query via: > > > require ''puppet'' > > require ''puppet/indirector/face'' > > > puts Puppet::Face[:resource, ''0.0.1''].find(''package/linecache'').to_pson > > > {"title":"linecache","exported":false,"tags":["package","linecache"],"type":"Package","parameters":{"provider":"gem","configfiles":"keep","loglevel":"notice","ensure":["0.46"]}} > > Look in the source code and there''s additional examples such as listing > all resource of a type: > > all_users = Puppet::Face[:resource, ''0.0.1''].search("user") >Bla, have to read more carefully since subject makes a difference here, if you want to search puppet db use (which also supplies a puppet face): https://github.com/dalen/puppet-puppetdbquery Nan -- You received this message because you are subscribed to the Google Groups "Puppet Users" group. To unsubscribe from this group and stop receiving emails from it, send an email to puppet-users+unsubscribe@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/puppet-users/CACqVBqCUP9fcgv%2BuGg5FL8dM9Qiy_Q1LwXV9Nzheen5kyCU%2BXQ%40mail.gmail.com. For more options, visit https://groups.google.com/groups/opt_out.