You need to specify the node
you want to impact with the XPath expression. In your case, you can write an idempotent change by 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 is no need (that I see) to filter on the existence of #attribute
sub-nodes, all the more that you don't create them, so you're changes won't be idempotent.