2010-09-15 15:36, Marc Zampetti wrote:

>  I don't think I've made my problem clear. The issue is NOT how to
> specify a version for a package. I know how to do that. And I know how
> to use a define to do it as well.
> 
> The issue is that if I call the define from two different classes on the
> same node, I get Duplicate errors. I also know how to make the define a
> virtual resource, but then the problem is I don't know how to pass in
> the version number when I do the realize.
> 
> How can I include the same package more then once on a host, with the
> option of specifying the version to install on a module/class basis.

First of all, Puppet does not handle installing more than one version
of a package on the same node.  Even if the package itself supports it,
like the kernel packages do.  This:

    package {
        "kernel": ensure => "2.6.18-194.11.1.el5";
        "kernel": ensure => "2.6.18-194.11.3.el5";
    }

will give you an error.

If you only need one version of each package installed on each node,
then you can do it using Puppet.  There exists a nice little function
named 'defined()' which you can use:

    class app1 {
        if ! defined(Package["needed-package"]) {
            package { "needed-package": ensure => "17.23"; }
        }
    }
    class app2 {
        if ! defined(Package["needed-package"]) {
            package { "needed-package": ensure => "17.23"; }
        }
    }

The problem with this approach, though, is that if you then also do

    class app3 {
        if ! defined(Package["needed-package"]) {
            package { "needed-package": ensure => "17.69"; }
        }
    }

and happen to include both app1 and app3 on the same node, Puppet won't
detect this conflict, and you will instead get a random version installed.
You won't even be ensured that Puppet will always choose the same version!
It could conceivably change its mind between two consecutive runs of puppetd,
with the exact same manifests and options to puppetd and puppetmasterd.

There might be some way to get Puppet to detect this kind of conflict, but
I don't know of any off hand.  Would need to think more about that.


        /Bellman

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

Reply via email to