diff options
author | Bryan Jen <bryan.jen@gmail.com> | 2015-08-13 10:14:13 -0700 |
---|---|---|
committer | Bryan Jen <bryan.jen@gmail.com> | 2015-08-13 10:14:13 -0700 |
commit | e84090df1d081679e0c687614efb982354cf3cbe (patch) | |
tree | 87fab8db19e9dcec2bcf64bedfb35c5fc1ccc437 /lib/puppet/type | |
parent | 605fffd852e972a2df76be1b051d3b4a5f740bd5 (diff) | |
parent | 9bacf14ca24283a94883523064603babcd7046d3 (diff) | |
download | puppet-stdlib-e84090df1d081679e0c687614efb982354cf3cbe.tar.gz puppet-stdlib-e84090df1d081679e0c687614efb982354cf3cbe.tar.bz2 |
Merge pull request #499 from jearls/2370-use-match-for-ensure-absent
[MODULES-2370] allow `match` parameter to influence `ensure => absent` behavior.
Diffstat (limited to 'lib/puppet/type')
-rw-r--r-- | lib/puppet/type/file_line.rb | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/lib/puppet/type/file_line.rb b/lib/puppet/type/file_line.rb index 4a96ba7..446f103 100644 --- a/lib/puppet/type/file_line.rb +++ b/lib/puppet/type/file_line.rb @@ -34,6 +34,20 @@ Puppet::Type.newtype(:file_line) do In this code example match will look for a line beginning with export followed by HTTP_PROXY and replace it with the value in line. + Match Example With `ensure => absent`: + + file_line { 'bashrc_proxy': + ensure => absent, + path => '/etc/bashrc', + line => 'export HTTP_PROXY=http://squid.puppetlabs.vm:3128', + match => '^export\ HTTP_PROXY\=', + match_for_absence => true, + } + + In this code example match will look for a line beginning with export + followed by HTTP_PROXY and delete it. If multiple lines match, an + error will be raised unless the `multiple => true` parameter is set. + **Autorequires:** If Puppet is managing the file that will contain the line being managed, the file_line resource will autorequire that file. @@ -55,6 +69,14 @@ Puppet::Type.newtype(:file_line) do ' match an exception will be raised. ' end + newparam(:match_for_absence) do + desc 'An optional value to determine if match should be applied when ensure => absent.' + + ' If set to true and match is set, the line that matches match will be deleted.' + + ' If set to false (the default), match is ignored when ensure => absent.' + newvalues(true, false) + defaultto false + end + newparam(:multiple) do desc 'An optional value to determine if match can change multiple lines.' + ' If set to false, an exception will be raised if more than one line matches' |