From 221277e8522b42bf170fded6ea23dfc526703b07 Mon Sep 17 00:00:00 2001 From: Dan Prince Date: Thu, 29 Aug 2013 12:19:16 -0400 Subject: Update file_line resource to support 'after'. When adding new lines to a file the 'after' option can be useful when you need to insert file lines into the middle of a file. This is particularly helpful when using file_line with sectioned config files. NOTE: the after option only works when adding new lines. If you are updating an existing (matched) line it will simply modify it in place. This assumes it was in the right place to begin with. --- lib/puppet/type/file_line.rb | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'lib/puppet/type') diff --git a/lib/puppet/type/file_line.rb b/lib/puppet/type/file_line.rb index 14946bb..323fc4c 100644 --- a/lib/puppet/type/file_line.rb +++ b/lib/puppet/type/file_line.rb @@ -42,6 +42,10 @@ Puppet::Type.newtype(:file_line) do newvalues(true, false) end + newparam(:after) do + desc 'An optional value used to specify the line after which we will add any new lines. (Existing lines are added in place)' + end + newparam(:line) do desc 'The line to be appended to the file located by the path parameter.' end -- cgit v1.2.3 From 6eaa592cd8d5af097a4624b3d1cead74408aabf2 Mon Sep 17 00:00:00 2001 From: Stephen Benjamin Date: Wed, 14 May 2014 20:33:57 +0200 Subject: (PUP-2571) add 'before' functionality to file_line file_line supports adding lines after a match, but there are use cases when having "before" would be useful. For example, in Debian-based OS's, the last line of /etc/rc.local is "exit 0" it's an incredible pain to deal with that scenario today. This commit adds a 'before' parameter to the file_line type, and implements it for the ruby provider. --- lib/puppet/type/file_line.rb | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'lib/puppet/type') diff --git a/lib/puppet/type/file_line.rb b/lib/puppet/type/file_line.rb index 323fc4c..bc6745f 100644 --- a/lib/puppet/type/file_line.rb +++ b/lib/puppet/type/file_line.rb @@ -46,6 +46,10 @@ Puppet::Type.newtype(:file_line) do desc 'An optional value used to specify the line after which we will add any new lines. (Existing lines are added in place)' end + newparam(:before) do + desc 'An optional value used to specify the line before which we will add any new lines. (Existing lines are added in place)' + end + newparam(:line) do desc 'The line to be appended to the file located by the path parameter.' end -- cgit v1.2.3 From c5b06f9bbca7acc491560c92a73d7e2a153fe0a7 Mon Sep 17 00:00:00 2001 From: Ashley Penney Date: Thu, 15 May 2014 17:28:59 -0400 Subject: Revert "Merge pull request #256 from stbenjam/2571-before" This reverts commit 8499ebdb7f892f2623295058649c67a5553d4732, reversing changes made to 08b00d9229961d7b3c3cba997bfb35c8d47e4c4b. --- lib/puppet/type/file_line.rb | 4 ---- 1 file changed, 4 deletions(-) (limited to 'lib/puppet/type') diff --git a/lib/puppet/type/file_line.rb b/lib/puppet/type/file_line.rb index bc6745f..323fc4c 100644 --- a/lib/puppet/type/file_line.rb +++ b/lib/puppet/type/file_line.rb @@ -46,10 +46,6 @@ Puppet::Type.newtype(:file_line) do desc 'An optional value used to specify the line after which we will add any new lines. (Existing lines are added in place)' end - newparam(:before) do - desc 'An optional value used to specify the line before which we will add any new lines. (Existing lines are added in place)' - end - newparam(:line) do desc 'The line to be appended to the file located by the path parameter.' end -- cgit v1.2.3 From 9fd13be825aa0133156016c078b99e0e471fc737 Mon Sep 17 00:00:00 2001 From: Thomas Linkin Date: Wed, 16 Jul 2014 11:39:23 -0400 Subject: (MODULES-1221) Add file_line autorequire documentation This commit adds additional documentation to the file_line resource explaining how it will autorequire file resources when present. --- lib/puppet/type/file_line.rb | 3 +++ 1 file changed, 3 insertions(+) (limited to 'lib/puppet/type') diff --git a/lib/puppet/type/file_line.rb b/lib/puppet/type/file_line.rb index 323fc4c..9dbe43c 100644 --- a/lib/puppet/type/file_line.rb +++ b/lib/puppet/type/file_line.rb @@ -21,6 +21,9 @@ Puppet::Type.newtype(:file_line) do In this example, Puppet will ensure both of the specified lines are contained in the file /etc/sudoers. + **Autorequires:** If Puppet is managing the file that will contain the line + being managed, the file_line resource will autorequire that file. + EOT ensurable do -- cgit v1.2.3 From c6c203fca8da81fea96659bfe9618bb31965b837 Mon Sep 17 00:00:00 2001 From: Hunter Haugen Date: Tue, 16 Dec 2014 11:48:46 -0800 Subject: Remove line match validation The `match` attribute was validated to match `line`, except that in many cases (even the example given in the docs) a user would want to match a line entirely different from the new line. See comments on the original commit https://github.com/puppetlabs/puppetlabs-stdlib/commit/a06c0d8115892a74666676b50d4282df9850a119 and ask https://ask.puppetlabs.com/question/14366/file_line-resource-match-problems/ for further examples of confusion. --- lib/puppet/type/file_line.rb | 7 ------- 1 file changed, 7 deletions(-) (limited to 'lib/puppet/type') diff --git a/lib/puppet/type/file_line.rb b/lib/puppet/type/file_line.rb index 9dbe43c..df263e6 100644 --- a/lib/puppet/type/file_line.rb +++ b/lib/puppet/type/file_line.rb @@ -71,12 +71,5 @@ Puppet::Type.newtype(:file_line) do unless self[:line] and self[:path] raise(Puppet::Error, "Both line and path are required attributes") end - - if (self[:match]) - unless Regexp.new(self[:match]).match(self[:line]) - raise(Puppet::Error, "When providing a 'match' parameter, the value must be a regex that matches against the value of your 'line' parameter") - end - end - end end -- cgit v1.2.3