Well, I was thinking of doing a type similar to what xmlstarlet does, including being able to add and remove nodes. I don't really need the added behavior of adding and removing nodes from the file right now, so I left command as a future expansion parameter, but it basically only accepts 'replace' and is set to default to that.
I'm only doing this type because Augeas doesn't like the particular XML file that has the value I need to change, but REXML parses it just fine. I really just want to do what Augeas can do to files, just using XPaths instead. I understand your point about the Puppet way of doing things. This type should really be saying "this XML document should have a path with this value" and, as my example is written, it looks more imperative than that. In practice, I think will basically be declarative since the only operation the type can do is retrieving an existing XPath, comparing it to the desired value, and then setting it if it doesn't match. I haven't had a lot of success getting compound namevars to work. I've added title_patterns to a different custom type before and done all of the basically undocumented steps for making it happen and hit a snag in the Puppet support code that meant my provider didn't get the values. I have this type doing the XPath operations properly now, so I'll try to go back and tweak it according to the postgres example that Raphink linked and see if I can get compound namevars to work. Hopefully you or the group will be able to get me on the right path if I can't get them working. :-) On Thursday, February 12, 2015 at 12:57:18 PM UTC-5, jcbollinger wrote: > > > > On Wednesday, February 11, 2015 at 11:09:32 AM UTC-6, jwil...@gmail.com > wrote: >> >> Hi all! >> >> I'm working on a custom type that applies xpaths to files. I expect the >> interface to look something like: >> >> xpath { "some update": >> xpath => "/some/xpath", >> command => "replace", >> value => "newvalue", >> file => "/path/to/file.xml" >> } >> >> I'm having a little trouble picking the namevar. It seems logical that >> the xpath attribute should be the namevar, but I'm a little hung up on the >> fact that it has to be unique among all xpath resources. In theory, I >> might want to apply the same xpath to many different files but with >> different values. I ran across a mention in the documentation that the >> exec type allows duplicate namevars, but going through the implementation, >> it isn't clear to me how that is done. Is it just a matter of each exec >> declaration having a unique title but the same command? >> >> > > Multiple Exec resources may have the same command and/or title. This is a > hard-coded special case, and other types cannot emulate it. > > No physical resource can be identified by an XPath expression alone. Only > in the context of an XML file does an XPath expression represent anything > concrete, and the natural identifier of that thing (or things) is the > combination of file and XPath expression. Your type absolutely *begs* > for a compound namevar. > > With that said, I can't say I care for the rest of what I see about your > type. In particular, the presence of a 'command' attribute suggests that > you are trying to model an action on some resource, instead of modeling the > resource itself. You probably can make that work, but it runs against > Puppet's design and mode of operation, which may end up presenting > practical problems. > > > John > > -- You received this message because you are subscribed to the Google Groups "Puppet Users" group. To unsubscribe from this group and stop receiving emails from it, send an email to puppet-users+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/puppet-users/fbafd64c-4339-4924-899e-519beb53a2cf%40googlegroups.com. For more options, visit https://groups.google.com/d/optout.