[augeas-devel] Re: [Puppet Users] Testing help for new Augeas Puppet provider which only executes if required

Bryan Kearney bkearney at redhat.com
Mon Feb 23 16:32:21 UTC 2009


David Lutterkort wrote:
> On Fri, 2009-02-20 at 07:53 -0500, Bryan Kearney wrote:
>> One question.... If I have a file with 10 nodes, does augeas re-write 
>> the whole file, or just scan for the nodes which changed?
> 
> It will write a new file (into a tmp location) and then replace the old
> file with the new one. Since rename(2) is the only way to modify files
> atomically, it's generally a bad idea to modify files that could be in
> the process of being read/written by others in place[1].

I pushed a new version up, if folks would not mind testing it. I made 2 
changes to the previous version:

1) I call Augeas twice. Once during the check to see if it should run, 
and once when executing the changes. This is a bit in-efficient, but 
removes the chance for data loss from the file changing between the 2 runs.

2) I also added a force parameter, which will disable this check. If 
force is set to true, then augeas will be called only being constrained 
by the onlyif parameter.

So.. the new logic to determine is the type should execute is:

<pseudo code>
needs_to_run = true

If only_if is set
   needs_to_run = false if get or match not found
end

if force is not set to true
   if Augeas version >= 0.3.6
     needs_to_run = false if executing the commands
                    would not effect any files.
   end
end

return needs_to_run
</pseudo code>

Again, if folks could take a look and see if it meets your needs before 
I ask James to push, that would be great.

-- bk

	




More information about the augeas-devel mailing list