puppet provider package

13 views
Skip to first unread message

Rich Siegel

unread,
May 18, 2012, 10:02:35 AM5/18/12
to Puppet Developers
I am trying to build something around a completely new package manager
for windows (not msi). Specifically I am trying to find out the goal
of what def_query is within a puppet provider package ? Is this a
list of all packages installed? Just a determination for 1 specific
resource package? I have looked at some examples in here :
https://github.com/puppetlabs/puppet/tree/master/lib/puppet/provider/package,
and it is hard to determine what puppet is expecting.

I had a look here, and it doesn't describe self.instances or def_query
role in the package provider sense.
http://projects.puppetlabs.com/projects/1/wiki/Development_Provider_Development

Jeff McCune

unread,
May 19, 2012, 6:06:52 PM5/19/12
to puppe...@googlegroups.com
On Fri, May 18, 2012 at 7:02 AM, Rich Siegel <rism...@gmail.com> wrote:
> I am trying to build something around a completely new package manager
> for windows (not msi).  Specifically I am trying to find out the goal
> of what def_query is within a puppet provider package ?  Is this a
> list of all packages installed?  Just a determination for 1 specific
> resource package?   I have looked at some examples in here :
> https://github.com/puppetlabs/puppet/tree/master/lib/puppet/provider/package,
> and it is hard to determine what puppet is expecting.

Puppet will call the query method on the instance of the package
provider resource when checking if the package is installed already or
not.

It's a determination for one specific package, the package modeled by
the resource the method is called on.

A simple (and poor) example of this determination is the pkgdmg
provider for Mac OS X:

def query
if FileTest.exists?("/var/db/.puppet_pkgdmg_installed_#{@resource[:name]}")
...
end

https://github.com/puppetlabs/puppet/blob/master/lib/puppet/provider/package/pkgdmg.rb#L104-111

It's a poor example because this method of determining if a package is
installed or not isn't ideal. Ideally the provider will talk directly
to the packaging system of the OS.

self.instances is a class method of the provider that returns all of
the resources present on the system. Not just a specific resource.

Hope this helps,
-Jeff

Jeff Weiss

unread,
May 19, 2012, 6:24:40 PM5/19/12
to puppe...@googlegroups.com
Rich,

The PIP package provider
(https://github.com/puppetlabs/puppet/blob/master/lib/puppet/provider/package/pip.rb#L26)
has decent comments about what is expected.

If you are working with a new package manager, then self.instances
will return a array of hashes. Each element in the array describing a
single package. Query provides the information for the single package
identified by @resource[:name].

I believe the test that the current msi package uses is if a state
file exists. I believe one could also query the registry, but my
windows-fu is waning.

Best of luck,

Jeff Weiss
Software Developer
Puppet Labs, Inc.
jeff....@puppetlabs.com

Sent from my iPhone
> --
> You received this message because you are subscribed to the Google Groups "Puppet Developers" group.
> To post to this group, send email to puppe...@googlegroups.com.
> To unsubscribe from this group, send email to puppet-dev+...@googlegroups.com.
> For more options, visit this group at http://groups.google.com/group/puppet-dev?hl=en.
>
Reply all
Reply to author
Forward
0 new messages