Hi,

The best way to overcome the problem you're experiencing, is to use virtual 
resources 

http://docs.puppetlabs.com/guides/virtual_resources.html

So, for example, you would have a class that declares the resources:

class php_v_packages {

    @package { [ "php5", "php5-cli", "php5-gd", "php5-imagick", "php5- 
        mysql", "phpmyadmin", "mysql-client" ]: 
        ensure => installed, 
    } 

}

and when you need to use those virtual packages, include that class, and 
realize the resources:

class apache::install { 

    include php_v_packages
    realize Package [ [ php5"], [php5-cli], [php5-gd], [php5-imagick]]

}

class cms::installpackage { 

    include php_v_packages
    realize Package [php5-imagick]

}

That should do the trick :)

Cheers,
Andrew

On Thursday, April 5, 2012 12:11:40 PM UTC+1, Christophe L wrote:
>
> Hello, 
>
> Thanks for your answer. 
>
> I understand the restriction about resource name uniqueness, but I 
> don't understand the practical usage of it on the package resources. 
>
> Let's say there is two modules totally different, written by two 
> different developpers, but both depending on the same debian 
> package : 
> the two developper wills use the simplified syntax of the package 
> resource such package { "MODULE_NAME" : ensure => installed }, like we 
> can see it on usual puppet sample on internet. 
>
> Then, when an administrator will include the two modules, it will fail 
> because the same package is defined twice, even if the description of 
> the resource is exactly the same. 
>
> It doesn't sound as a normal behavior to me, unless if a best practice 
> is to never use the simplified syntax for package resource ? 
>
> Or is there an other best practice for avoiding this situation ? 
>
> Thanks in advance for your answers. 
>
> Best regards. 
> Christophe 
>
>
> On 4 avr, 00:15, Miguel Di Ciurcio Filho <miguel.fi...@gmail.com> 
> wrote: 
> > On Tue, Apr 3, 2012 at 3:33 PM, Christophe L <cl.subscript...@gmail.com> 
> wrote: 
> > > Hello, 
> > 
> > > We had the following situation where including two classes that were 
> > > ensuring the installation of the same package "php5-imagick" and it 
> > > was causing an error indicating that two ressources of the same name 
> > > are forbidden (sorry, I don't have the exact message error since we 
> > > fixed quickly the error). 
> > 
> > By the nature of the Puppet's language, resources must have a unique 
> > title and must have only one definition. 
> > 
> > Quotinghttp://docs.puppetlabs.com/guides/language_guide.html#resources: 
> > 
> > "The field before the colon is the resource’s title, which must be 
> > unique and can be used to refer to the resource in other parts of the 
> > Puppet configuration." 
> > 
> > > Code causing the error: 
> > 
> > > /etc/puppet/modules/apache/manifests/init.pp 
> > 
> > > class apache::install { 
> > >  ... 
> > >  package { [ "php5", "php5-cli", "php5-gd", "php5-imagick", "php5- 
> > > mysql", "phpmyadmin", "mysql-client" ]: 
> > >        ensure => installed, 
> > >  } 
> > 
> > The line above is just a shortcut to this something like this: 
> > 
> > package {"php5": .... } 
> > package {"php5-cli": .... } 
> > package {"php5-imagick": .... } 
> > 
> > So when Puppet compiles all your manifests, there can be only one 
> > php5-imagick, in your case.

-- 
You received this message because you are subscribed to the Google Groups 
"Puppet Users" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/puppet-users/-/fnts8JOMwnIJ.
To post to this group, send email to puppet-users@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