summaryrefslogtreecommitdiff
path: root/lib/puppet/type/file_line.rb
diff options
context:
space:
mode:
authorTP Honey <tphoney@users.noreply.github.com>2017-10-02 10:27:40 +0100
committerGitHub <noreply@github.com>2017-10-02 10:27:40 +0100
commit2339ea8db67ac7ef02d707c2a6011ae50f5d82b5 (patch)
tree4b601143c1d4e665e8a715596bfb5fbd87f17801 /lib/puppet/type/file_line.rb
parent2b2b3870ec1737dc78ec402c2dccbb7b65a2ef8f (diff)
parentad5d92461596d8d0b1c001d49061d70b36761d59 (diff)
Merge pull request #820 from alexharv074/maint_clarify_docs
(maint) Clarify docs and add new tests
Diffstat (limited to 'lib/puppet/type/file_line.rb')
-rw-r--r--lib/puppet/type/file_line.rb24
1 files changed, 22 insertions, 2 deletions
diff --git a/lib/puppet/type/file_line.rb b/lib/puppet/type/file_line.rb
index b2357b8..06be552 100644
--- a/lib/puppet/type/file_line.rb
+++ b/lib/puppet/type/file_line.rb
@@ -34,12 +34,16 @@ 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`:
+ Examples With `ensure => absent`:
+
+ This type has two behaviors when `ensure => absent` is set.
+
+ One possibility is to set `match => ...` and `match_for_absence => true`,
+ as in the following example:
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,
}
@@ -48,6 +52,22 @@ Puppet::Type.newtype(:file_line) do
followed by HTTP_PROXY and delete it. If multiple lines match, an
error will be raised unless the `multiple => true` parameter is set.
+ Note that the `line => ...` parameter would be accepted BUT IGNORED in
+ the above example.
+
+ The second way of using `ensure => absent` is to specify a `line => ...`,
+ and no match:
+
+ file_line { 'bashrc_proxy':
+ ensure => absent,
+ path => '/etc/bashrc',
+ line => 'export HTTP_PROXY=http://squid.puppetlabs.vm:3128',
+ }
+
+ Note that when ensuring lines are absent this way, the default behavior
+ this time is to always remove all lines matching, and this behavior
+ can't be disabled.
+
Encoding example:
file_line { "XScreenSaver":