From 7e408ca7970fd172822db02227935798f9ff282f Mon Sep 17 00:00:00 2001 From: Johnson Earls Date: Mon, 28 Mar 2016 20:59:27 +0000 Subject: [MODULES-2370] file_line.rb: Fix `line` attribute validation `file_line` type: During validation, do not require `line` attribute if: * `ensure` is `absent`, * `match` is not empty, * and `match_for_absence` is `true`. Also update `spec` tests to reflect this. --- lib/puppet/type/file_line.rb | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) (limited to 'lib/puppet/type/file_line.rb') diff --git a/lib/puppet/type/file_line.rb b/lib/puppet/type/file_line.rb index 77d3be2..f2c6937 100644 --- a/lib/puppet/type/file_line.rb +++ b/lib/puppet/type/file_line.rb @@ -111,8 +111,13 @@ Puppet::Type.newtype(:file_line) do end validate do - unless self[:line] and self[:path] - raise(Puppet::Error, "Both line and path are required attributes") + unless self[:line] + unless (self[:ensure].to_s == 'absent') and (self[:match_for_absence].to_s == 'true') and self[:match] + raise(Puppet::Error, "line is a required attribute") + end + end + unless self[:path] + raise(Puppet::Error, "path is a required attribute") end end end -- cgit v1.2.3