[augeas-devel] help with nrpe.cfg lens

Marc Fournier marc.fournier at camptocamp.com
Mon Aug 9 16:13:00 UTC 2010


Hello,

Thanks for you answer, Francis !

> There was 2 problems. First: look at the test. The lens that is tested
> is "command", but the iteration is defined only in "lns", that's why
> it matches only once. Your lens works when using "lns" for the test.
> The second problem I see is the subtree of the command lens. This
> subtree shouldn't be iterated. It doesn't prevent the lens from
> working, but it doesn't seems make sens to allow iteration there.
> 
> If you need debugging, then you can use this trick:
> 
>    let _ = print_regexp(lens_ctype(some_fucked_lens))
>    let _ = print_endline ""
> 
> The "ctype" is the actual regexp that will be used to match the input
> file.

Excellent, I wasn't aware of these debugging functions. The error was
obvious once you pointed it out...

> As for the tree, I would do at first a simple lens, try it, and see if
> it fits the need with a use case.

I'm still having some trouble understanding how my subtree should be
defined. The test2.aug you sent on friday (as well as most of the
attempts I've been iterating on today) fails with a variation of this
error:

 Expected:
{ 
  { "command"
    { "foo" = "bar" }
    { "bar" = "baz" }
  }
}

 Actual:
{ 
  { "command"
    { "foo" = "bar" }
  }
  { "command"
    { "bar" = "baz" }
  }
}

In the first case (the expected one), I would be able to use augtool
this way: "set /files/etc/nrpe.cfg/command/foo bar". In the second one,
augtool is used this way: "set /files/etc/nrpe.cfg/command[1]/foo bar"
which I don't find as elegant...

So I'm actually wondering if it really is possible to define a subtree
the way I'm trying to ? ie:

option1=bla
command[foo]=bla
command[bar]=blabla
option2=blabla
command[bla]=foobar

would be:

/files/etc/nrpe.cfg/option1
/files/etc/nrpe.cfg/command/foo
/files/etc/nrpe.cfg/command/bar
/files/etc/nrpe.cfg/option2
/files/etc/nrpe.cfg/command/bla

A similar config file would be /etc/sudoers, and this specific point
was handled the same way my lens actually works, not the way I'm
trying to make it work:

Defaults    env_keep=SSH_AUTH_SOCK
Defaults    authenticate
Defaults    env_reset

is structured as:

/files/etc/sudoers/Defaults[1]/env_keep/...
/files/etc/sudoers/Defaults[2]/authenticate
/files/etc/sudoers/Defaults[3]/env_reset

Do you think my goal is realistic ?

Marc





More information about the augeas-devel mailing list