See the following:

https://github.com/puppetlabs/puppetlabs-stdlib/tree/master/lib/puppet/provider/file_line

On Mar 16, 6:02 am, 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.

Reply via email to