Code Monkey home page Code Monkey logo

line's Introduction

line cookbook

Cookbook Version CI State OpenCollective OpenCollective License

Maintainers

This cookbook is maintained by the Sous Chefs. The Sous Chefs are a community of Chef cookbook maintainers working together to maintain important cookbooks. If you’d like to know more please visit sous-chefs.org or come chat with us on the Chef Community Slack in #sous-chefs.

Motivation

Quite often, the need arises to do line editing instead of managing an entire file with a template resource. This cookbook supplies various resources that will help you do this.

Limitations

  • The line resources processes the entire target file in memory. Trying to edit large files may fail.

  • The end of line processing was only tested using \n and \r\n. Using other line endings very well may not work.

  • The end of line string used needs to match the actual end of line used in the file \n and \r\n are used as the defaults but if they don't match the actual end of line used in the file the results will be weird.

  • Adding a line implies there is a separator on the previous line. Adding a line differs from appending characters.

  • Lines to be added should not contain EOL characters. The providers do not do multiline regex checks.

  • Missing file processing is the way it is by intention

    • add_to_list do nothing, list not found so there is nothing to add to.
    • append_if_no_line create file, add the line.
    • delete_from_list do nothing, the list was not found which implies there is nothing to delete
    • delete_lines do nothing, the line isn't there which implies there is nothing to delete
    • replace_or_add create file, add the line
    • filter_lines create file if the file changes
  • Chef client version 13 or greater is expected.

Resources

For more detailed information see the matching resource documentation:

Sample filters

  • after: Insert lines after a matched line
  • before: Insert lines before a matched lined
  • between: Insert lines between matched lines
  • comment: Change lines to comments
  • delete_between: Delete the lines found between two patterns
  • missing: Add missing lines to a file
  • replace: Replace each instance of matched lines
  • replace_between: Replace lines between matched lines
  • stanza: Insert or change keys in files formatted in stanzas
  • substitute: Substitute text in lines matching a pattern

Authors

  • Contributor: Mark Gibbons
  • Contributor: Dan Webb
  • Contributor: Sean OMeara
  • Contributor: Antek S. Baranski

Contributors

This project exists thanks to all the people who contribute.

Backers

Thank you to all our backers!

https://opencollective.com/sous-chefs#backers

Sponsors

Support this project by becoming a sponsor. Your logo will show up here with a link to your website.

https://opencollective.com/sous-chefs/sponsor/0/website https://opencollective.com/sous-chefs/sponsor/1/website https://opencollective.com/sous-chefs/sponsor/2/website https://opencollective.com/sous-chefs/sponsor/3/website https://opencollective.com/sous-chefs/sponsor/4/website https://opencollective.com/sous-chefs/sponsor/5/website https://opencollective.com/sous-chefs/sponsor/6/website https://opencollective.com/sous-chefs/sponsor/7/website https://opencollective.com/sous-chefs/sponsor/8/website https://opencollective.com/sous-chefs/sponsor/9/website

line's People

Contributors

axelrtgs avatar calston avatar ccrebolder avatar chazzly avatar chilicheech avatar clockwerx avatar damacus avatar dayne avatar hulu1522 avatar jasonwbarnett avatar jblaine avatar johnroesler avatar kitchen-porter avatar kitforbes avatar lamont-granquist avatar markgibbons avatar mbaitelman avatar pludi avatar powerschill avatar ramereth avatar renovate[bot] avatar sauraus avatar sekrett avatar someara avatar tas50 avatar therek3r avatar vinyar avatar wabri avatar xorima avatar xorimabot avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

line's Issues

replace_or_add failing on XML document

I am using this resource on a machine. It will find the line it needs on the first run and replaces it correctly. Every run after that fails because it can't detect that the line was already replaces so it appends it to the end of the document.

CODE:

replace_or_add "sso crowd auth" do
  path "#{node["confluence"]["install_dir"]}/confluence/confluence/WEB-INF/classes/seraph-config.xml"
  pattern %Q[<!-- <authenticator class="com.atlassian.confluence.user.ConfluenceCrowdSSOAuthenticator"/> -->]
  line %Q[<authenticator class="com.atlassian.confluence.user.ConfluenceCrowdSSOAuthenticator"/>]
  notifies :restart, "service[#{service_name}]", :delayed
end

DEBUG OUTPUT:

* replace_or_add[sso crowd auth] action edit[2015-05-15T20:30:39+00:00] INFO: Processing replace_or_add[sso crowd auth] action edit (tcn_atlassian::confluence line 112)
[2015-05-15T20:30:39+00:00] DEBUG: providers for generic replace_or_add resource enabled on node include: []
[2015-05-15T20:30:39+00:00] DEBUG: providers that refused resource replace_or_add[sso crowd auth] were: []
[2015-05-15T20:30:39+00:00] DEBUG: providers that support resource replace_or_add[sso crowd auth] include: []
[2015-05-15T20:30:39+00:00] DEBUG: no providers supported the resource, falling back to enabled handlers
[2015-05-15T20:30:39+00:00] DEBUG: providers that survived replacement include: []
[2015-05-15T20:30:39+00:00] DEBUG: dynamic provider resolver FAILED to resolve a provider

Is there any reason why it is not finding the line and reporting it as "up to date"?

rename repo to simply `line`

To be like the other cookbooks in sous-chefs, we should change the name of this repo to line.

I can't remember all the places we'd want to change references, and how friendly github is about redirections.

Would we just want to update the link in the readme and the metadata? Anywhere else?

WARN: This will no longer work in Chef 13

Not sure when this started, but some time since we started using the Chef 12 client, our usage of the Line cookbook as started to emit the following warning:

WARN: Class Chef::Provider::AppendIfNoLine does not declare 'resource_name :append_if_no_line'.
WARN: This will no longer work in Chef 13: you must use 'resource_name' to provide DSL.

We are seeing the same warning on replace_or_add as well. Likely occurs elsewhere but these are the only two Line resources that we are using.

undefined method 'filter'

Cookbook version

2.2.0

Chef-client version

14.10.9

Platform Details

RedHat 7

Scenario:

Run basic filter_lines

Steps to Reproduce:

depends 'line' # put in metadata.rb
RECIPE:
content = <<~EOF
export var=EXAMPLE
EOF
match_pattern = /System wide functions and aliases/
filter_lines 'insert var' do
path '/etc/bashrc'
filter after: [match_pattern, content]
end

Expected Result:

Success

Actual Result:

NoMethodError: undefined method 'filter' for Custom resource line_filter_files from cookbook line

Line added repeatedly

Cookbook version

2

Chef-client version

Any

Platform Details

Ubuntu, Windows

Scenario:

Append a line (also replace a line). Try to do it once. With the right pattern the line is inserted repeatedly. Newlines in the append line pattern won't work. Line does not support appending multiple lines.

Steps to Reproduce:

Specify append_if_no_line where the line is:
"text\n"

append_if_no_line file do
line "text\n"
end

Expected Result:

Insert the line once or blow up.

Actual Result:

The line is appended with every execution of the resource.

ReplaceOrAdd does not declare 'provides :replace_or_add'.

WARN: Class Chef::Provider::ReplaceOrAdd does not declare 'provides :replace_or_add'.
This will no longer work in Chef 13: you must use 'provides' to use the resource's DSL.

If I get a chance I will try and do some work to remove this one.

Release 2.0

We need a warning in the changelog about the possible breaking changes.

undefined method `close' for nil:NilClass

Seeing this on latest cookbook version.

           System Info:
           ------------
           chef_version=13.2.20
           platform=centos
           platform_version=6.8
           ruby=ruby 2.4.1p111 (2017-03-22 revision 58053) [x86_64-linux]
           program_name=chef-solo worker: ppid=4737;start=13:16:55;
           executable=/opt/chef/bin/chef-solo
             ================================================================================
             Error executing action `edit` on resource 'delete_lines[remove test from /tmp/test]'
             ================================================================================

             NoMethodError
             -------------
             undefined method `close' for nil:NilClass

             Cookbook Trace:
             ---------------
             /tmp/kitchen/cache/cookbooks/line/resources/delete_lines.rb:41:in `ensure in block in class_from_file'
             /tmp/kitchen/cache/cookbooks/line/resources/delete_lines.rb:42:in `block in class_from_file'

Tag the 1.0.4 release in Git

I've just noticed that Supermarket sees a version 1.0.4 of this cookbook, but it's not showing in Git, would it be possible to get the commit that was used to build that version tagged? This will help checking diffs between versions. Thanks!

Dollar Sign

I'd like to append the following 3 lines to my bashrc with the 'append_if_no_line' resource......

export WORKON_HOME=$HOME/.virtualenvs
export PROJECT_HOME=$HOME/Devel
source /usr/local/bin/virtualenvwrapper.sh

However, on subsequent chef runs, the lines with dollar signs are continually appended.

Handle missing file consistently across the providers.

I want to include this change in the 2.0.0 release.

Proposed behavior if missing file
add_to_list.rb -> do nothing, list not found to add to
append_if_no_line.rb -> create file, add line
delete_from_list.rb -> do nothing, list not found implies nothing to delete
delete_lines.rb -> do nothing, line isn’t there implies nothing to delete
replace_or_add.rb -> create file, add line

Use the ignore_missing option to allow an error to be raised in case the file is not found. This change breaks the behavior of the recent change to add_to_list, append_if_no_line, delete_from_list,
delete_lines. So doing it with the other breaking changes for the 2.0.0 release makes sense to me.

How to push Multiple lines into a file using the line cookbook

Cookbook version

Version 1.0

Chef-client version

Chef Client, version 14.3.37

Platform Details

[RHEL]

Scenario:

UseCase:

Trying to insert multiple lines to a file without deleting the original file.

It simply does not inset anything post the first line and does not fail either.

Recipe Used:
replace_or_add "New Lines" do
path "/etc/rsyslog.conf"
pattern "# ### end of the forwarding rule ###"
line "#audit log
$ModLoad imfile"
end

Steps to Reproduce:

Import the line quick book into the chef Server.
Add the above lines to the recipe
run the cookbook to add multiple lines to the config files

Expected Result:

All the lines should have been added to the files? one line at a time and on the next lines
Ex: #audit log
$ModLoad imfile
$Line 2
$Line 3
$Line 4

Actual Result:

Only one line is added to the file and no other lines gets added even after changing the code to include the \n character

#audit log

Files should have the standard license header.

Cookbook version

Latest

Chef-client version

None

Platform Details

None]

Scenario:

Steps to Reproduce:

Expected Result:

Most of the files in line should have an Apache 2 license header.

Actual Result:

delete_from_list with space delimiter does not work properly

I am trying to use the line cookbook to add/remove kernel parameters from grub.conf. I tried to use delete_from_list for this, but ran into a problem.

Given the following existing file content:

kernel /vmlinuz-4.1.12-103.3.8.el6uek.x86_64 ro root=/dev/sda2 rd_NO_LUKS  KEYBOARDTYPE=pc KEYTABLE=us LANG=en_US.UTF-8 rd_NO_MD SYSFONT=latarcyrheb-sun16 crashkernel=auto nompath rd_NO_LVM rd_NO_DM rhgb quiet

And this recipe:

  delete_from_list "grub.conf - Remove rhgb" do
    path "/etc/grub.conf"
    pattern "^\\s*kernel .*"
    delim [' ']
    entry "rhgb"
  end

  delete_from_list "grub.conf - Remove quiet" do
    path "/etc/grub.conf"
    pattern "^\\s*kernel .*"
    delim [' ']
    entry "quiet"
  end

The result is:

kernel /vmlinuz-4.1.12-103.3.8.el6uek.x86_64 ro root=/dev/sda2 rd_NO_LUKS  KEYBOARDTYPE=pc KEYTABLE=us LANG=en_US.UTF-8 rd_NO_MD SYSFONT=latarcyrheb-sun16 crashkernel=auto nompath rd_NO_LVM rd_NO_DMquiet

... rd_NO_DMquiet -- the space delimiter gets deleted, so the second resource fails to match, and the result is malformed.

If I reverse the order of the recipe resources, it works in the test case, but I can't guarantee the input order, so I can't really rely on that. I also tried fiddling around with the delimiter (" ", "\ ", [" ", " "], etc), but no luck.

Has anyone used this to edit kernel params in grub.conf successfully? In my case, this is an oldish distro that doesn't have grub2-mkconfig, so I can't edit /etc/default/grub and then have it render the grub.cfg.

delete_from_list.ends_with doesn't seem to be working

Cookbook version

1.0.4 (appears to be missing in 2.0.0 as well, via source inspection)

Chef-client version

14.1.12

Platform Details

RHEL 7.5

Scenario:

  ['/etc/default/grub'].each do |f|     # cheap hack to avoid name duplication->typos
    delete_from_list f do
      path      f
      pattern   'GRUB_CMDLINE_LINUX="'
      delim     [' ']
      entry     'elevator=noop'
      ends_with '"'
      #    backup       true    # line >= 2.0.0 only
      only_if File.exist?(f)
    end
  end

Steps to Reproduce:

as above

Expected Result:

--- /dev/fd63       2018-05-30 16:01:16.715879150 -0700
+++ /etc/default/grub   2018-05-31 09:41:52.100677036 -0700
@@ -2,5 +2,5 @@
 GRUB_DEFAULT=saved
 GRUB_DISABLE_SUBMENU=true
 GRUB_TERMINAL_OUTPUT="console"
-GRUB_CMDLINE_LINUX="rd.lvm.lv=centos/root rd.lvm.lv=centos/swap crashkernel=auto rhgb net.ifnames=0 boisdevname=0 quiet elevator=noop"
+GRUB_CMDLINE_LINUX="rd.lvm.lv=centos/root rd.lvm.lv=centos/swap crashkernel=auto rhgb net.ifnames=0 boisdevname=0 quiet "
 GRUB_DISABLE_RECOVERY="true"

Actual Result:

NoMethodError
-------------
undefined method `ends_with' for Custom resource line_delete_from_list from cookbook line

Release 0.5.2 to Supermarket?

I am working on a cookbook that uses the delete_lines resource; it would be cool to not have to add it to Berksfiles

replace_or_add multiple lines

Hi,

I have a file with the following contents:

# comment line 1
# comment line2
# comment line X
some random text

I want to use the replace_or_add command to make it add several lines IF they DO NOT EXIST and skip it if the lines are already there.
So I tried this:

replace_or_add 'blahblah' do
  path '/path/to/file'
  line 'SOMELINE 1'
  line 'SOMELINE 2'
end

What it did is replaced all lines from the file with SOMELINE 2.

Is it possible to specify multiple lines in one replace_or_add block?

THe final result I want to achieve is for it to look like below regardless of how many times it is execute:

# comment line 1
# comment line2
# comment line X
some random text
SOMELINE 1
SOMELINE 2

Please help. Thanks in advance.

New Resource: prepend_if_no_line

Feature Request

Add a prepend_if_no_line resource. Similar to append_if_no_line except it will add the content before the line.

The missing cookbook(s)

Cookbook version

2.0.2

Chef-client version

13.x

Platform Details

centos 7

Scenario:

multiline edits

Steps to Reproduce:

knife cookbook site install line

Expected Result:

replace_or_add "postgresql.md5_auth_cidr_addresses/etc/chef-backend/chef-backend.rb" do
  path "/etc/chef-backend/chef-backend.rb"
  pattern "postgresql.md5_auth_cidr_addresses"
  line "postgresql.md5_auth_cidr_addresses = ["samehost", "samenet", "#{node['chefclusterbe1']['ip']}"]"
  replace_only true
end

i uploaded line cookbook on the server via knife

Actual Result:

$knife cookbook upload chefclusterbe

Uploading chefclusterbe  [2.2.2]
ERROR: Cookbook chefclusterbe depends on cookbooks which are not currently
ERROR: being uploaded and cannot be found on the server.
ERROR: The missing cookbook(s) are: '[#<Logger:0x000000000466d1a0 @level=2, @progname=nil, @default_formatter=#<Logger::Formatter:0x000000000466d128 @datetime_format=nil>, @formatter=#<Mixlib::Log::Formatter:0x000000000466cfc0 @datetime_format=nil>, @logdev=#<Logger::LogDevice:0x000000000466d088 @shift_period_suffix=nil, @shift_size=nil, @shift_age=nil, @filename=nil, @dev=#<IO:<STDOUT>>, @mon_owner=nil, @mon_count=0, @mon_mutex=#<Thread::Mutex:0x000000000466cfe8>>>]' version '>= 0.0.0'

Is it possible to do this inside ruby_block?

I have the following in a recipe:

ruby_block "add LD_PRELOAD" do
  block do
    replace_or_add "LD_PRELOAD" do
      path "/etc/environment"
      pattern "LD_PRELOAD*"
      line "LD_PRELOAD=/usr/lib/libjemalloc.so.2"
    end
  end
end

I end up with an error:

================================================================================
Error executing action `run` on resource 'ruby_block[add LD_PRELOAD]'
================================================================================
 
NoMethodError
-------------
undefined method `replace_or_add' for Chef::Resource::RubyBlock

append_if_no_line doesn't work on empty files

When using append_if_no_line with an empty file the following error occurs:

==> docker: Error executing action `edit` on resource 'append_if_no_line[disable_cramfs_filesystem]'
==> docker:     ================================================================================
==> docker:
==> docker:     NoMethodError
==> docker:     -------------
==> docker:     undefined method `chomp' for nil:NilClass

Example Recipe:

file "/etc/modprobe.d/CIS.conf" do
  content ''
  owner 'root'
  group 'root'
  mode 0644
  action :create_if_missing
end

%w(cramfs freevxfs jffs2 hfs hfsplus squashfs udf vfat).each do |fs|
  append_if_no_line "disable_#{fs}_filesystem" do
    path '/etc/modprobe.d/CIS.conf'
    line "install #{fs} /bin/true"
  end
end

Example workaround:

file "/etc/modprobe.d/CIS.conf" do
  content '# CIS Benchmark Disabled Filesystems'
  owner 'root'
  group 'root'
  mode 0644
  action :create_if_missing
end

%w(cramfs freevxfs jffs2 hfs hfsplus squashfs udf vfat).each do |fs|
  append_if_no_line "disable_#{fs}_filesystem" do
    path '/etc/modprobe.d/CIS.conf'
    line "install #{fs} /bin/true"
  end
end

Line 1.2.0 Supermarket Release does not compile

resourses/filter_lines.rb looks like it references a class, Line::OS, that does not exist in the release.
The file also does not exist in the 1.2.0 branch's source code.

Here is an output of the chef compile error:

================================================================================
Recipe Compile Error in /var/chef/cache/cookbooks/line/resources/filter_lines.rb
================================================================================

NameError
---------
uninitialized constant Line::OS

Cookbook Trace:
---------------
  /var/chef/cache/cookbooks/line/resources/filter_lines.rb:19:in `class_from_file'

Relevant File Content:
----------------------
/var/chef/cache/cookbooks/line/resources/filter_lines.rb:

 12:  # distributed under the License is distributed on an "AS IS" BASIS,
 13:  # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 14:  # See the License for the specific language governing permissions and
 15:  # limitations under the License.
 16:  #
 17:
 18:  property :backup, [true, false], default: false
 19>> property :eol, String, default: Line::OS.unix? ? "\n" : "\r\n"
 20:  property :filter, [Method, Proc, Array]
 21:  property :filter_args, Array
 22:  property :path, String
 23:
 24:  resource_name :filter_lines
 25:
 26:  action :edit do
 27:    new_resource.sensitive = true unless property_is_set?(:sensitive)
 28:    eol = new_resource.eol

Platform:
---------
x86_64-linux

README.md links don't work on supermarket.chef.io

Cookbook version

current

Chef-client version

n/a

Platform Details

n/a

Scenario:

Read the links

Steps to Reproduce:

Look at the cookbook description on supermarket.chef.io.

Expected Result:

Should be able to follow the links and read the documentation.

Actual Result:

Semi ugly text is presented.

Support for inserting a line after a matching line is found

It would be great if this cookbook had the ability to search for a matching line of text and then insert another line after it. It would certainly help keep things organized in config files and the like when templates are not a good option.

I'm going to be away for a bit, but if no one tackles it before I have time I can certainly give it a go myself and submit a PR. I think it should be similar to the replace_or_add functionality (insert_or_add perhaps?), but I can think of a number of edge cases that would need addressing.

One long string

When running on Windows 2012-R2-Datacenter, how do I get it to add newlines back into my file. Right now it just makes it one long string on one line, removing all the newlines.

I'm running it on Chef 12.18.31 (using it in my chef-client-updater wrapper cookbook).

Cannot enable `backup`

Cookbook version

2.0.2

Chef-client version

13.2.20

Platform Details

RHEL6

Scenario:

Backup file in /var/chef/backup/...

Steps to Reproduce:

replace_or_add 'foo' do
  path '/etc/issue'
  pattern '^nonsense.*'
  content 'nonsense'
  backup true
end

Expected Result:

Edit works, find backup in /var/chef/backup/etc/issue*

Actual Result:

Chef::Exceptions::ValidationFailed
----------------------------------
Property backup must be one of: Integer, false!  You passed true.

Cookbook Trace:
---------------
/var/chef/cookbooks/line/resources/replace_or_add.rb:39:in `block (2 levels) in class_from_file'
/var/chef/cookbooks/line/resources/replace_or_add.rb:37:in `block in class_from_file'

Suggestion:

Match the file resource, and use [ Integer, FalseClass ] for the backup attribute. (https://github.com/chef/chef/blob/2878c06b5287ce9415406738da7ccd3ed0ac0ebc/lib/chef/resource/file.rb#L60)

Add not_if and only_if, also standard cases such as exists/not exists

When using filter_lines there is no way to tell it not to append a line if one already exists. There should also be ways to code custom not_if and only_if clauses to prevent multiple converges. These options should probably be rolled out to all the resources where appropriate.

An example of what I wanted to achieve in ruby code is as follows where it will insert after a matched line, but only if the new line is not already present in the file.

          match = /# comment to find/
          newline = 'some.property=abc123'
          ruby_block "modify #{filename} insert_line_after_match##{editIndex} file" do
            block do
              line_count = 0
              File.open( filepath ).each do |line|
                if line =~ (/#{Regexp.escape(newline)}/)
                  line_count += 1
                end
              end
              if line_count == 0
                file = Chef::Util::FileEdit.new( filepath )
                file.insert_line_after_match(match, newline)
                file.write_file
              end
              action :run
              not_if { line_count = 1 }
            end
          end

I saw that filter_lines was the only way to insert near a given line, but there is no way to tell it that should only insert the line if it is not already present, so it inserts a new line on every convergence.

        filter_lines "modify #{filename} insert_line_after_match##{editIndex} file" do
          path filepath
          filters after: [match, newline, :each]
        end

I therefore feel it would be appropriate to add not_if and only_if to the libraries, but for something that is a fairly common need such as this use case, new option switches could be added to cater for these more common use cases internally.

Rubocop: 22 files inspected, 231 offenses detected

Inspecting 22 files
.CCCWC.WWWWCCCCCCC.CCC

Offenses:

line-cookbook/files/default/tests/minitest/default_test.rb:4:1: C: Extra empty line detected at block body beginning.
line-cookbook/files/default/tests/minitest/default_test.rb:10:1: C: Extra empty line detected at block body end.
line-cookbook/files/default/tests/minitest/support/helpers.rb:2:3: C: Missing top-level module documentation comment.
  module Line
  ^^^^^^
line-cookbook/Gemfile:4:14: C: Use the new Ruby 1.9 hash syntax.
gem 'rspec', :group => :integration
             ^^^^^^^^^
line-cookbook/Gemfile:5:27: C: Use the new Ruby 1.9 hash syntax.
gem 'chefspec', '~> 3.0', :group => :integration
                          ^^^^^^^^^
line-cookbook/Gemfile:6:14: C: Use the new Ruby 1.9 hash syntax.
gem 'guard', :group => :integration
             ^^^^^^^^^
line-cookbook/Gemfile:7:21: C: Use the new Ruby 1.9 hash syntax.
gem 'test-kitchen', :group => :integration
                    ^^^^^^^^^
line-cookbook/Gemfile:8:24: C: Use the new Ruby 1.9 hash syntax.
gem 'kitchen-vagrant', :group => :integration
                       ^^^^^^^^^
line-cookbook/Guardfile:4:29: C: Space inside square brackets detected.
guard 'rspec', spec_paths: [ 'spec' ] do
                            ^
line-cookbook/Guardfile:4:36: C: Space inside square brackets detected.
guard 'rspec', spec_paths: [ 'spec' ] do
                                   ^
line-cookbook/Guardfile:5:9: C: Use %r only for regular expressions matching more than 1 '/' character.
  watch(%r{^spec/.+spec\.rb$})
        ^^^^^^^^^^^^^^^^^^^^^
line-cookbook/Guardfile:7:9: C: Use %r only for regular expressions matching more than 1 '/' character.
  watch(%r{recipes/(.+)\.rb$}) { |m| "spec/#{m[1]}_spec.rb" }
        ^^^^^^^^^^^^^^^^^^^^^
line-cookbook/Guardfile:8:9: C: Use %r only for regular expressions matching more than 1 '/' character.
  watch(%r{([A-Za-z]+)/(.+)(\..*)?$}) { |m| "spec/*.rb" }
        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
line-cookbook/Guardfile:8:42: W: Unused block argument - m. You can omit the argument if you don't care about it.
  watch(%r{([A-Za-z]+)/(.+)(\..*)?$}) { |m| "spec/*.rb" }
                                         ^
line-cookbook/Guardfile:8:45: C: Prefer single-quoted strings when you don't need string interpolation or special symbols.
  watch(%r{([A-Za-z]+)/(.+)(\..*)?$}) { |m| "spec/*.rb" }
                                            ^^^^^^^^^^^
line-cookbook/Guardfile:10:1: C: 1 trailing blank lines detected.
line-cookbook/libraries/default.rb:5:41: C: Trailing whitespace detected.
# Author:: Sean OMeara <[email protected]>                                  
                                        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
line-cookbook/libraries/default.rb:19:2: C: Trailing whitespace detected.
#    
 ^^^^
line-cookbook/libraries/default.rb:23:23: C: Space missing to the left of {.
  string.gsub(pattern){|match|"\\" + match}
                      ^
line-cookbook/libraries/default.rb:23:23: C: Space between { and | missing.
  string.gsub(pattern){|match|"\\" + match}
                      ^^
line-cookbook/libraries/default.rb:23:30: C: Space after closing | missing.
  string.gsub(pattern){|match|"\\" + match}
                             ^
line-cookbook/libraries/default.rb:23:31: C: Prefer single-quoted strings when you don't need string interpolation or special symbols.
  string.gsub(pattern){|match|"\\" + match}
                              ^^^^
line-cookbook/libraries/default.rb:23:43: C: Space missing inside }.
  string.gsub(pattern){|match|"\\" + match}
                                          ^
line-cookbook/libraries/provider_add_to_list.rb:5:41: C: Trailing whitespace detected.
# Author:: Sean OMeara <[email protected]>                                  
                                        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
line-cookbook/libraries/provider_add_to_list.rb:19:2: C: Trailing whitespace detected.
#    
 ^^^^
line-cookbook/libraries/provider_add_to_list.rb:26:5: C: Missing top-level class documentation comment.
    class AddToList < Chef::Provider
    ^^^^^
line-cookbook/libraries/provider_add_to_list.rb:27:1: C: Extra empty line detected at class body beginning.
line-cookbook/libraries/provider_add_to_list.rb:30:1: C: Trailing whitespace detected.
line-cookbook/libraries/provider_add_to_list.rb:31:7: C: Assignment Branch Condition size for action_edit is too high. [77.18/15]
      def action_edit             
      ^^^
line-cookbook/libraries/provider_add_to_list.rb:31:7: C: Cyclomatic complexity for action_edit is too high. [7/6]
      def action_edit             
      ^^^
line-cookbook/libraries/provider_add_to_list.rb:31:7: C: Method has too many lines. [39/10]
      def action_edit             
      ^^^
line-cookbook/libraries/provider_add_to_list.rb:31:7: C: Perceived complexity for action_edit is too high. [8/7]
      def action_edit             
      ^^^
line-cookbook/libraries/provider_add_to_list.rb:31:22: C: Trailing whitespace detected.
      def action_edit             
                     ^^^^^^^^^^^^^
line-cookbook/libraries/provider_add_to_list.rb:33:1: C: Trailing whitespace detected.
line-cookbook/libraries/provider_add_to_list.rb:34:9: C: Use a guard clause instead of wrapping the code inside a conditional expression.
        if ::File.exists?(new_resource.path) then
        ^^
line-cookbook/libraries/provider_add_to_list.rb:34:19: W: File.exists? is deprecated in favor of File.exist?.
        if ::File.exists?(new_resource.path) then
                  ^^^^^^^
line-cookbook/libraries/provider_add_to_list.rb:34:46: C: Do not use then for multi-line if.
        if ::File.exists?(new_resource.path) then
                                             ^^^^
line-cookbook/libraries/provider_add_to_list.rb:36:48: C: Prefer single-quoted strings when you don't need string interpolation or special symbols.
            f = ::File.open(new_resource.path, "r+")
                                               ^^^^
line-cookbook/libraries/provider_add_to_list.rb:41:1: C: Trailing whitespace detected.
line-cookbook/libraries/provider_add_to_list.rb:43:1: C: Trailing whitespace detected.
line-cookbook/libraries/provider_add_to_list.rb:47:32: C: Do not use then for multi-line if.
              if line =~ regex then
                               ^^^^
line-cookbook/libraries/provider_add_to_list.rb:48:17: W: Useless assignment to variable - found.
                found = true
                ^^^^^
line-cookbook/libraries/provider_add_to_list.rb:49:1: C: Tab detected.
        if new_resource.delim.count == 1
^^
line-cookbook/libraries/provider_add_to_list.rb:49:3: C: Inconsistent indentation detected.
        if new_resource.delim.count == 1
  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
line-cookbook/libraries/provider_add_to_list.rb:50:3: C: Use 2 (not 16) spaces for indentation.
                  unless line =~ /(#{new_resource.delim[0]}|#{new_resource.pattern})\s*#{new_resource.entry}\s*(#{new_resource.delim[0]}|\n)/
  ^^^^^^^^^^^^^^^^
line-cookbook/libraries/provider_add_to_list.rb:50:19: C: Avoid more than 3 levels of block nesting.
                  unless line =~ /(#{new_resource.delim[0]}|#{new_resource.pattern})\s*#{new_resource.entry}\s*(#{new_resource.delim[0]}|\n)/
                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
line-cookbook/libraries/provider_add_to_list.rb:50:81: C: Line is too long. [141/80]
                  unless line =~ /(#{new_resource.delim[0]}|#{new_resource.pattern})\s*#{new_resource.entry}\s*(#{new_resource.delim[0]}|\n)/
                                                                                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
line-cookbook/libraries/provider_add_to_list.rb:51:81: C: Line is too long. [87/80]
                    line = line.chomp + "#{new_resource.delim[0]}#{new_resource.entry}"
                                                                                ^^^^^^^
line-cookbook/libraries/provider_add_to_list.rb:54:17: C: Align else with if.
                else
                ^^^^
line-cookbook/libraries/provider_add_to_list.rb:55:19: C: Avoid more than 3 levels of block nesting.
                  unless line =~ /#{new_resource.delim[0]}\s*#{new_resource.entry}\s*#{new_resource.delim[1]}/
                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
line-cookbook/libraries/provider_add_to_list.rb:55:81: C: Line is too long. [110/80]
                  unless line =~ /#{new_resource.delim[0]}\s*#{new_resource.entry}\s*#{new_resource.delim[1]}/
                                                                                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
line-cookbook/libraries/provider_add_to_list.rb:56:81: C: Line is too long. [111/80]
                    line = line.chomp + "#{new_resource.delim[0]}#{new_resource.entry}#{new_resource.delim[1]}"
                                                                                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
line-cookbook/libraries/provider_add_to_list.rb:59:17: W: end at 59, 16 is not aligned with if at 49, 2
                end
                ^^^
line-cookbook/libraries/provider_add_to_list.rb:66:25: C: Do not use then for multi-line if.
            if modified then
                        ^^^^
line-cookbook/libraries/provider_add_to_list.rb:68:49: C: Space missing after comma.
              FileUtils.copy_file(temp_file.path,new_resource.path)
                                                ^
line-cookbook/libraries/provider_add_to_list.rb:69:41: C: Space missing after comma.
              FileUtils.chown(file_owner,file_group,new_resource.path)
                                        ^
line-cookbook/libraries/provider_add_to_list.rb:69:52: C: Space missing after comma.
              FileUtils.chown(file_owner,file_group,new_resource.path)
                                                   ^
line-cookbook/libraries/provider_add_to_list.rb:70:40: C: Space missing after comma.
              FileUtils.chmod(file_mode,new_resource.path)              
                                       ^
line-cookbook/libraries/provider_add_to_list.rb:70:59: C: Trailing whitespace detected.
              FileUtils.chmod(file_mode,new_resource.path)              
                                                          ^^^^^^^^^^^^^^
line-cookbook/libraries/provider_add_to_list.rb:77:14: C: Trailing whitespace detected.
          end          
             ^^^^^^^^^^
line-cookbook/libraries/provider_add_to_list.rb:80:1: C: Trailing whitespace detected.
line-cookbook/libraries/provider_add_to_list.rb:83:1: C: Trailing whitespace detected.
line-cookbook/libraries/provider_append_if_no_line.rb:5:41: C: Trailing whitespace detected.
# Author:: Sean OMeara <[email protected]>                                  
                                        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
line-cookbook/libraries/provider_append_if_no_line.rb:19:2: C: Trailing whitespace detected.
#    
 ^^^^
line-cookbook/libraries/provider_append_if_no_line.rb:23:5: C: Missing top-level class documentation comment.
    class AppendIfNoLine < Chef::Provider
    ^^^^^
line-cookbook/libraries/provider_append_if_no_line.rb:24:1: C: Extra empty line detected at class body beginning.
line-cookbook/libraries/provider_append_if_no_line.rb:27:1: C: Trailing whitespace detected.
line-cookbook/libraries/provider_append_if_no_line.rb:28:7: C: Assignment Branch Condition size for action_edit is too high. [25.88/15]
      def action_edit             
      ^^^
line-cookbook/libraries/provider_append_if_no_line.rb:28:7: C: Method has too many lines. [24/10]
      def action_edit             
      ^^^
line-cookbook/libraries/provider_append_if_no_line.rb:28:22: C: Trailing whitespace detected.
      def action_edit             
                     ^^^^^^^^^^^^^
line-cookbook/libraries/provider_append_if_no_line.rb:32:1: C: Extra blank line detected.
line-cookbook/libraries/provider_append_if_no_line.rb:33:19: W: File.exists? is deprecated in favor of File.exist?.
        if ::File.exists?(new_resource.path) then
                  ^^^^^^^
line-cookbook/libraries/provider_append_if_no_line.rb:33:46: C: Do not use then for multi-line if.
        if ::File.exists?(new_resource.path) then
                                             ^^^^
line-cookbook/libraries/provider_append_if_no_line.rb:35:48: C: Prefer single-quoted strings when you don't need string interpolation or special symbols.
            f = ::File.open(new_resource.path, "r+")
                                               ^^^^
line-cookbook/libraries/provider_append_if_no_line.rb:36:1: C: Trailing whitespace detected.
line-cookbook/libraries/provider_append_if_no_line.rb:39:1: C: Trailing whitespace detected.
line-cookbook/libraries/provider_append_if_no_line.rb:40:13: C: Favor unless over if for negative conditions.
            if ! found then
            ^^^^^^^^^^^^^^^
line-cookbook/libraries/provider_append_if_no_line.rb:40:16: C: Do not leave space between ! and its argument.
            if ! found then
               ^
line-cookbook/libraries/provider_append_if_no_line.rb:40:24: C: Do not use then for multi-line if.
            if ! found then
                       ^^^^
line-cookbook/libraries/provider_append_if_no_line.rb:49:48: C: Prefer single-quoted strings when you don't need string interpolation or special symbols.
            f = ::File.open(new_resource.path, "w")
                                               ^^^
line-cookbook/libraries/provider_append_if_no_line.rb:55:1: C: Trailing whitespace detected.
line-cookbook/libraries/provider_append_if_no_line.rb:56:1: C: Trailing whitespace detected.
line-cookbook/libraries/provider_append_if_no_line.rb:59:1: C: Trailing whitespace detected.
line-cookbook/libraries/provider_delete_lines.rb:27:5: C: Missing top-level class documentation comment.
    class DeleteLines < Chef::Provider
    ^^^^^
line-cookbook/libraries/provider_delete_lines.rb:28:1: C: Extra empty line detected at class body beginning.
line-cookbook/libraries/provider_delete_lines.rb:32:7: C: Assignment Branch Condition size for action_edit is too high. [35.06/15]
      def action_edit
      ^^^
line-cookbook/libraries/provider_delete_lines.rb:32:7: C: Method has too many lines. [29/10]
      def action_edit
      ^^^
line-cookbook/libraries/provider_delete_lines.rb:35:9: C: Use a guard clause instead of wrapping the code inside a conditional expression.
        if ::File.exists?(new_resource.path) then
        ^^
line-cookbook/libraries/provider_delete_lines.rb:35:19: W: File.exists? is deprecated in favor of File.exist?.
        if ::File.exists?(new_resource.path) then
                  ^^^^^^^
line-cookbook/libraries/provider_delete_lines.rb:35:46: C: Do not use then for multi-line if.
        if ::File.exists?(new_resource.path) then
                                             ^^^^
line-cookbook/libraries/provider_delete_lines.rb:37:48: C: Prefer single-quoted strings when you don't need string interpolation or special symbols.
            f = ::File.open(new_resource.path, "r+")
                                               ^^^^
line-cookbook/libraries/provider_delete_lines.rb:48:32: C: Do not use then for multi-line if.
              if line =~ regex then
                               ^^^^
line-cookbook/libraries/provider_delete_lines.rb:57:25: C: Do not use then for multi-line if.
            if modified then
                        ^^^^
line-cookbook/libraries/provider_delete_lines.rb:59:49: C: Space missing after comma.
              FileUtils.copy_file(temp_file.path,new_resource.path)
                                                ^
line-cookbook/libraries/provider_delete_lines.rb:60:41: C: Space missing after comma.
              FileUtils.chown(file_owner,file_group,new_resource.path)
                                        ^
line-cookbook/libraries/provider_delete_lines.rb:60:52: C: Space missing after comma.
              FileUtils.chown(file_owner,file_group,new_resource.path)
                                                   ^
line-cookbook/libraries/provider_delete_lines.rb:61:40: C: Space missing after comma.
              FileUtils.chmod(file_mode,new_resource.path)
                                       ^
line-cookbook/libraries/provider_delete_lines.rb:74:1: C: Extra empty line detected at class body end.
line-cookbook/libraries/provider_replace_or_add.rb:5:41: C: Trailing whitespace detected.
# Author:: Sean OMeara <[email protected]>                                  
                                        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
line-cookbook/libraries/provider_replace_or_add.rb:19:2: C: Trailing whitespace detected.
#    
 ^^^^
line-cookbook/libraries/provider_replace_or_add.rb:26:5: C: Missing top-level class documentation comment.
    class ReplaceOrAdd < Chef::Provider
    ^^^^^
line-cookbook/libraries/provider_replace_or_add.rb:27:1: C: Extra empty line detected at class body beginning.
line-cookbook/libraries/provider_replace_or_add.rb:30:1: C: Trailing whitespace detected.
line-cookbook/libraries/provider_replace_or_add.rb:31:7: C: Assignment Branch Condition size for action_edit is too high. [55.87/15]
      def action_edit             
      ^^^
line-cookbook/libraries/provider_replace_or_add.rb:31:7: C: Cyclomatic complexity for action_edit is too high. [7/6]
      def action_edit             
      ^^^
line-cookbook/libraries/provider_replace_or_add.rb:31:7: C: Method has too many lines. [47/10]
      def action_edit             
      ^^^
line-cookbook/libraries/provider_replace_or_add.rb:31:7: C: Perceived complexity for action_edit is too high. [8/7]
      def action_edit             
      ^^^
line-cookbook/libraries/provider_replace_or_add.rb:31:22: C: Trailing whitespace detected.
      def action_edit             
                     ^^^^^^^^^^^^^
line-cookbook/libraries/provider_replace_or_add.rb:33:1: C: Trailing whitespace detected.
line-cookbook/libraries/provider_replace_or_add.rb:34:19: W: File.exists? is deprecated in favor of File.exist?.
        if ::File.exists?(new_resource.path) then
                  ^^^^^^^
line-cookbook/libraries/provider_replace_or_add.rb:34:46: C: Do not use then for multi-line if.
        if ::File.exists?(new_resource.path) then
                                             ^^^^
line-cookbook/libraries/provider_replace_or_add.rb:36:48: C: Prefer single-quoted strings when you don't need string interpolation or special symbols.
            f = ::File.open(new_resource.path, "r+")
                                               ^^^^
line-cookbook/libraries/provider_replace_or_add.rb:41:1: C: Trailing whitespace detected.
line-cookbook/libraries/provider_replace_or_add.rb:43:1: C: Trailing whitespace detected.
line-cookbook/libraries/provider_replace_or_add.rb:48:32: C: Do not use then for multi-line if.
              if line =~ regex then
                               ^^^^
line-cookbook/libraries/provider_replace_or_add.rb:58:13: C: Favor unless over if for negative conditions.
            if (!found) then # "add"!
            ^^^^^^^^^^^^^^^^^^^^^^^^^
line-cookbook/libraries/provider_replace_or_add.rb:58:16: C: Don't use parentheses around the condition of an if.
            if (!found) then # "add"!
               ^^^^^^^^
line-cookbook/libraries/provider_replace_or_add.rb:58:25: C: Do not use then for multi-line if.
            if (!found) then # "add"!
                        ^^^^
line-cookbook/libraries/provider_replace_or_add.rb:65:25: C: Do not use then for multi-line if.
            if modified then
                        ^^^^
line-cookbook/libraries/provider_replace_or_add.rb:67:49: C: Space missing after comma.
              FileUtils.copy_file(temp_file.path,new_resource.path)
                                                ^
line-cookbook/libraries/provider_replace_or_add.rb:68:41: C: Space missing after comma.
              FileUtils.chown(file_owner,file_group,new_resource.path)
                                        ^
line-cookbook/libraries/provider_replace_or_add.rb:68:52: C: Space missing after comma.
              FileUtils.chown(file_owner,file_group,new_resource.path)
                                                   ^
line-cookbook/libraries/provider_replace_or_add.rb:69:40: C: Space missing after comma.
              FileUtils.chmod(file_mode,new_resource.path)              
                                       ^
line-cookbook/libraries/provider_replace_or_add.rb:69:59: C: Trailing whitespace detected.
              FileUtils.chmod(file_mode,new_resource.path)              
                                                          ^^^^^^^^^^^^^^
line-cookbook/libraries/provider_replace_or_add.rb:79:1: C: Extra blank line detected.
line-cookbook/libraries/provider_replace_or_add.rb:81:53: C: Trailing whitespace detected.
            nf = ::File.open(new_resource.path, 'w')            
                                                    ^^^^^^^^^^^^
line-cookbook/libraries/provider_replace_or_add.rb:85:81: C: Line is too long. [88/80]
            Chef::Log.info('ERROR: Containing directory does not exist for #{nf.class}')
                                                                                ^^^^^^^^
line-cookbook/libraries/provider_replace_or_add.rb:89:1: C: Trailing whitespace detected.
line-cookbook/libraries/provider_replace_or_add.rb:92:1: C: Trailing whitespace detected.
line-cookbook/libraries/provider_replace_or_add.rb:95:1: C: Trailing whitespace detected.
line-cookbook/libraries/resource_add_to_list.rb:5:41: C: Trailing whitespace detected.
# Author:: Sean OMeara <[email protected]>                                  
                                        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
line-cookbook/libraries/resource_add_to_list.rb:19:2: C: Trailing whitespace detected.
#    
 ^^^^
line-cookbook/libraries/resource_add_to_list.rb:22:5: C: Missing top-level class documentation comment.
    class AddToList < Chef::Resource
    ^^^^^
line-cookbook/libraries/resource_add_to_list.rb:23:1: C: Trailing whitespace detected.
line-cookbook/libraries/resource_add_to_list.rb:24:39: C: Surrounding space missing in default value assignment.
      def initialize(name, run_context=nil)
                                      ^
line-cookbook/libraries/resource_add_to_list.rb:31:19: C: Surrounding space missing in default value assignment.
      def path(arg=nil)
                  ^
line-cookbook/libraries/resource_add_to_list.rb:35:11: C: Use the new Ruby 1.9 hash syntax.
          :kind_of => String
          ^^^^^^^^^^^
line-cookbook/libraries/resource_add_to_list.rb:39:22: C: Surrounding space missing in default value assignment.
      def pattern(arg=nil)
                     ^
line-cookbook/libraries/resource_add_to_list.rb:43:11: C: Use the new Ruby 1.9 hash syntax.
          :kind_of => String
          ^^^^^^^^^^^
line-cookbook/libraries/resource_add_to_list.rb:47:20: C: Surrounding space missing in default value assignment.
      def delim(arg=nil)
                   ^
line-cookbook/libraries/resource_add_to_list.rb:51:11: C: Use the new Ruby 1.9 hash syntax.
          :kind_of => Array
          ^^^^^^^^^^^
line-cookbook/libraries/resource_add_to_list.rb:55:20: C: Surrounding space missing in default value assignment.
      def entry(arg=nil)
                   ^
line-cookbook/libraries/resource_add_to_list.rb:59:11: C: Use the new Ruby 1.9 hash syntax.
          :kind_of => String
          ^^^^^^^^^^^
line-cookbook/libraries/resource_add_to_list.rb:62:1: C: Extra empty line detected at class body end.
line-cookbook/libraries/resource_append_if_no_line.rb:5:41: C: Trailing whitespace detected.
# Author:: Sean OMeara <[email protected]>                                  
                                        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
line-cookbook/libraries/resource_append_if_no_line.rb:19:2: C: Trailing whitespace detected.
#    
 ^^^^
line-cookbook/libraries/resource_append_if_no_line.rb:23:5: C: Missing top-level class documentation comment.
    class AppendIfNoLine < Chef::Resource
    ^^^^^
line-cookbook/libraries/resource_append_if_no_line.rb:24:1: C: Extra empty line detected at class body beginning.
line-cookbook/libraries/resource_append_if_no_line.rb:25:39: C: Surrounding space missing in default value assignment.
      def initialize(name, run_context=nil)
                                      ^
line-cookbook/libraries/resource_append_if_no_line.rb:29:36: C: Space missing after comma.
        @allowed_actions.push(:edit,:nothing)
                                   ^
line-cookbook/libraries/resource_append_if_no_line.rb:32:19: C: Surrounding space missing in default value assignment.
      def path(arg=nil)
                  ^
line-cookbook/libraries/resource_append_if_no_line.rb:36:11: C: Use the new Ruby 1.9 hash syntax.
          :kind_of => String
          ^^^^^^^^^^^
line-cookbook/libraries/resource_append_if_no_line.rb:40:19: C: Surrounding space missing in default value assignment.
      def line(arg=nil)
                  ^
line-cookbook/libraries/resource_append_if_no_line.rb:44:11: C: Use the new Ruby 1.9 hash syntax.
          :kind_of => String
          ^^^^^^^^^^^
line-cookbook/libraries/resource_append_if_no_line.rb:47:1: C: Extra empty line detected at class body end.
line-cookbook/libraries/resource_delete_lines.rb:23:5: C: Missing top-level class documentation comment.
    class DeleteLines < Chef::Resource
    ^^^^^
line-cookbook/libraries/resource_delete_lines.rb:24:1: C: Extra empty line detected at class body beginning.
line-cookbook/libraries/resource_delete_lines.rb:25:39: C: Surrounding space missing in default value assignment.
      def initialize(name, run_context=nil)
                                      ^
line-cookbook/libraries/resource_delete_lines.rb:29:36: C: Space missing after comma.
        @allowed_actions.push(:edit,:nothing)
                                   ^
line-cookbook/libraries/resource_delete_lines.rb:32:19: C: Surrounding space missing in default value assignment.
      def path(arg=nil)
                  ^
line-cookbook/libraries/resource_delete_lines.rb:36:11: C: Use the new Ruby 1.9 hash syntax.
          :kind_of => String
          ^^^^^^^^^^^
line-cookbook/libraries/resource_delete_lines.rb:40:22: C: Surrounding space missing in default value assignment.
      def pattern(arg=nil)
                     ^
line-cookbook/libraries/resource_delete_lines.rb:44:11: C: Use the new Ruby 1.9 hash syntax.
          :kind_of => String
          ^^^^^^^^^^^
line-cookbook/libraries/resource_delete_lines.rb:47:1: C: Extra empty line detected at class body end.
line-cookbook/libraries/resource_replace_or_add.rb:5:41: C: Trailing whitespace detected.
# Author:: Sean OMeara <[email protected]>                                  
                                        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
line-cookbook/libraries/resource_replace_or_add.rb:19:2: C: Trailing whitespace detected.
#    
 ^^^^
line-cookbook/libraries/resource_replace_or_add.rb:22:5: C: Missing top-level class documentation comment.
    class ReplaceOrAdd < Chef::Resource
    ^^^^^
line-cookbook/libraries/resource_replace_or_add.rb:23:1: C: Trailing whitespace detected.
line-cookbook/libraries/resource_replace_or_add.rb:24:39: C: Surrounding space missing in default value assignment.
      def initialize(name, run_context=nil)
                                      ^
line-cookbook/libraries/resource_replace_or_add.rb:31:19: C: Surrounding space missing in default value assignment.
      def path(arg=nil)
                  ^
line-cookbook/libraries/resource_replace_or_add.rb:35:11: C: Use the new Ruby 1.9 hash syntax.
          :kind_of => String
          ^^^^^^^^^^^
line-cookbook/libraries/resource_replace_or_add.rb:39:22: C: Surrounding space missing in default value assignment.
      def pattern(arg=nil)
                     ^
line-cookbook/libraries/resource_replace_or_add.rb:43:11: C: Use the new Ruby 1.9 hash syntax.
          :kind_of => String
          ^^^^^^^^^^^
line-cookbook/libraries/resource_replace_or_add.rb:47:19: C: Surrounding space missing in default value assignment.
      def line(arg=nil)
                  ^
line-cookbook/libraries/resource_replace_or_add.rb:51:11: C: Use the new Ruby 1.9 hash syntax.
          :kind_of => String
          ^^^^^^^^^^^
line-cookbook/libraries/resource_replace_or_add.rb:54:1: C: Extra empty line detected at class body end.
line-cookbook/metadata.rb:1:5: C: Put one space between the method name and the first argument.
name             "line"
    ^^^^^^^^^^^^^
line-cookbook/metadata.rb:1:18: C: Prefer single-quoted strings when you don't need string interpolation or special symbols.
name             "line"
                 ^^^^^^
line-cookbook/metadata.rb:2:11: C: Put one space between the method name and the first argument.
maintainer       "Sean OMeara"
          ^^^^^^^
line-cookbook/metadata.rb:2:18: C: Prefer single-quoted strings when you don't need string interpolation or special symbols.
maintainer       "Sean OMeara"
                 ^^^^^^^^^^^^^
line-cookbook/metadata.rb:3:18: C: Prefer single-quoted strings when you don't need string interpolation or special symbols.
maintainer_email "[email protected]"
                 ^^^^^^^^^^^^^^^^^
line-cookbook/metadata.rb:4:8: C: Put one space between the method name and the first argument.
license          "Apache2"
       ^^^^^^^^^^
line-cookbook/metadata.rb:4:18: C: Prefer single-quoted strings when you don't need string interpolation or special symbols.
license          "Apache2"
                 ^^^^^^^^^
line-cookbook/metadata.rb:5:12: C: Put one space between the method name and the first argument.
description      "Provides line editing resources for use by recipes"
           ^^^^^^
line-cookbook/metadata.rb:5:18: C: Prefer single-quoted strings when you don't need string interpolation or special symbols.
description      "Provides line editing resources for use by recipes"
                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
line-cookbook/metadata.rb:7:8: C: Put one space between the method name and the first argument.
version          "0.6.1"
       ^^^^^^^^^^
line-cookbook/metadata.rb:7:18: C: Prefer single-quoted strings when you don't need string interpolation or special symbols.
version          "0.6.1"
                 ^^^^^^^
line-cookbook/metadata.rb:8:1: C: 1 trailing blank lines detected.
line-cookbook/recipes/default.rb:6:2: C: Trailing whitespace detected.
# 
 ^
line-cookbook/recipes/tester.rb:25:6: C: Prefer single-quoted strings when you don't need string interpolation or special symbols.
file "/tmp/dangerfile" do
     ^^^^^^^^^^^^^^^^^
line-cookbook/recipes/tester.rb:27:9: C: Prefer single-quoted strings when you don't need string interpolation or special symbols.
  owner "root"
        ^^^^^^
line-cookbook/recipes/tester.rb:28:8: C: Prefer single-quoted strings when you don't need string interpolation or special symbols.
  mode "00644"
       ^^^^^^^
line-cookbook/recipes/tester.rb:35:6: C: Prefer single-quoted strings when you don't need string interpolation or special symbols.
file "/tmp/dangerfile2" do
     ^^^^^^^^^^^^^^^^^^
line-cookbook/recipes/tester.rb:37:9: C: Prefer single-quoted strings when you don't need string interpolation or special symbols.
  owner "root"
        ^^^^^^
line-cookbook/recipes/tester.rb:38:8: C: Prefer single-quoted strings when you don't need string interpolation or special symbols.
  mode "00666"
       ^^^^^^^
line-cookbook/recipes/tester.rb:45:15: C: Prefer single-quoted strings when you don't need string interpolation or special symbols.
cookbook_file "/tmp/serial.conf" do
              ^^^^^^^^^^^^^^^^^^
line-cookbook/recipes/tester.rb:46:9: C: Prefer single-quoted strings when you don't need string interpolation or special symbols.
  owner "root"
        ^^^^^^
line-cookbook/recipes/tester.rb:47:8: C: Prefer single-quoted strings when you don't need string interpolation or special symbols.
  mode "00644"
       ^^^^^^^
line-cookbook/recipes/tester.rb:52:19: C: Prefer single-quoted strings when you don't need string interpolation or special symbols.
append_if_no_line "Operation 1" do
                  ^^^^^^^^^^^^^
line-cookbook/recipes/tester.rb:53:8: C: Prefer single-quoted strings when you don't need string interpolation or special symbols.
  path "/tmp/dangerfile"
       ^^^^^^^^^^^^^^^^^
line-cookbook/recipes/tester.rb:54:8: C: Prefer single-quoted strings when you don't need string interpolation or special symbols.
  line "HI THERE I AM STRING"
       ^^^^^^^^^^^^^^^^^^^^^^
line-cookbook/recipes/tester.rb:57:16: C: Prefer single-quoted strings when you don't need string interpolation or special symbols.
replace_or_add "Operation 2" do
               ^^^^^^^^^^^^^
line-cookbook/recipes/tester.rb:58:8: C: Prefer single-quoted strings when you don't need string interpolation or special symbols.
  path "/tmp/dangerfile"
       ^^^^^^^^^^^^^^^^^
line-cookbook/recipes/tester.rb:59:11: C: Prefer single-quoted strings when you don't need string interpolation or special symbols.
  pattern "hey there.*"
          ^^^^^^^^^^^^^
line-cookbook/recipes/tester.rb:60:8: C: Prefer single-quoted strings when you don't need string interpolation or special symbols.
  line "hey there how you doin"
       ^^^^^^^^^^^^^^^^^^^^^^^^
line-cookbook/recipes/tester.rb:63:16: C: Prefer single-quoted strings when you don't need string interpolation or special symbols.
replace_or_add "Operation 3" do
               ^^^^^^^^^^^^^
line-cookbook/recipes/tester.rb:64:8: C: Prefer single-quoted strings when you don't need string interpolation or special symbols.
  path "/tmp/dangerfile"
       ^^^^^^^^^^^^^^^^^
line-cookbook/recipes/tester.rb:65:11: C: Prefer single-quoted strings when you don't need string interpolation or special symbols.
  pattern "hey there.*"
          ^^^^^^^^^^^^^
line-cookbook/recipes/tester.rb:66:8: C: Prefer single-quoted strings when you don't need string interpolation or special symbols.
  line "hey there how you doin"
       ^^^^^^^^^^^^^^^^^^^^^^^^
line-cookbook/recipes/tester.rb:69:16: C: Prefer single-quoted strings when you don't need string interpolation or special symbols.
replace_or_add "Operation 4" do
               ^^^^^^^^^^^^^
line-cookbook/recipes/tester.rb:70:8: C: Prefer single-quoted strings when you don't need string interpolation or special symbols.
  path "/tmp/dangerfile2"
       ^^^^^^^^^^^^^^^^^^
line-cookbook/recipes/tester.rb:71:11: C: Prefer single-quoted strings when you don't need string interpolation or special symbols.
  pattern "ssh-rsa AAAAB3NzaC1yc2EAAAADDEADBEEF.*"
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
line-cookbook/recipes/tester.rb:72:8: C: Prefer single-quoted strings when you don't need string interpolation or special symbols.
  line ""
       ^^
line-cookbook/recipes/tester.rb:76:8: C: Prefer single-quoted strings when you don't need string interpolation or special symbols.
  path "/tmp/dangerfile"
       ^^^^^^^^^^^^^^^^^
line-cookbook/recipes/tester.rb:81:8: C: Prefer single-quoted strings when you don't need string interpolation or special symbols.
  path "/tmp/dangerfile2"
       ^^^^^^^^^^^^^^^^^^
line-cookbook/spec/tester_spec.rb:16:81: C: Line is too long. [96/80]
    expect(chef_run).to render_file('/tmp/dangerfile').with_content(/^# UNCOMMENT ME YOU FOOL$/)
                                                                                ^^^^^^^^^^^^^^^^
line-cookbook/spec/tester_spec.rb:27:1: C: 1 trailing blank lines detected.
line-cookbook/Thorfile:11:8: C: Prefer single-quoted strings when you don't need string interpolation or special symbols.
  puts ">>>>> Kitchen gem not loaded, omitting tasks" unless ENV['CI']
       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
line-cookbook/Vagrantfile:11:81: C: Line is too long. [84/80]
  # An array of symbols representing groups of cookbook described in the Vagrantfile
                                                                                ^^^^
line-cookbook/Vagrantfile:15:81: C: Line is too long. [84/80]
  # An array of symbols representing groups of cookbook described in the Vagrantfile
                                                                                ^^^^
line-cookbook/Vagrantfile:19:25: C: Prefer single-quoted strings when you don't need string interpolation or special symbols.
  config.vm.host_name = "line-berkshelf"
                        ^^^^^^^^^^^^^^^^
line-cookbook/Vagrantfile:21:19: C: Prefer single-quoted strings when you don't need string interpolation or special symbols.
  config.vm.box = "chef-centos-6.3"
                  ^^^^^^^^^^^^^^^^^
line-cookbook/Vagrantfile:22:23: C: Prefer single-quoted strings when you don't need string interpolation or special symbols.
  config.vm.box_url = "https://dl.dropbox.com/u/31081437/Berkshelf-CentOS-6.3-x86_64-minimal.box"
                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
line-cookbook/Vagrantfile:22:97: C: Line is too long. [97/80]
  config.vm.box_url = "https://dl.dropbox.com/u/31081437/Berkshelf-CentOS-6.3-x86_64-minimal.box"
                                                                                                ^
line-cookbook/Vagrantfile:31:32: C: Prefer single-quoted strings when you don't need string interpolation or special symbols.
  config.vm.network :hostonly, "33.33.33.10"
                               ^^^^^^^^^^^^^
line-cookbook/Vagrantfile:53:7: C: Use the new Ruby 1.9 hash syntax.
      :mysql => {
      ^^^^^^^^^
line-cookbook/Vagrantfile:54:9: C: Use the new Ruby 1.9 hash syntax.
        :server_root_password => 'rootpass',
        ^^^^^^^^^^^^^^^^^^^^^^^^
line-cookbook/Vagrantfile:55:9: C: Use the new Ruby 1.9 hash syntax.
        :server_debian_password => 'debpass',
        ^^^^^^^^^^^^^^^^^^^^^^^^^^
line-cookbook/Vagrantfile:56:9: C: Use the new Ruby 1.9 hash syntax.
        :server_repl_password => 'replpass'
        ^^^^^^^^^^^^^^^^^^^^^^^^
line-cookbook/Vagrantfile:61:7: C: Prefer single-quoted strings when you don't need string interpolation or special symbols.
      "recipe[line::tester]"
      ^^^^^^^^^^^^^^^^^^^^^^
line-cookbook/Vagrantfile:65:1: C: 1 trailing blank lines detected.

22 files inspected, 231 offenses detected

crashes when the file does not exists or is empty

When using the append_if_no_line provider on a file that either does not exists or is empty, the providers crashes.

Use Case :
Wanted to list attribute from a bunch of nodes and add them to a file. Initially the file does not exists. Of course I can initialize the file but imo it should the the provider's task rather than the recipe.

Only Replace a Line in replace_or_add

It would be nice if replace_or_add had an option to only replace it matched.

This could be a new LWRP, but may be easier to just add an option to replace_or_add so that if a line is not matched just move on, and not add it at the bottom.

for example:
File:

Line 1
Line 2
Line 3

This changes something:

replace_or_add 'file' do
   path '<file>'
  pattern 'Line 2'
  line 'Line Two'
end

But this takes No action:

replace_or_add 'file' do
   path '<file>'
  pattern 'Line 4'
  line 'Line Four'
end

Tar Header Octal string (ArgumentError)

Hi,

With version 1.1.1, I receive the following error when running a berks install caused by an invalid tar header.

# [master ≡ +110 ~3 -1 !]> cat berksfile
# frozen_string_literal: true
source 'https://supermarket.chef.io'
cookbook 'chef-client'
cookbook 'line', '~> 1.1.1'


metadata
`[C:\Users\REMOVED\Desktop\Hadoop-HPC Projects\Chef\auto-bootstrap\cookbooks\service-config] [10:41:59]
# [master ≡ +110 ~3 -1 !]> berks install
Resolving cookbook dependencies...
Fetching 'service-config' from source at .
Fetching cookbook index from https://supermarket.chef.io...
Using chef-client (10.0.4)
Using logrotate (2.2.0)
Using service-config (0.1.0) from source at .
Using windows (4.2.2)
Using cron (5.1.0)
Installing line (1.1.1)
c:/opscodeNEW/chefdk/embedded/lib/ruby/site_ruby/2.4.0/rubygems/package/tar_header.rb:128:in `strict_oct': "\x80\x00\x0
\x00d\x9E\xD3\xD9" is not an octal string (ArgumentError)
        from c:/opscodeNEW/chefdk/embedded/lib/ruby/site_ruby/2.4.0/rubygems/package/tar_header.rb:108:in `from'
        from c:/opscodeNEW/chefdk/embedded/lib/ruby/site_ruby/2.4.0/rubygems/package/tar_reader.rb:59:in `each'
        from c:/opscodeNEW/chefdk/embedded/lib/ruby/gems/2.4.0/gems/mixlib-archive-0.4.1/lib/mixlib/archive/tar.rb:27:i
 `block in extract'
        from c:/opscodeNEW/chefdk/embedded/lib/ruby/site_ruby/2.4.0/rubygems/package/tar_reader.rb:29:in `new'
        from c:/opscodeNEW/chefdk/embedded/lib/ruby/gems/2.4.0/gems/mixlib-archive-0.4.1/lib/mixlib/archive/tar.rb:118:
n `reader'
        from c:/opscodeNEW/chefdk/embedded/lib/ruby/gems/2.4.0/gems/mixlib-archive-0.4.1/lib/mixlib/archive/tar.rb:25:i
 `extract'
        from c:/opscodeNEW/chefdk/embedded/lib/ruby/gems/2.4.0/gems/mixlib-archive-0.4.1/lib/mixlib/archive.rb:33:in `e
tract'
        from c:/opscodeNEW/chefdk/embedded/lib/ruby/gems/2.4.0/gems/berkshelf-6.3.1/lib/berkshelf/community_rest.rb:16:
n `unpack'
        from c:/opscodeNEW/chefdk/embedded/lib/ruby/gems/2.4.0/gems/berkshelf-6.3.1/lib/berkshelf/community_rest.rb:102
in `download'
        from c:/opscodeNEW/chefdk/embedded/lib/ruby/gems/2.4.0/gems/berkshelf-6.3.1/lib/berkshelf/downloader.rb:70:in `
ry_download'
        from c:/opscodeNEW/chefdk/embedded/lib/ruby/gems/2.4.0/gems/berkshelf-6.3.1/lib/berkshelf/downloader.rb:40:in `
lock in download'
        from c:/opscodeNEW/chefdk/embedded/lib/ruby/gems/2.4.0/gems/berkshelf-6.3.1/lib/berkshelf/downloader.rb:39:in `
ach'
        from c:/opscodeNEW/chefdk/embedded/lib/ruby/gems/2.4.0/gems/berkshelf-6.3.1/lib/berkshelf/downloader.rb:39:in `
ownload'
        from c:/opscodeNEW/chefdk/embedded/lib/ruby/gems/2.4.0/gems/berkshelf-6.3.1/lib/berkshelf/installer.rb:108:in `
nstall'
        from c:/opscodeNEW/chefdk/embedded/lib/ruby/gems/2.4.0/gems/berkshelf-6.3.1/lib/berkshelf/installer.rb:181:in `
lock (2 levels) in install_from_universe'
        from c:/opscodeNEW/chefdk/embedded/lib/ruby/gems/2.4.0/gems/concurrent-ruby-1.0.5/lib/concurrent/executor/safe_
ask_executor.rb:24:in `block in execute'
        from c:/opscodeNEW/chefdk/embedded/lib/ruby/gems/2.4.0/gems/concurrent-ruby-1.0.5/lib/concurrent/synchronizatio
/mri_lockable_object.rb:38:in `block in synchronize'
        from c:/opscodeNEW/chefdk/embedded/lib/ruby/gems/2.4.0/gems/concurrent-ruby-1.0.5/lib/concurrent/synchronizatio
/mri_lockable_object.rb:38:in `synchronize'
        from c:/opscodeNEW/chefdk/embedded/lib/ruby/gems/2.4.0/gems/concurrent-ruby-1.0.5/lib/concurrent/synchronizatio
/mri_lockable_object.rb:38:in `synchronize'
        from c:/opscodeNEW/chefdk/embedded/lib/ruby/gems/2.4.0/gems/concurrent-ruby-1.0.5/lib/concurrent/executor/safe_
ask_executor.rb:19:in `execute'
        from c:/opscodeNEW/chefdk/embedded/lib/ruby/gems/2.4.0/gems/concurrent-ruby-1.0.5/lib/concurrent/ivar.rb:170:in
`safe_execute'
        from c:/opscodeNEW/chefdk/embedded/lib/ruby/gems/2.4.0/gems/concurrent-ruby-1.0.5/lib/concurrent/future.rb:52:i
 `block in execute'
        from c:/opscodeNEW/chefdk/embedded/lib/ruby/gems/2.4.0/gems/concurrent-ruby-1.0.5/lib/concurrent/executor/ruby_
hread_pool_executor.rb:348:in `run_task'
        from c:/opscodeNEW/chefdk/embedded/lib/ruby/gems/2.4.0/gems/concurrent-ruby-1.0.5/lib/concurrent/executor/ruby_
hread_pool_executor.rb:337:in `block (3 levels) in create_worker'
        from c:/opscodeNEW/chefdk/embedded/lib/ruby/gems/2.4.0/gems/concurrent-ruby-1.0.5/lib/concurrent/executor/ruby_
hread_pool_executor.rb:320:in `loop'
        from c:/opscodeNEW/chefdk/embedded/lib/ruby/gems/2.4.0/gems/concurrent-ruby-1.0.5/lib/concurrent/executor/ruby_
hread_pool_executor.rb:320:in `block (2 levels) in create_worker'
        from c:/opscodeNEW/chefdk/embedded/lib/ruby/gems/2.4.0/gems/concurrent-ruby-1.0.5/lib/concurrent/executor/ruby_
hread_pool_executor.rb:319:in `catch'
        from c:/opscodeNEW/chefdk/embedded/lib/ruby/gems/2.4.0/gems/concurrent-ruby-1.0.5/lib/concurrent/executor/ruby_
hread_pool_executor.rb:319:in `block in create_worker```

uninitialized constant #<Class:0x0000000579eff0>::Line

ruby-2.3.1
Starting Chef Client, version 12.8.1

Dans-MacBook-Pro:htw_infra dan$ cat Berksfile.lock  | grep line
  line (= 0.6.3)
  line (0.6.3)
    line (>= 0.0.0)
================================================================================
Recipe Compile Error in /tmp/chef/cookbooks/line/resources/add_to_list.rb
================================================================================

NameError
---------
uninitialized constant #<Class:0x0000000579eff0>::Line

Cookbook Trace:
---------------
  /tmp/chef/cookbooks/line/resources/add_to_list.rb:96:in `block in class_from_file'
  /tmp/chef/cookbooks/line/resources/add_to_list.rb:92:in `class_eval'
  /tmp/chef/cookbooks/line/resources/add_to_list.rb:92:in `class_from_file'

Relevant File Content:
----------------------
/tmp/chef/cookbooks/line/resources/add_to_list.rb:

 89:    end
 90:  end
 91:  
 92:  action_class.class_eval do
 93:    require 'fileutils'
 94:    require 'tempfile'
 95:  
 96>>   include Line::Helper
 97:  end
 98:  

It might just be as simple as ::Line to specify current namespace.

append_if_no_line broken since v1.1.0

Working in v1.0.6

       Recipe: test::default
         * append_if_no_line[maybe there, maybe not] action edit[2018-04-19T20:59:11+00:00] INFO: Processing append_if_no_line[maybe there, maybe not] action edit (test::default line 1)
       
           - Updating file /tmp/test_file

Not working in v.1.1.0 (same results for recently released v1.1.1)

       Recipe: test::default
         * append_if_no_line[maybe there, maybe not] action edit[2018-04-19T20:56:50+00:00] INFO: Processing append_if_no_line[maybe there, maybe not] action edit (test::default line 1)
       
           
           ================================================================================
           Error executing action `edit` on resource 'append_if_no_line[maybe there, maybe not]'
           ================================================================================
           
           RuntimeError
           ------------
           File /tmp/test_file not found
           
           Cookbook Trace:
           ---------------
           /tmp/kitchen/cache/cookbooks/line/resources/append_if_no_line.rb:10:in `block in class_from_file'
           
           Resource Declaration:
           ---------------------
           # In /tmp/kitchen/cache/cookbooks/test/recipes/default.rb
           
             1: append_if_no_line "maybe there, maybe not" do
             2:   path '/tmp/test_file'
             3:   line "Hello World!"
             4: end
             5: 
           
           Compiled Resource:
           ------------------
           # Declared in /tmp/kitchen/cache/cookbooks/test/recipes/default.rb:1:in `from_file'
           
           append_if_no_line("maybe there, maybe not") do
             action [:edit]
             retries 0
             retry_delay 2
             default_guard_interpreter :default
             declared_type :append_if_no_line
             cookbook_name "test"
             recipe_name "default"
             path "/tmp/test_file"
             line "Hello World!"
           end
           
           Platform:
           ---------
           x86_64-linux
           
       [2018-04-19T20:56:50+00:00] INFO: Running queued delayed notifications before re-raising exception

2.0.0 Issue with delete_lines - sensitive

Cookbook version

2.0.0

Chef-client version

12.21.14

Platform Details

RHEL

Scenario:

Trying to use delete_lines resource

Steps to Reproduce:

Use delete_lines resource

Expected Result:

Lines deleted from file

Actual Result:

 ================================================================================
           Error executing action `edit` on resource 'delete_lines[Remove mware from sudoers]'
           ================================================================================

           ArgumentError
           -------------
           Property sensitive is not defined in class delete_lines[Remove mware from sudoers]

           Cookbook Trace:
           ---------------
           /tmp/kitchen/cache/cookbooks/line/libraries/helper.rb:13:in `sensitive_default'
           /tmp/kitchen/cache/cookbooks/line/resources/delete_lines.rb:12:in `block in class_from_file'

Looks like you need to add 'properties' to the resource

Chefspec coverage needed

Untouched Resources:
append_if_no_line[Operation 1]
replace_or_add[Operation 2]
replace_or_add[Operation 3]
replace_or_add[Operation 4]
delete_lines[Operation 5]
delete_lines[Operation 6]

Also, there are no specs for add_to_list

append_if_no_line appends line always...

The following code block:

append_if_no_line 'Set MULE_HOME' do
  path '/home/muleesb/.bash_profile'
  line 'MULE_HOME=/muleesb/mule-enterprise-standalone-3.7.2'
end

Should write the line to the file in path and not write the line if the line already exists. It writes the line on every converge.

add_to_list for lists in quotes

Is there any indication how add_to_list works for lists in quotes? I am trying to append to the grub boot line options and I cant seem to figure out how to do this.

DEFAULT_APPEND="resume=/dev/sda2 splash=silent crashkernel=256M-:128M showopts"

replace_or_add does not add line

The file ifcfg-eth0 does not contain any line with the string "peerdns". The expected behavior is for it to add the line "PEERDNS=no".

replace_or_add "Disabling PEERDNS" do
path "/etc/sysconfig/network-scripts/ifcfg-eth0"
pattern "PEERDNS.*"
line "PEERDNS=no"
end

/etc/sysconfig/network-scripts/ifcfg-eth0

DEVICE=eth0
BOOTPROTO=static
HWADDR=ab:cd:ef:11:06:09
IPADDR=10.1.1.2
NETMASK=255.255.255.0
DEFROUTE=yes
GATEWAY= 10.1.1.1
IPV6INIT=yes
IPV6_AUTOCONF=no
IPV6ADDR=2003:5401:7119:0074:00d2:2bd2:ff11:0652/64
IPV6_DEFAULTGW=fe80::def%eth0
DNS1=10.1.1.1
DNS2=10.1.1.1
ONBOOT=yes
NM_CONTROLLED=no

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.