[augeas-devel] Re: [Puppet-dev] Re: Augeas and Puppet

Raphaël Pinson raphink at gmail.com
Sat Aug 2 17:03:11 UTC 2008


On Fri, Aug 1, 2008 at 8:56 PM, David Schmitt <david at schmitt.edv-bus.at>wrote:

>
> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
>
> On Friday 01 August 2008, Raphaël Pinson wrote:
> > On Fri, Aug 1, 2008 at 4:00 PM, David Schmitt
> <david at schmitt.edv-bus.at>wrote:
> > > Lacking a real use case I'd rather omit that "mv" completely.
> >
> > I already mentionned commenting/uncommenting, but as you said puppet
> could
> > provide a higher level API for that. So here is another example, using
> > bb-hosts, which you might or might not be familiar with.
> >
> > bb-hosts is the configuration file for the bb4 web interface. It lists
> > pages, groups and hosts to include in monitoring system. There are two
> > kinds of groups that can be defined (or rather: I know two kinds of
> > groups): group-compress and group-only. Both can contain hosts, but they
> > don't behave the same way when bb4 parses them. Now if I want to turn a
> > group-compress into a  group-only (without losing the hosts in it, which
> > are subnodes), I would have to do something like this:
> >
> > # insert a group-only node to host the move (otherwise it would end up in
> > the end of the file)
> > aug.insert("/files/etc/bb-hosts/page[4]/group-compress[3]", "group-only",
> > "after")
> > # get the path to the newly created node (not implemented yet in augeas)
> > newpath = aug.get("/augeas/last_modified_node")
> > # move the group
> > aug.mv("/files/etc/bb-hosts/page[4]/group-compress[3]", newpath)
>
> Thanks for bringing up an example of this kind. It is great to demonstrate
> the
> power of augeas to create a simple tool to edit the brok^Wnon-standard
> configuration scheme of some app.
>
> Assuming that "hosts" are the primary resource to configure with bb4, in
> puppet I would expect this would look like this:
>
> bb4::host {
>        [ 'hostA', 'hostB' ]:
>                group => 'group-only',
>                other_parameter => something;
>        [ 'hostC', 'hostD' ]:
>                group => 'group-compress',
>                other_parameter => something_else;
> }
>
> define bb4::host($group, $other_parameter) {
>        augeas {
>                "/files/etc/bb4/some.conf/groups/${group}/${name}":
>                        ensure => present,
>                        value => $other_parameter;
>                "/files/etc/bb4/some.conf/groups/*/${name}":
>                        ensure => absent;
>        }
> }
>


Hmmm not exactly. There are not two groups, named 'group-only' and
'group-compress'. There can be any amount of groups, within pages, and these
groups can be of two types, 'group-compress' or 'group-only'. Hosts can
belong to groups or to pages directly. Groups belong to pages. The 'mv' I
talked about was not to move hosts from a group to another, but to change
the type of a group. That said, it's my implementation of the bb-hosts lens
which considers 'group-compress' and 'group-only' as keys. I could well
choose to consider a generic 'group' label, and 'type' subnode with
'compress' or 'only' as the value, which would allow to change the type by
setting this node.


Raphael
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://listman.redhat.com/archives/augeas-devel/attachments/20080802/7c4c2515/attachment.htm>


More information about the augeas-devel mailing list