Reposting my answer to a similar thread:
https://groups.google.com/d/msg/puppet-users/xAhvtWetin4/cw4OOuNfCcIJ
Short version: use a define.
http://docs.puppetlabs.com/guides/language_guide.html#defined-resource-types
On Mon, Aug 13, 2012 at 05:17:13PM -0700, Kevin G. wrote:
> I'm pretty sure I'm coming at this from the wrong direction, if anybody
> could point me to what the puppet idiom should be here I'd really
> appreciate it.
> I'd like to install two instances of this service on this host, with
> different parameters:
>
> node /^memcache\d+.
util.foo.com$/ {
> class {'memcached': pool_index => 1, port => 11211 }
> class {'memcached': pool_index => 2, port => 11212 }
> }
>
> The class itself uses the parameters something like this (abridged):
>
> class memcached ($pool_index = undef, $port = 11211) {
> daemontools_service::s {
> memcached:
> service_name => "memcached${pool_index}",
> command => "exec memcached -v -m 2048 -p ${port} "
> }
> }
>
> But the first part throws this error: Duplicate declaration:
> Class[Memcached] is already declared in file...cannot redeclare.
> I was thinking a parameterized class was something you could call like a
> function, but apparently not. What's the right way to set that up twice,
> with different parameters?
>
> --
> You received this message because you are subscribed to the Google Groups
> "Puppet Users" group.
> To view this discussion on the web visit
> [1]
https://groups.google.com/d/msg/puppet-users/-/6vBVmFQ4V58J.
> To post to this group, send email to
puppet...@googlegroups.com.
> To unsubscribe from this group, send email to
>
puppet-users...@googlegroups.com.
> For more options, visit this group at
>
http://groups.google.com/group/puppet-users?hl=en.
>
> References
>
> Visible links
> 1.
https://groups.google.com/d/msg/puppet-users/-/6vBVmFQ4V58J