[augeas-devel] grub lens doesn't match /boot/grub/grub.conf

David Lutterkort lutter at redhat.com
Wed Jan 11 01:10:31 UTC 2012


On Tue, 2012-01-10 at 09:32 -0600, Nathan Huff wrote:
> On 01/09/2012 06:17 PM, David Lutterkort wrote:
> > On Fri, 2011-12-30 at 13:46 -0600, Nathan Huff wrote:
> >> Since that is the actual file that RedHat uses I think it should.  I
> >> believe the one line change below would fix it.
> >>
> >> diff -ur augeas-0.10.0.orig/lenses/grub.aug augeas-0.10.0/lenses/grub.aug
> >> --- augeas-0.10.0.orig/lenses/grub.aug	2011-11-28 17:51:05.000000000 -0600
> >> +++ augeas-0.10.0/lenses/grub.aug	2011-12-30 13:27:13.651145502 -0600
> >> @@ -276,5 +276,6 @@
> >>        (* View: filter *)
> >>        let filter = incl "/boot/grub/menu.lst"
> >>                   . incl "/etc/grub.conf"
> >> +               . incl "/boot/grub/grub.conf"
> >
> > We have /etc/grub.conf in there; that should be a symlink
> > to /boot/grub/grub.conf. Does that not work for you ?
> >
> > (I hesitate to make that change because we'll have the same file show up
> > twice in the tree, opening the door to all kinds of interesting
> > conflicts)
> >
> > David
> >
> >
> >
> 
> The problem that I am running into is actually a combination of augeas 
> and puppet.  The way puppet seems to work with augeas is that it runs 
> the augeas commands against the existing file and creates a copy.  It 
> then checks if the copy and the original are the same if they are it 
> removes the copy and does nothing.  If they aren't it replaces the 
> original with the copy.  In the /etc/grub.conf case this causes the 
> symlink to be replaced by a regular file.  Obviously this is a problem 
> because grub doesn't actually look at /etc/grub.conf.
> 
> I can work around this by telling puppet explicitly which lens to use. 
> I just thought it was weird that the lens matches several files non of 
> which grub actually reads directly on at least RedHat and I assume any 
> other recent linux distro.

I just had a look at what the augeas provider[1] does there, and the
provider is entirely the problem here.

I am not sure why the provider tries so hard to only make the changes to
the tree once (making changes is very fast) But even with that, the code
around line 370 in execute_changes needs to check whether saved_file is
a symlink, and if so, dereference it. Augeas (see commits ca2e0c08 and
c0234fc9) uses canonicalize_file_name to dereference links, and make
sure the file ultimately winds up in the right place.

The puppet provider either needs to do that, too, or rely on Augeas to
do the right thing (which means it needs to reload the tree (@aug.load)
and rerun the changes; reloading the tree should be very cheap)

David


[1] https://github.com/puppetlabs/puppet/blob/master/lib/puppet/provider/augeas/augeas.rb#L370




More information about the augeas-devel mailing list