Each time a definition is "called" it defines all the resources. If the definition for the virtual package isn't variable you should put it in a class as classes get included only once. Otherwise you will have to rename the resource depending on the variables of the definition (doesn't seem the case here, because it is a package)

Ex:

class clspackage
{
 @package { postfix: }
}

define mydefine1 {
 include clspackage
}

define mydefine2 {
 mydefine1 { $name: }

 realize Package[postfix]
}


Silviu

Sébastien Prud'homme wrote:
Hi,

I get a "duplicate definition problem" with Puppet 0.24.8 when using
virtual ressource in a define:

Here is a sample :

define mydefine1 {
  @package { postfix: }
}

define mydefine2 {
  mydefine1 { $name: }

  realize Package[postfix]
}

mydefine2 { test1: }
mydefine2 { test2: }

Here is the problem:

Puppet::Parser::AST::Resource failed with error ArgumentError:
Duplicate definition: Package[postfix] is already defined in file
test.pp at line 2

If i move the virtual resource in a class all is working fine. For instance:

class common {
  @package { postfix: }
}

define mydefine1 {
  include common
}

define mydefine2 {
  mydefine1 { $name: }

  realize Package[postfix]
}

mydefine2 { test1: }
mydefine2 { test2: }

Does someone know if it's a bug or if i'm doing things the wrong way?

Thanks!

-- 
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