Feature #2728
augeas show print file changes as applicable via --show_diff
| Status: | Closed | Start date: | 10/16/2009 | |
|---|---|---|---|---|
| Priority: | Normal | Due date: | ||
| Assignee: | % Done: | 0% | ||
| Category: | augeas | |||
| Target version: | 2.7.3 | |||
| Affected Puppet version: | 0.25.0 | Branch: | https://github.com/mikeknox/puppet/tree/feature/master/2728 | |
| Keywords: | ||||
Description
It would be nice for augeas to display changes when puppetd is run from the command line.
(Just like file changes with show_diff)
Related issues
History
#1
Updated by James Turnbull over 3 years ago
- Status changed from Unreviewed to Needs Decision
- Assignee set to David Lutterkort
- Target version set to 2.6.0
#2
Updated by James Turnbull over 3 years ago
- Target version changed from 2.6.0 to 2.7.x
#3
Updated by James Turnbull almost 3 years ago
- Assignee changed from David Lutterkort to Bryan Kearney
#4
Updated by Bryan Kearney over 2 years ago
- Status changed from Needs Decision to Needs More Information
can you give an example of what you would like to see?
#5
Updated by Michael Knox over 2 years ago
- Target version changed from 2.7.x to 2.6.x
This has been bugging me for a while, so I’ve created a patch so Puppet will show the changes that the Augeas provider will make.
https://github.com/mikeknox/puppet/commit/33301966d4c803640cb9aaed13b81bd7fd285484
https://github.com/mikeknox/puppet/tree/feature/master/2728
Output sample is:
info: Augeas[my.cnf/mysqld](provider=augeas): --- /etc/my.cnf 2011-03-18 18:09:46.343264543 +1100 +++ /etc/my.cnf.augnew 2011-03-18 21:29:39.706254147 +1100 @@ -133,7 +133,7 @@ character-set-server=utf8 log-warnings=1 skip-external-locking=1 -log-error=/var/log/mysql.log +log-error=/var/log/mysql.err set=log-slow-queries key_buffer=16M table_cache=64 notice: /Stage[main]/Mysql::Server/Augeas[my.cnf/mysqld]/returns: is need_to_run, should be 0 (noop)
Also this issue seems to be duplicated by feature #5400
#6
Updated by Michael Knox over 2 years ago
- Branch set to https://github.com/mikeknox/puppet/tree/feature/master/2728
#7
Updated by Josh Cooper about 2 years ago
- 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.
- close_augeas + if Puppet[:noop] + close_augeas + end
- 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:
$ 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
Adding the following to lib/puppet/provider/augeas/augeas.rb fixed the problem for me:
require 'puppet/util' require 'puppet/util/diff'
- The augeas tests fail because of the change from @aug.match to @aug.get in lib/puppet/provider/augeas/augeas.rb
- 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: #.get('/augeas/events/saved')
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.
saved_files = @aug.get("/augeas/events/saved")
...
else
saved_files.each do |tmp_file|
- 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:
/augeas/events/saved[1]=/files/etc/hosts /augeas/events/saved[2]=/files/etc/resolv.conf
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.
augeas { "test1" :
root => "/tmp/augeas-sandbox",
...
}
I think this can be accounted for as follows (where tmp_file is the “value” returned from @aug.get(..) above):
- saved_file = tmp_file.sub(/^\/files/, '') + saved_file = tmp_file.sub(/^\/files/, resource[:root])
- In execute_changes, if there are saved files and we successfully rename them, we don’t need to call @aug.save.
#8
Updated by Dominic Cleal about 2 years ago
Nigel also requested some tests on -dev, so I created a couple of simple ones the other day – you might want to cherry-pick this commit from my branch:
https://github.com/domcleal/puppet/commit/237e75bbf3bca6581f0b73ffdc0e828b6c2feb17
There did seem to be some issues for me trying to merge your branch, perhaps because of the ActiveRecord change you backed out – it’d be worth double checking your branch is in a sane state.
#9
Updated by Michael Knox about 2 years ago
Thanks for the comments, I’ve made the code changes in my branch. https://github.com/mikeknox/puppet/tree/a79ebce83ea4c65781b4a294aef639cccd87221c
I’ll have a go at incorporating the tests now.
#10
Updated by Josh Cooper about 2 years ago
- Status changed from Code Insufficient to Merged - Pending Release
- Target version set to 2.7.x
Merged into 2.7.x as commit:ae8069c0afc981d27012d7e1cf6fd1f63e0b6d94
#11
Updated by Michael Stahnke almost 2 years ago
Available in 2.7 series.
#12
Updated by Michael Stahnke almost 2 years ago
- Status changed from Merged - Pending Release to Closed
#13
Updated by James Turnbull almost 2 years ago
- Target version changed from 2.7.x to 2.7.3