How to create separated XML nodes with “set” in Puppet using Augeas?

落花浮王杯 提交于 2019-12-04 20:20:14

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.

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!