Issue #2728 has been updated by Josh Cooper.

Status changed from Needs More Information to Code Insufficient
Target version deleted (2.6.x)


Hi Michael,

Thank you for submitting this patch. I found some issues that need to be 
resolved before we can accept them. Could you take a look and resubmit when you 
can? 

There were the issues Dominic mentioned on the mailing list:

* Change diff to be consistent with the file type, see 
lib/puppet/type/file/content.rb.

* The close_augeas method (below) won't be called if return_value is false. 
Also, if there's an exception parsing the filter, or if the augeas version is 
< 0.3.6, it won't be called. I suggest you change it so that the 
close_augeas method is only skipped if we successfully save the .augnew files.

<pre>
-      close_augeas
+      if Puppet[:noop]
+        close_augeas
+      end
</pre>

* When checking noop, it should check the resource noop? method. See 
lib/puppet/type.rb.

Also, I encountered the following issues after applying your patch. I am using 
Mac OS X 10.7, augeas 0.7.4, ruby-augeas 0.3.0, and ruby 1.8.7:

* I'm not able to run puppet due to some change in runtime include dependencies:

<pre>
$ puppet describe augeas
Could not run: 
Could not autoload /Users/josh/work/puppet/lib/puppet/type/augeas.rb:
Could not autoload 
/Users/josh/work/puppet/lib/puppet/provider/augeas/augeas.rb: uninitialized 
constant Puppet::Util::Diff
</pre>

Adding the following to lib/puppet/provider/augeas/augeas.rb fixed the problem 
for me:

<pre>
require 'puppet/util'
require 'puppet/util/diff'
</pre>

* The augeas tests fail because of the change from @aug.match to @aug.get in 
lib/puppet/provider/augeas/augeas.rb
<pre>
-          saved_files = @aug.match("/augeas/events/saved")
+          saved_files = @aug.get("/augeas/events/saved")

$ rspec -d spec/unit/provider/augeas/augeas_spec.rb
1) Puppet::Type::Augeas::ProviderAugeas augeas execution integration should 
handle set commands
  Failure/Error: @provider.execute_changes.should == :executed
  Mocha::ExpectationError:
    unexpected invocation: #<Mock:augeas>.get('/augeas/events/saved')
</pre>

One problem with this change is that @aug.get returns nil if no files were 
saved (so the following call to saved_files.each generates an exception), 
whereas @aug.match returns an empty list. But more importantly, augeas may save 
multiple files, and you need to iterate over the list returned by match.

<pre>
saved_files = @aug.get("/augeas/events/saved")
...
else
  saved_files.each do |tmp_file|
</pre>          

* Also, @aug.match("/augeas/events/saved") doesn't return the name of the files 
that were saved, but a list of keys, whose values are the saved file names. For 
example:
<pre>
/augeas/events/saved[1]=/files/etc/hosts
/augeas/events/saved[2]=/files/etc/resolv.conf
</pre>
  To resolve the file name, you have to call @aug.get(..) with the key, e.g. 
@aug.get("/augeas/events/saved[1]")

* The code does not take into account a non-default resource[:root] setting.
<pre>
augeas { "test1" :
  root =&gt; "/tmp/augeas-sandbox",
  ...
}
</pre>
  I think this can be accounted for as follows (where tmp_file is the "value" 
returned from @aug.get(..) above):
<pre>
-          saved_file = tmp_file.sub(/^\/files/, '')
+          saved_file = tmp_file.sub(/^\/files/, resource[:root])
</pre>

* In execute_changes, if there are saved files and we successfully rename them, 
we don't need to call @aug.save.

----------------------------------------
Feature #2728: augeas show print file changes as applicable via --show_diff 
https://projects.puppetlabs.com/issues/2728

Author: defunt Bode
Status: Code Insufficient
Priority: Normal
Assignee: Bryan Kearney
Category: augeas
Target version: 
Affected Puppet version: 0.25.0
Keywords: 
Branch: https://github.com/mikeknox/puppet/tree/feature/master/2728


It would be nice for augeas to display changes when puppetd is run from the 
command line.

(Just like file changes with show_diff)


-- 
You have received this notification because you have either subscribed to it, 
or are involved in it.
To change your notification preferences, please click here: 
http://projects.puppetlabs.com/my/account

-- 
You received this message because you are subscribed to the Google Groups 
"Puppet Bugs" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/puppet-bugs?hl=en.

Reply via email to