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.
The examples in the file_line resource documentation state the following
resource should work:
file_line { 'sudo_rule':
path => '/etc/sudoers',
line => '%sudo ALL=(ALL) ALL',
}
Without this patch the example does not work because ensure is not set
to present.
This patch fixes the problem by setting the default value of ensure to
present.
* 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.
This commit adds a native type that can check if
a line exists and append it to a file.
This use case seems common enough to warrant its
inclusion into stdlib.
Reviewed-by: Jeff McCune
With Puppet 2.6.x we do not have a way to specify containment
relationships. In the use case of class ntp { } declaring
ntp::{package,config,service} classes, the ntp class itself should allow
the user to specify before and require relationships to the main ntp
class.
The anchor resource type allows module authors to close the loop on
classes composing the main top level module. For example:
class ntp {
class { 'ntp::package': }
-> class { 'ntp::config': }
-> class { 'ntp::service': }
# These two resources "anchor" the composed classes
# such that the end user may use "require" and "before"
# relationships with Class['ntp']
anchor { 'ntp::begin': } -> class { 'ntp::package': }
class { 'ntp::service': } -> anchor { 'ntp::end': }
}
Using this pattern, the module user may then simply declare relationships to
the ntp class as they expect:
class { 'ntp': } -> class { 'mcollective': }
# OR
class { 'mcollective': } -> class { 'ntp': }