On Monday, May 6, 2013 2:55:33 AM UTC-5, Paul Tötterman wrote:Hi,
On Sunday, May 5, 2013 2:25:02 AM UTC+3, Schofield wrote:
I'm hoping a commonly used module that provides a resource for managing
multiple contiguous lines in a file already exists and someone can point me
to it. I want something like the file_line type in the puppet labs stdlib
module but have it check multiple lines instead of just one.
Have you looked at using templates? If not, then do that first. In case
templates don't work out, maybe the concat module does:
https://github.com/ripienaar/puppet-concat Indeed, templates and Concat, either individually or in combination, are
great tools for managing files, including where responsibility for
different pieces of the file is spread across multiple classes.
Unfortunately, none of that is really analogous to Stdlib::File_line, which
manages *just* one line in a file, without managing the rest of the file's
content. That's a pretty strange thing to do in the Puppet scheme of
things, actually, but I suppose it can be useful.
I am not aware of any existing, publicly available module providing a type
that manages blocks of lines in a manner analogous to Stdlib::File_line.
There are several possible approaches that might work instead, depending on
the details of the problem, among them:
- Manage the whole file (best, if it is feasible). Templates and/or
Concat fit right into this.
- Put everything on one line and manage it via Stdlib::File_line. That
assumes the line breaks are optional (or can be replaced with something
else), which is often true, but not always.
- Put the managed content in a separate, wholly-managed file, and
include it into the target via a target-specific inclusion feature. For
instance, some configuration file languages have an 'include' statement
that interpolates external files (much like the C preprocessor's #include
directive). Better, some programs automatically read all files from a
given directory.
If none of those are suitable then it's a very unusual case; the best
available option may then be to build what you need yourself.
John