On 08/01/13 11:01, j4m3s wrote: > I started to look into this for JBoss - it uses an xml config file but > the app itself makes changes to the file > when you deploy an application (in domain mode) - so using the normal > file resource in puppet simply wouldn't work. > > I found the Augeas documentation to be rather hard to get into (or even > find). I was expecting there to be > a straightforward (xpath-style?) lens for editing xml files but couldn't > find anything. There wasn't a JBoss AS lens > either, which again was surprising since JBoss is a RedHat product and > it looks like Augeas is sponsored by RedHat.
If it's just XML, there's a lens for that already - it wouldn't need another. XML support is limited before Augeas 1.0 (released last month) as it only supports double quotes. Docs are a problem, but that's because it's primarily a library and so docs are targeted at those developers. The Augeas type in Puppet is very low-level, so it's tricky to use. Most docs about it are here. but there's no XML example yet: http://projects.puppetlabs.com/projects/puppet/wiki/Puppet_Augeas > In the end I found a workaround for JBoss so I can just use normal > puppet File type, though my XPath thoughts > did make me wonder whether I ought to actually be looking for an xpath > type/ resource/ plugin for puppet (sorry > for the incorrect terminology). Augeas actually uses a syntax that > looks a lot like xpath... Indeed, it's inspired by XPath. I tend to start with augtool to see how the tree looks on the original file and the finished file, then it's much easier to create expressions to make the changes: $ augtool --noautoload -r . augtool> set /augeas/load/Xml/lens Xml.lns augtool> set /augeas/load/Xml/incl /jbossas.xml augtool> load augtool> print /files/jbossas.xml/ /files/jbossas.xml /files/jbossas.xml/host /files/jbossas.xml/host/#text[1] = "\n " etc. The commands available in Puppet mirror those in the augtool (a test utility). I came up with this example to apply the transformation you mentioned: augeas { "jbossas-datasource": lens => "Xml.lns", incl => "/etc/jbossas.xml", changes => [ "set host/server[#attribute/name='one'] ''", "set host/server[#attribute/name='one']/datasource #empty", "set host/server[#attribute/name='one']/datasource/#attribute[name='example']/name example", ], } Cheers, -- Dominic Cleal Red Hat Engineering -- You received this message because you are subscribed to the Google Groups "Puppet Users" group. To post to this group, send email to puppet-users@googlegroups.com. To unsubscribe from this group, send email to puppet-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/puppet-users?hl=en.