On Fri, May 21, 2010 at 6:08 PM, Daniel Pittman <dan...@rimspace.net> wrote:
> Marley Bacelar <marleybace...@gmail.com> writes: > > > I need to replace some text in a file... there is some type, that i can > pass > > a value and to be replace and the destination file? > > I know this sounds like a great idea, but decades of experience with puppet > and proceeding tools tell us that editing the content of files is very, > very > hard to get right. > > You would almost certainly be better off copying the right file content > into > place, so that you don't have the extra complexity. > > > As an alternative, building the file from fragments with one of the > 'concatenated files' classes is a pretty sound idea; it makes it easy have > variable sections inside the file without needing to edit-in-place. > > > or anyone here have some class who does that? > > There are a couple in the common module collections; check out the wiki for > the links off to 'em. Their current state may have changed since I last > looked, so I don't have a specific recommendation for you. > > Daniel > > Y'see, I learned that lesson way back when cfengine provided really good > tools > for doing this sort of editing, and it *always* tool much longer and was > much > less robust than I expected... > > The vast majority of our text replacement work we do is for files that have simple key/value pairs with an assignment operator. foo=bar foo: bar etc. We occasionally stray outside this with a regexp replacer, but I totally agree with Daniel here, it's not the most robust thing in the world. Generally we do this because we want to allow people to customize extra parts of their config files, and we've switched daemons entirely for some services, simply based upon their ability to cope with a parts.d directory or to have "include" directives of some kind. That allows you to ship an absolute config with a default include that people are free to modify. -- 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.