What I normally do is I create a virtual @package resource which installs 
php5 for example within say "apache" class and then I realize the virtual 
resource within the same "apache" class.

Please, if you intend to write generic and reusable modules so other people 
can use, STOP putting hardcoded dependencies in your modules.

Either write in documentation that it depends on an abstract resource, for 
instance a mysql database and make it configurable so you can pass db_name, 
db_host, etc to your "apache" class. Or create virtual resources and 
realize them within the same class - works great for packages and maybe 
other resource types.


On Tuesday, 3 April 2012 19:33:32 UTC+1, Christophe L 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). 
>
> Since we are newbies in puppet, we would like to understand what this 
> error meant: 
> does it mean that all the package resource ensuring the installation 
> of a package need to have a unique resource name ? 
> Or maybe have we done something wrong in our usage of puppet ? 
>
> Below, the code causing the error and how we fixed it. 
>
> Thanks in advance for your feebacks. 
>
> Best regards, 
> Christophe 
>
> 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, 
>   } 
>   ... 
> } 
>
> /etc/puppet/modules/cms/manifests/init.pp 
>
> class cms::installpackage { 
>   ... 
>   package { 'php5-imagick': 
>     name => 'php5-imagick', 
>     ensure => 'installed', 
>   } 
>   ... 
> } 
>
> In order to fix the error, we prefixed the resource in 
> cms::installpackage class with cms_ 
>
> package { 'cms_php5-imagick': 
>     name => 'php5-imagick', 
>     ensure => 'installed', 
> }

-- 
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/-/taR8nQd_iDMJ.
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