ATTENTION: this is not how Augeas is used in puppet, this is just to exercise with augtool that is normally not used...
[root@sapocvm2 ~]# augtool # the interactive augtool is ONLY installed on vm2 (other nodes use the lib and ruby binding for puppet) augtool> print /files/etc/hosts/* /files/etc/hosts/#comment = "127.0.0.1\tlocalhost localhost.localdomain" /files/etc/hosts/1 /files/etc/hosts/1/ipaddr = "127.0.0.1" /files/etc/hosts/1/canonical = "localhost" /files/etc/hosts/2 /files/etc/hosts/2/ipaddr = "::1" /files/etc/hosts/2/canonical = "localhost6" /files/etc/hosts/2/alias = "localhost6.localdomain6" /files/etc/hosts/3 /files/etc/hosts/3/ipaddr = "10.226.58.167" /files/etc/hosts/3/canonical = "puppet" /files/etc/hosts/3/alias[1] = "salt" /files/etc/hosts/3/alias[2] = "sapocvm1" augtool> print /files/etc/hosts/*/alias /files/etc/hosts/2/alias = "localhost6.localdomain6" /files/etc/hosts/3/alias[1] = "salt" /files/etc/hosts/3/alias[2] = "sapocvm1" Using XPath... augtool> match /files/etc/hosts/*[canonical='localhost'] /files/etc/hosts/1 = (none) augtool> match /files/etc/hosts/*/ipaddr[../canonical='localhost'] /files/etc/hosts/1/ipaddr = 127.0.0.1 The single dot . and double dots .. are short for self::* and parent::*. 2 examples to demo augtool> match /files/etc/hosts/*/canonical[.=~regexp('local.*')] /files/etc/hosts/1/canonical = localhost /files/etc/hosts/2/canonical = localhost6 augtool> match /files/etc/hosts/*/canonical[self::*=~regexp('local.*')] /files/etc/hosts/1/canonical = localhost /files/etc/hosts/2/canonical = localhost6 The single dot . and double dots .. are short for self::* and parent::*. 2 examples to demo augtool> match /files/etc/hosts/*/canonical[../alias=~regexp('sa.*')] /files/etc/hosts/3/canonical = puppet augtool> match /files/etc/hosts/*/canonical[parent::*/alias=~regexp('sa.*')] /files/etc/hosts/3/canonical = puppet augtool> match /files/etc/hosts/*/ipaddr[../alias=~regexp('sa.*') or ../canonical=~regexp('pup.*')] /files/etc/hosts/3/ipaddr = 10.226.58.167 augtool> print /files/etc/hosts/*/alias[last()-1] /files/etc/hosts/3/alias[1] = "salt" augtool> print /files/etc/hosts/*[last()]/* /files/etc/hosts/3/ipaddr = "10.226.58.167" /files/etc/hosts/3/canonical = "puppet" /files/etc/hosts/3/alias[1] = "salt" /files/etc/hosts/3/alias[2] = "sapocvm1"