Hi Timo, there are two ways to achieve duplicate resource prevention:
1. virtual resources migrate all packages which could be used by multiple classes into a separate class and mark them with the @-sign to be "virtual". Virtual resources are not added to catalog onless you tell Puppet to realize or collect the resource. Best practice is to provide information on when to manage the package via the "tag" metaparameter: e.g. site/profile/manifests/packages.pp class profile::packages { @package { 'foo': ensure => present, tag => ['web', 'db', 'storage'], } @package { 'bar': ensure => present, tag => ['db', 'storage'], } } on the db, web, storage server profile add the collector for the required resource type: class profile::db { Package <| tag == 'db' |> } site/profile/manifests/web.pp class profile::web { Package <| tag == 'web' |> } site/profile/manifests/storage.pp class profile::web { Package <| tag == 'storage' |> } 2nd option is to use the ensure_packages or ensure_resources function (I don't like this way as it hides what you want to achieve): site/profile/manifests/db.pp site/profile/manifests/db.pp class profile::db { ensure_packages(['foo', 'bar'], {ensure => present}) } site/profile/manifests/web.pp class profile::web { ensure_packages('foo', {ensure => present}) } site/profile/manifests/storage.pp class profile::web { ensure_packages(['foo', 'bar'], {ensure => present}) } hth, Martin > On 27. Sep 2019, at 12:38, Timo Vlot <timo.v...@gmail.com> wrote: > > Hi All, > > We recently start with Puppet and during our introductory consultancy it was > mentioned that there is a "sneaky" way to define a resource (for example a > pakcage) in multiple classes that wouldn't cause the "duplicate resource" > errors. We have a few classes that rely on the same package being installed, > but cannot guarantee they are all attached to a node, as such we would need > to define the same package resource in all classes. > > Does anyone know how to add a resource in multiple classes without the error? > > thanx! > > Timo > > -- > You received this message because you are subscribed to the Google Groups > "Puppet Users" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to puppet-users+unsubscr...@googlegroups.com. > To view this discussion on the web visit > https://groups.google.com/d/msgid/puppet-users/b690bc99-46cc-4130-b7ea-8f03442aa16d%40googlegroups.com. -- You received this message because you are subscribed to the Google Groups "Puppet Users" group. To unsubscribe from this group and stop receiving emails from it, send an email to puppet-users+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/puppet-users/C38915D8-513D-4B79-A986-56BB27EE2AAD%40gmail.com.