Age | Commit message (Collapse) | Author |
|
This reverts commit 8499ebdb7f892f2623295058649c67a5553d4732, reversing
changes made to 08b00d9229961d7b3c3cba997bfb35c8d47e4c4b.
|
|
file_line supports adding lines after a match, but there are use cases when
having "before" would be useful. For example, in Debian-based OS's, the last
line of /etc/rc.local is "exit 0" it's an incredible pain to deal with
that scenario today.
This commit adds a 'before' parameter to the file_line type, and implements
it for the ruby provider.
|
|
Without this patch the implementation of the file_line provider is a bit
convoluted with respect to the newly introduced "after" parameter.
This patch addresses the problem by separating out the concerns of each
case into their own methods of handling the behavior with the match
parameter, handling the behavior with the after parameter, or simply
appending the line.
|
|
When adding new lines to a file the 'after' option can be useful
when you need to insert file lines into the middle of a file.
This is particularly helpful when using file_line with sectioned
config files.
NOTE: the after option only works when adding new lines. If you are
updating an existing (matched) line it will simply modify it in place.
This assumes it was in the right place to begin with.
|
|
Without this commit the file_line type will outright fail if multiple
lines match the given regex. This commit allows the file_line type and
provider to optionally match and modify all matching lines.
Changeset rebased into a single commit by Adrien Thebo <adrien@puppetlabs.com>
|
|
|
|
This commit adds a new parameter called "match"
to the file_line resource type, and support for
this new parameter to the corresponding ruby
provider.
This parameter is optional; file_line should work
just as before if you do not specify this parameter...
so this change should be backwards-compatible.
If you do specify the parameter, it is treated
as a regular expression that should be used when
looking through the file for a line. This allows
you to do things like find a line that begins with
a certain prefix (e.g., "foo=.*"), and *replace*
the existing line with the line you specify in your
"line" parameter. Without this capability, if you
already had a line "foo=bar" in your file and your
"line" parameter was set to "foo=baz", you'd end up
with *both* lines in the final file. In many cases
this is undesirable.
|
|
* Implement a simple destroy method.
* Add tests for it
* Refactor code, so file is actually read only once. However, due
to the nature how provider tests are run, we need to ensure that
the file is read before we open it to write it.
|
|
Without this patch the resource whole_line would be included in the
stable stdlib module shipping in PE 1.2. Ideally the name will be
stable and unchanging in the future.
There was quite a bit of concern over whole_line being an unwise name.
file_line appears to be the most suitable name and least likely to need
another rename in the future.
|