Thanks for all your answers and suggestions. So, what happens is that I want to push a file from the master to a client. But the problem is that after starting the service that reads that file, it appends one line to it, which is an authorization token.
Like this: #1 file is pushed from the master to the client: line1 line2 #2 the service starts on the client for the first time and it appends the new line (line3): line1 line2 line3 #3 if I restart puppet the file will be changed to: line1 line2 #4 the service stops working because the line 3 (authorization token) is gone. I'd really like to manage all lines in that file but the one that is added after the service is started. I hope is clear now. Bruno On Mar 16, 2:02 pm, jcbollinger <john.bollin...@stjude.org> wrote: > On Mar 15, 7:24 am, Gamon <bruno.pessa...@gmail.com> wrote: > > > I'd like to have a template that would contain: > > > line1 <%= value1 %> > > line2 <%= value2 %> > > line3 <%= value3 %> > > > But the template should ignore line2 for example if that already > > exists. Something like greping for line2 and if that exists, keep the > > original line. > > What you request is not possible, though a similar effect can probably > be achieved. Puppet templates are processed on the master to produce > a single file, then that whole file is transported to wherever the > manifest says it should go. There is no way to after the fact adapt > it to whatever file may be in the target location already. > > On the other hand, you can determine in advance what is in the target > file and communicate it to Puppet via a custom fact. Then your > template can use the fact value to create whatever the output is that > you want. > > Overall, however, what you are asking runs against Puppet's grain. > Why shouldn't Puppet know in advance whether line2 should be present, > and if so, what it should contain? It is usually better to tell > Puppet how a node should be configured than to try to make it adapt to > how the node is already configured. If you're talking about managing > a file that is also dynamically modified by some other agent then you > are asking for trouble. > > This whole discussion has been rather abstract, however. If you can > be more specific about what you want to do then we may be able to > offer better advice and / or alternatives. > > John -- 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+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/puppet-users?hl=en.