You need virtual resources:

1.       Define package A in a virtual way:



    @package {

        "A" :

            ensure => 'present',

    }



2.       Then  realize it wherever needed:

class module2::app2 {

            realize(Package["A"])

            # your stuff here...
}


Cheers,
Bernd

Von: puppet-users@googlegroups.com [mailto:puppet-users@googlegroups.com] Im 
Auftrag von EmmEff
Gesendet: Montag, 19. März 2012 02:15
An: puppet-users@googlegroups.com
Betreff: [Puppet Users] How to handle multiple definitions of the same package 
in multiple included modules?

How to handle this scenario?

Assume that all three apps are defined in three separate modules.  All three 
modules are mutually exclusive with the exception that they require the same 
packageA to be installed.

Pseudocode:

class module1::app1 {
  package {
    'packageA':
      ;
  }
}

class module2::app2 {
  package {
    'packageA':
      ;
  }
}

class module3::app3 {
  package {
    'packageA':
      ;
  }
}

-- site.pp

node 'mynode.example.com' {
  include module1::app1
  include module2::app2
  include module3::app3
}

This will give me an error that packageA is already defined in another file.  I 
*know* I'm missing something simple, but what is it?  How can I avoid this 
situation of the duplicate package definitions while ensuring the resource 
Package['packageA'] is created?

I tried the following but I guess I'm not understanding the defined() function 
properly:

class module1::app1 {
  if ! defined(Package['packageA']) {
    package {
      'packageA':
        ;
    }
  }
}

Forgive me if this is an oft asked question.  I couldn't figure out the search 
term that made sense that would match this scenario.  TIA

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

-- 
You received this message because you are subscribed to the Google Groups 
"Puppet Users" group.
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