[augeas-devel] help on using your up2date lens

Dominic Cleal dcleal at redhat.com
Fri Apr 20 18:16:15 UTC 2012


Hi Nicolas,

On 20/04/12 17:27, Nicolas Di Gregorio wrote:
> I'm trying to create a module in puppet able to modify
> /etc/sysconfig/rhn/up2date using augeas on both red hat 5 and 6 systems.
> 
> As it is not possible to do it out of box, I found your lens interesting
> at
> https://fedorahosted.org/augeas/browser/lenses/up2date.aug?rev=fe43cdaa89f1ab776e57e54f74bdc16ce4ae1fbb

It'll be included in the next version of Augeas.

> but I don't understand how to use it correctly.
> 
> can you tell me how to set the enableProxy value by exemple?
> 
> 
> Here is what I get when I run augtool:
> [root at sv0277 dist]#   augtool print /files/etc/sysconfig/rhn/up2date/
> /files/etc/sysconfig/rhn/up2date
[snip]
> /files/etc/sysconfig/rhn/up2date/9 = "enableProxy[comment]"
> /files/etc/sysconfig/rhn/up2date/9/value = "Use a HTTP Proxy"
> /files/etc/sysconfig/rhn/up2date/10 = "enableProxy"
> /files/etc/sysconfig/rhn/up2date/10/value = "0"

If you're using augtool (or Puppet, which has nearly identical
commands), at a simple level you can run "set /path value".  In the
tree, the "10" node (10th entry in the file) with "enableProxy" has a
"value" node beneath it with a value of "0".  To change that, just do:

set /files/etc/sysconfig/rhn/up2date/10/value 1
save

(the "save" is needed in augtool, it's done implicitly in Puppet)

Because the order can change, you can replace the "10" with an XPath
type expression to find the node with the value "enableProxy".

set /files/etc/sysconfig/rhn/up2date/*[. = 'enableProxy']/value 1
save

The "." refers to the current value of a node, so it's searching through
all of them (the "*") to find one with the value 'enableProxy'.

Here's a Puppet example showing what it could become, setting multiple
values and using the context shortcut:

augeas { "up2date-enableProxy":
  context => "/files/etc/sysconfig/rhn/up2date",
  changes => [
    "set *[. = 'enableProxy']/value 1",
    "set *[. = 'httpProxy']/value squid.redhat.com:3128",
  ],
}

There are examples of path expressions here:
http://augeas.net/page/Path_expressions

Raphael is also working on an exciting book, which covers path
expressions in chapter 3.  Well worth a read.
http://www.scribd.com/doc/51028532/Augeas-devel#outer_page_31

I've copied the augeas-devel list, which is as much for users as
development.  It's a good place to ask questions like this, as well as
in #augeas on Freenode.
http://www.redhat.com/mailman/listinfo/augeas-devel

Hope that gets you started.

-- 
Dominic Cleal
Red Hat Consulting
m: +44 (0)7817 878113




More information about the augeas-devel mailing list