Commit graph

10 commits

Author SHA1 Message Date
Chris Price
9e0256aabf Add support for a 'match' parameter to file_line
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.
2012-06-07 09:09:14 -07:00
Peter Meier
f0a62c7dba fix regression in #11017 properly
We need the defaultvalues for that.
2012-05-23 08:17:57 +02:00
Jeff McCune
1373e70639 Make file_line default to ensure => present
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.
2012-05-10 22:04:58 -07:00
Peter Meier
fc5cfc8cca implement #11017 - make file_line type ensurable
* 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.
2012-02-09 15:56:09 +01:00
nfagerlund
8e770b0423 Docs: Clarify the use case for the anchor type
This commit tweaks the docs for the anchor resource type to give more context
for its existence.
2011-08-18 12:39:05 -07:00
Jeff McCune
0594aa9141 Docs: Update file_line documentation
This commit clarifies the behavior of the file_line resource type.
2011-08-18 12:39:04 -07:00
Jeff McCune
4c93090e1a (#8792) Rename whole_line type to file_line
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.
2011-08-04 19:17:48 -07:00
Dan Bode
4540949d96 (#8665) Change type from append_line to whole_line
Changed the type name from append_line to
whole_line.

After feedback that having a type with a verb in
the name was confusing.
2011-07-27 15:28:44 -07:00
Dan Bode
e82370a26d (#8628) Add append_line native type
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
2011-07-26 15:30:28 -07:00
Jeff McCune
ab70663d15 (#3) Add an anchor type to provide containment
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': }
2011-06-15 09:40:04 -07:00