Puppet resource details using http api or puppetdb api

28 views
Skip to first unread message

Riju Francis

unread,
Nov 5, 2013, 11:50:58 PM11/5/13
to puppet...@googlegroups.com
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

Nan Liu

unread,
Nov 6, 2013, 1:10:16 PM11/6/13
to puppet...@googlegroups.com
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

Nan Liu

unread,
Nov 6, 2013, 1:26:09 PM11/6/13
to puppet...@googlegroups.com
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):


Nan
Reply all
Reply to author
Forward
0 new messages