summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorAdrien Thebo <git@somethingsinistral.net>2013-07-11 16:26:45 -0700
committerAdrien Thebo <git@somethingsinistral.net>2013-07-11 16:26:45 -0700
commite0d4588bd2470109bd1eea4e597f1d205bf01b52 (patch)
tree07e1aae2e2028fd0b0d50f999a5cab3ddf02704c /lib
parent4d2558f383e18bbe322dd0feb073555491216ab4 (diff)
parent964a9ad6193b0dd243a44ddae1509655fc9e9fb8 (diff)
downloadpuppet-stdlib-e0d4588bd2470109bd1eea4e597f1d205bf01b52.tar.gz
puppet-stdlib-e0d4588bd2470109bd1eea4e597f1d205bf01b52.tar.bz2
Merge branch 'pull-163'
This closes GH-163
Diffstat (limited to 'lib')
-rw-r--r--lib/puppet/provider/file_line/ruby.rb5
-rw-r--r--lib/puppet/type/file_line.rb5
2 files changed, 7 insertions, 3 deletions
diff --git a/lib/puppet/provider/file_line/ruby.rb b/lib/puppet/provider/file_line/ruby.rb
index a3219d3..3cb9f6e 100644
--- a/lib/puppet/provider/file_line/ruby.rb
+++ b/lib/puppet/provider/file_line/ruby.rb
@@ -1,4 +1,3 @@
-
Puppet::Type.type(:file_line).provide(:ruby) do
def exists?
@@ -35,8 +34,8 @@ Puppet::Type.type(:file_line).provide(:ruby) do
def handle_create_with_match()
regex = resource[:match] ? Regexp.new(resource[:match]) : nil
match_count = lines.select { |l| regex.match(l) }.size
- if match_count > 1
- raise Puppet::Error, "More than one line in file '#{resource[:path]}' matches pattern '#{resource[:match]}'"
+ if match_count > 1 && resource[:multiple].to_s != 'true'
+ raise Puppet::Error, "More than one line in file '#{resource[:path]}' matches pattern '#{resource[:match]}'"
end
File.open(resource[:path], 'w') do |fh|
lines.each do |l|
diff --git a/lib/puppet/type/file_line.rb b/lib/puppet/type/file_line.rb
index f71a4bc..14946bb 100644
--- a/lib/puppet/type/file_line.rb
+++ b/lib/puppet/type/file_line.rb
@@ -37,6 +37,11 @@ Puppet::Type.newtype(:file_line) do
'if a match is found, we replace that line rather than adding a new line.'
end
+ newparam(:multiple) do
+ desc 'An optional value to determine if match can change multiple lines.'
+ newvalues(true, false)
+ end
+
newparam(:line) do
desc 'The line to be appended to the file located by the path parameter.'
end