How to create separated XML nodes with "set" in Puppet using Augeas? -
i using augeas tool puppet 3.2 , trying create xml file. want able add multiple fields same name xml doc. instance, want separate node2/location2 node1/location1 placing in own "node" field. code:
augeas { "update template": lens => "xml.lns", require => file["${buildpath}/tempfile.xml"], incl => "${buildpath}/tempfile.xml", changes => [ "set member/acceptors[#attribute]/node[#attribute]/nodeidentity[#attribute]/#text node2", "set member/acceptors/node/nodelocation[#attribute]/#text location2", "set member/acceptors/node/nodeidentity[#attribute]/#text node1", "set member/acceptors/node/nodelocation[#attribute]/#text location1" ], }
this xml output get:
<member> <acceptors> <node> <nodeidentity>node2</nodeidentity> <nodelocation>location2</nodelocation> <nodeidentity>node1</nodeidentity> <nodelocation>location1</nodelocation> </node> </acceptors> </member>
this output want:
<member> <acceptors> <node> <nodeidentity>node2</nodeidentity> <nodelocation>location2</nodelocation> </node> <node> <nodeidentity>node1</nodeidentity> <nodelocation>location1</nodelocation> </node> </acceptors> </member>
i have tried adding [#attribute] node1 line following:
"set member/acceptors/node[#attribute]/nodeidentity[#attribute]/#text node1",
but "node1" doesn't outputted. suggestions?
you need specify node
want impact xpath expression. in case, can write idempotent change doing this:
augeas { "update template": lens => "xml.lns", require => file["${buildpath}/tempfile.xml"], incl => "${buildpath}/tempfile.xml", changes => [ "set member/acceptors/node[nodeidentity/#text='node2']/nodeidentity/#text node2", "set member/acceptors/node[nodeidentity/#text='node2']/nodelocation/#text location2", "set member/acceptors/node[nodeidentity/#text='node1']/nodeidentity/#text node1", "set member/acceptors/node[nodeidentity/#text='node1']/nodelocation/#text location1" ], }
there no need (that see) filter on existence of #attribute
sub-nodes, more don't create them, you're changes won't idempotent.
Comments
Post a Comment