Redefine package type

255 views
Skip to first unread message

SiD

unread,
Sep 8, 2010, 4:10:21 AM9/8/10
to Puppet Users
Hello,

I would like to go in depth with Puppet, but I haven't found any good
documentation about my issue (I've just ordered the official Puppet
book, hope it helps).
I need to install RPM packages with specified install-options, like --
prefix. But the package type does not support this kind of option.
Does anyone have an idea how to redefine a type ?

Thanks !

mohit chawla

unread,
Sep 8, 2010, 4:45:55 AM9/8/10
to puppet...@googlegroups.com
You can probably start by looking at the code for the various types/providers under puppet's code directory. On Debian, for eg., the code for rpm package provider is under /usr/lib/ruby/1.8/puppet/provider/package/rpm.rb .



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


SiD

unread,
Sep 9, 2010, 4:27:16 AM9/9/10
to Puppet Users
Thanks for your quick answer.
I've already analysed the code, but it does not really help me. Do I
need to write a new provider in Ruby, or can I override the original
one ?

Thanks again !

On Sep 8, 10:45 am, mohit chawla <mohit.chawla.bin...@gmail.com>
wrote:
> You can probably start by looking at the code for the various
> types/providers under puppet's code directory. On Debian, for eg., the code
> for rpm package provider is under
> /usr/lib/ruby/1.8/puppet/provider/package/rpm.rb .
>
> On Wed, Sep 8, 2010 at 1:40 PM, SiD <self...@gmail.com> wrote:
> > Hello,
>
> > I would like to go in depth with Puppet, but I haven't found any good
> > documentation about my issue (I've just ordered the official Puppet
> > book, hope it helps).
> > I need to install RPM packages with specified install-options, like --
> > prefix. But the package type does not support this kind of option.
> > Does anyone have an idea how to redefine a type ?
>
> > Thanks !
>
> > --
> > You received this message because you are subscribed to the Google Groups
> > "Puppet Users" group.
> > To post to this group, send email to puppet...@googlegroups.com.
> > To unsubscribe from this group, send email to
> > puppet-users...@googlegroups.com<puppet-users%2Bunsu...@googlegroups.com>
> > .

alcy

unread,
Sep 9, 2010, 4:46:37 AM9/9/10
to Puppet Users
You can do both.

As an introductory tutorial, have a look at
http://www.kartar.net/2010/02/puppet-types-and-providers-are-easy/
and, more information at http://docs.puppetlabs.com/#extending_puppet

Eric Shamow

unread,
Sep 9, 2010, 11:40:06 AM9/9/10
to puppet...@googlegroups.com
Well as a starter --

This is a provider called rpm_plus.rb -- I found most of it floating
around on the web and I seem to recall tweaking some small part of it,
although I don't recall now what it was... in any event this works and
is in use in our environment. Provider looks like:

Puppet::Type.type(:package).provide :rpm_plus, :parent => :rpm, :source =>
:rpm do

has_feature :versionable

desc "Support via ``rpm``."
commands :rpm_plus => "rpm"
def rpm(*args)
rpm_plus(*args + @resource[:vendor].split(" "))
end
end

You'd throw this in a file called rpm_plus.rb and stash it in
<module>/lib/puppet/provider/package/. What this basically does is
wrap the existing RPM provider with another one that lets you pass
arguments in a "vendor" attribute.

You would then install your RPM package in your manifest the following way:

package{ 'My_package':
ensure => 'version_number',
provider => rpm_plus,
source = "<my_package_location>",
vendor => "--prefix=/home/ads",
}

The key bits are the provider => rpm_plus attribute, which tells
Puppet to override its default yum provider, and the vendor attribute,
into which you pass your additional arguments.

-Eric

> To unsubscribe from this group, send email to puppet-users...@googlegroups.com.

SiD

unread,
Sep 10, 2010, 9:41:02 AM9/10/10
to Puppet Users
Thank you for your links, especially kartar.net. Blog posts are really
useful and clear !

On Sep 9, 10:46 am, alcy <mohit.chawla.bin...@gmail.com> wrote:
> You can do both.
>
> As an introductory tutorial, have a look athttp://www.kartar.net/2010/02/puppet-types-and-providers-are-easy/
> and, more information athttp://docs.puppetlabs.com/#extending_puppet

SiD

unread,
Sep 10, 2010, 9:57:48 AM9/10/10
to Puppet Users
Hey Eric

Wow, it's exactly what I wanted to do. I did not know how to call the
provider and modify the command without writing a new provider.
Simple, clear and powerful. Thanks a lot for sharing !
Did you use "vendor" parameter because it is not possible to create
new parameters ? I have tired, but it does not work.
Reply all
Reply to author
Forward
0 new messages