On Mon, 2009-06-15 at 12:50 +0200, Kjetil Torgrim Homme wrote:
> I was trying to use defnode as a simple way to declare state
> idempotently, and defnode seems to be the ticket. let's say I wanted
> to add a new entry in /etc/services
>
> defnode svc '/files/etc/services/service-name[. = "foo" and protocol =
> "tcp"]' foo
> set $svc/port 4711
> set $svc/protocol tcp
>
> this works fine for known services, but when adding a new entry, it
> fails.
The problem is that 'defnode var path value' is roughly equivalent to
if !exists(path)
set path value
end
defvar var path
The path you use will only find the service-name node for 'foo' if it
has a protocol child set to 'tcp' - but the set that defnode does, does
not create a protocol child. With that, you wind up with a defvar with a
path that matches no nodes, and var contains the empty node set.
Short of support for a full-blown 'if' (and the ensuing need for boolean
expressions), I don't see how this could be implemented in augtool.
Of course, if you use Augeas from your favorite programming language,
you can easily achieve what you want.
David
_______________________________________________
augeas-devel mailing list
[email protected]
https://www.redhat.com/mailman/listinfo/augeas-devel