By the nature of the Puppet's language, resources must have a unique
title and must have only one definition.
Quoting http://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.
Expanding somewhat on Andrew's response:
From a conceptual perspective, if two separate and independent modules
both require the same package, then clearly it is incorrect to model
that package as belonging to or being the responsibility of either
module. It is a more fundamental resource than either module
represents, else you would not have such a conflict in the first
place.
The correct solution, both conceptually and practically, is to manage
the package via a separate module that both of the others rely upon.
In your particular case, it looks like it would be very natural to
create and use a "php" or "php5" module to manage all the PHP
packages. Your "apache" and "cms" modules would then both depend on
the new "php" module to ensure that the needed packages were
installed.
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.