On Friday, January 18, 2013 10:08:49 AM UTC-6, iamauser wrote: > > Hi John, > > Thanks for the reply. Your corrections made it work. As you pointed out > about the implementation of this code. I wrote it keeping in mind 'def' of > ruby where one can return a value evaluating a block. Syntactically it > didn't have a problem with Ruby, but it failed to return a value in > puppet's case. > > I am trying to implement this code to check pattern in a file, e.g. > (/etc/fstab) before puppet tries to edit it. In other words, trying to find > an equivalent of "BeginGroupIfNoLineContaining" of cfengine. This may not > be the best method though. > > Not only is it not the best method, it is not a viable method. Puppet functions are evaluated on the master, with no visibility on client details other than anything passed as arguments. You need something that runs on the client.
You might want to look into augeas for editing the file. Alternatively, it would be closer to your current design to implement and use a custom fact. If you are modifying the file via an Exec, then use grep in its 'onlyif' or 'unless' parameter. There are other alternatives, too. John -- You received this message because you are subscribed to the Google Groups "Puppet Users" group. To view this discussion on the web visit https://groups.google.com/d/msg/puppet-users/-/odHP-E72V44J. 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.
