Nigel's Virtual Resources is one way, this is another using only
classes.

You can put the base software in classes of their own and include
these in your 'server classes'. Classes can be included multiple times
on a node without causing errors.

You'll want something that looks like:

class jre-jce {
  package { "jre-jce": ... }
}

class tomcat {
  package { "tomcat: ... }
}

class foo {
  include jre-jce
  include tomcat
  ... (do more stuff) ...
}

class bar {
  include jre-jce
  include tomcat
  ... (do more stuff) ...
}

node something {
  include foo
  include bar
}

If inside classes foo and bar you need to make sure that things occur
after jre-jce is installed you can setup a dependency with require,
see: http://docs.puppetlabs.com/references/latest/metaparameter.html#require

This is more verbose than using virtual resources, but the I like the
advantage that you've now already got a place where you can  put site
wide configuration for tomcat or jre-jce.

On Dec 17, 3:17 pm, bluebook <paul.fletc...@gmail.com> wrote:
> Hello,
>
> I'm new to puppet, so maybe this is a silly question, but an hour of
> googling has thrown up nothing.
>
> I am trying to define a set of classes which each represent different
> server types in my architecture, for example "dns server" and "web
> server".  A single machine may perform more than one server role - eg
> it could be both a dns server and a web server.
>
> For the types of roles I have, lets call them foo and bar, there are
> some packages in common.  Eg they both require tomcat and jre.  So to
> start off with I tried this:
>
> class foo {
>   package { jre-jce:                  ensure => present}
>   package { tomcat:               ensure => '6.0.20-1'}
>   package { foo-services:     ensure => present}
>
> }
>
> class bar {
>   package { jre-jce:                  ensure => present}
>   package { tomcat:               ensure => '6.0.20-1'}
>   package { bar-services:     ensure => present}
>
> }
>
> node 'server1' {
>         include foo
>         include bar
>
> }
>
> This works fine if I only include one class or the other in the node
> definition, but if I include both then I get an error "Package[jre-
> jce] is already defined in file ...; cannot redefine at ..."
>
> So now I am trying to find a way to move the package definitions
> outside of the class definitions, and reference them from there.  But
> I can't find a syntax which allows me to do that.  The closest I have
> come is this:
>
> package { jre-jce:                  ensure => present}
>
> class foo {
>   Package["jre-jce"] {}
>
> }
>
> but puppet doesn't like the empty braces.
>
> Is there a better way to do what I am trying to do?  Or is this the
> right way but the wrong syntax?
>
> Thanks for any help.
>
> Paul

-- 
You received this message because you are subscribed to the Google Groups 
"Puppet Users" group.
To post to this group, send email to puppet-us...@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