[Puppet Users] Re: Calling a define multiple times

Luke Kanies
Mon, 13 Oct 2008 15:19:50 -0000

On Oct 13, 2008, at 6:21 AM, Matt wrote:

> Hi folks,
>
> I think i''m missing something obvious here.  I''m trying
to search/
> replace multiple times in n files but I keep hitting a
> ''ArgumentError: Duplicate definition'' or similar in any
method I try
> and do it in.
>
> I guess this is because i''m using ${name} to edit the multiple
> files, but as far as I can tell, i''m unable to use another type of
> array. i.e. if I do:
>
> define dnstext ($cwd, $dnstext) {
>         exec {$name:
>                 cwd     => $cwd,
>                 path    => ["/bin"],
>                 command => "sed -i
''s/$rtext/$stext/'' ./${name}",
>         }
>
> }
>
> dnstext { $myfiles:
>       cwd     => "/opt",
>       stext => "replacethis",
>       rtext => "withthis",
> }
>
> that works, but if I try and do another one:
>
> dnstext { $myfiles:
>       cwd     => "/opt",
>       stext => "replacethis",
>       rtext => "withthis",
> }

Each instance of a defined resource, like each instance of builtin
resources, needs a unique name.  I recommend refactoring your
definition to support this.

--
A conservative is a man who believes that nothing should be done for
the first time. --Alfred E. Wiggam
---------------------------------------------------------------------
Luke Kanies | http://reductivelabs.com | http://madstop.com


--~--~---------~--~----~------------~-------~--~----~
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+unsubscribe@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/puppet-users?hl=en
-~----------~----~----~----~------~----~------~--~---