Paul,
You're correct, I did indeed fall in to thinking that defines act similar to
functions. I wanted to create a generic definition that basically did a
linux 'sed', but the only way I could do it with an array of files was by
using the $name array. I was having issues with this as I had multiple
execs in the define, but i'd just called them exec { "$name...
So that was my issue. I'm a bit blurred on when puppet iterates through an
array and when it concatanates the array. Does it only iterate through $name
on defines?
Thanks,
Matt
2008/10/14 Paul Lathrop <[EMAIL PROTECTED]>
>
> Matt,
>
> From the terminology you are using, you seem to have fallen into the
> trap of thinking of defines as functions which you call. I highly
> recommend you avoid this; it leads you to certain mistaken assumptions
> about how defines work.
>
> From your description I am having difficulty understanding what you
> are trying to accomplish. Can you provide some specific details? You
> are trying to perform a search/replace on multiple files in a single
> resource?
>
> With those questions answered I might be able to help.
>
> --Paul
>
> On Mon, Oct 13, 2008 at 5:17 AM, Matt <[EMAIL PROTECTED]> wrote:
> > Hi Pete,
> >
> > I tried that with $myfiles as an array, but as I said, that just executed
> > the sed command with all of the filenames concatanated.
> >
> > I've got a fix at the moment. I've just prefixed multiple execs in the
> > define method with something unique. Its working, but just feels like
> there
> > would be a better way to do this.
> >
> > My code at the moment is:
> >
> > define searchreplace ( $cwd, $stext, $rtext, $sstext, $rrtext, $ssstext,
> > $rrrtext ) {
> > exec {"dns_$name":
> > cwd => $cwd,
> > path => ["/bin"],
> > command => "sed -i 's/$stext/$rtext/' ./${name}",
> > }
> > exec {"tag_$name":
> > cwd => $cwd,
> > path => ["/bin"],
> > command => "sed -i 's/$sstext/$rrtext/' ./${name}",
> > }
> > exec {"ray_$name":
> > cwd => $cwd,
> > path => ["/bin"],
> > command => "sed -i 's/$ssstext/$rrrtext/' ./${name}",
> > }
> > }
> >
> > searchreplace {$bfprocesses :
> > cwd => "/home",
> > stext => "replacethis",
> > rtext => $dns,
> > sstext => "replacethis2",
> > rrtext => $tag,
> > ssstext => "replacethis3",
> > rrrtext => $ray,
> >
> > }
> > }
> >
> >
> > It works - just wondering if there was a simpler way.
> >
> > Cheers,
> >
> > Matt
> >
> > 2008/10/13 Peter Meier <[EMAIL PROTECTED]>
> >>
> >> Hi
> >>
> >> > But that executed the sed command with all of the files as input.
> >> >
> >> > I also tried with a general define searchreplace method but i'm only
> >> > able to
> >> > call it once in a class with the $name due to the $name method again.
> >> >
> >> > Is it possible to get puppet to iterate a definition other than using
> >> > the
> >> > $name method?
> >>
> >>
> >> use something else than $name as filename. because $name have to be
> >> unique.
> >>
> >> greets pete
> >>
> >>
> >
> >
> > >
> >
>
> >
>
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Puppet Users" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/puppet-users?hl=en
-~----------~----~----~----~------~----~------~--~---