FAQ
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+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/puppet-users?hl=en.

Search Discussions

  • Jcbollinger at Nov 6, 2012 at 8:41 pm

    On Tuesday, November 6, 2012 12:31:16 PM UTC-6, Vaidas Jablonskis wrote:
    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.
    If only it were that easy. Cross-module dependencies are a particularly
    tricky issue for all past and present Puppet versions. We have had some
    interesting discussions on that topic here, with some possibly-useful ideas
    arising from them, but none of that has made it into the codebase yet.

    If you write all your own modules then you can probably keep the problem
    under control, but if you rely on others' modules then you simply have to
    be prepared to make local modifications to address compatibility problems.
    Good module documentation is helpful for that, but there is no
    documentation or coding practice that can solve the problem under the
    current DSL.


    John

    --
    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/-/FuNKiZK0t_kJ.
    To post to this group, send email to puppet-users@googlegroups.com.
    To unsubscribe from this group, send email to puppet-users+unsubscribe@googlegroups.com.
    For more options, visit this group at http://groups.google.com/group/puppet-users?hl=en.

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
grouppuppet-users @
categoriespuppet
postedNov 6, '12 at 6:31p
activeNov 6, '12 at 8:41p
posts2
users2
websitepuppetlabs.com

2 users in discussion

Vaidas Jablonskis: 1 post Jcbollinger: 1 post

People

Translate

site design / logo © 2022 Grokbase