How to use setm in puppet

邮差的信 提交于 2019-12-02 02:18:04

问题


I would like to change a one property name ( "modcluster.proxylist" ) with setm Command in Puppet. My following code is not working. Any help is much appreciated.

    augeas { "jboss_domain_config":
            incl    =>      "/opt/domain.xml",
            lens    =>      "Xml.lns",
            context =>      "/files/opt/domain.xml",
            onlyif  =>      "match /files/opt/domain.xml/domain/server-groups/*/system-properties/*/#attribute/name modcluster.proxylist"
            changes =>      "setm /files/opt/domain.xml/domain/server-groups server-group[.]/system-properties/property[.]/#attribute/value kumaran",
    }

Following is my Source XML which i would like to change.

<server-group name="ServiceGroupOne" profile="full-ha">
    <system-properties>
            <property name="jboss.default.multicast.address" value="232.0.2.20" boot-time="true"/>
            <property name="modcluster.proxylist" value="192.168.79.77:7777" boot-time="true"/>
            <property name="modcluster.lbgroup" value="SearchGroupOne" boot-time="true"/>
    </system-properties>
</server-group>
<server-group name="ServiceGroupTwo" profile="full-ha">
    <system-properties>
            <property name="jboss.default.multicast.address" value="232.0.2.20" boot-time="true"/>
            <property name="modcluster.lbgroup" value="SearchGroupTwo" boot-time="true"/>
            <property name="modcluster.proxylist" value="192.168.79.77:7777" boot-time="true"/>
    </system-properties>
</server-group>
<server-group name="ServiceGroupThree" profile="full-ha">
    <system-properties>
            <property name="modcluster.lbgroup" value="CommonSearchGroup" boot-time="true"/>
            <property name="modcluster.proxylist" value="192.168.79.77:7777" boot-time="true"/>
            <property name="jboss.default.multicast.address" value="232.0.2.20" boot-time="true"/>
    </system-properties>
</server-group>

回答1:


There's quite a few problems in there. Let's deal with them one by one:

  • it seems the domain.xml code you provide is wrong, as there's no domain and server-groups nodes as your Puppet code suggests. I take it there's two more levels around the code you provided:

    <domain>
      <server-groups>
        <!-- the rest of the file -->
      <server-groups>
    <domain>
    
  • there's no need to set context when using incl and lens, it's automatic

  • you misunderstood the way setm works: the first parameter is the nodeset on which Augeas will loop, the second one is the subnode to set and the third one the value
  • the change you want to do with setm is inherently idempotent, there's really no need to use onlyif here.

Here's the result:

augeas { "jboss_domain_config":
  incl    =>      "/tmp/domain.xml",
  lens    =>      "Xml.lns",
  changes =>      "setm domain/server-groups/server-group system-properties/property[#attribute/name='modcluster.proxylist']/#attribute/value kumaran",
 }


来源:https://stackoverflow.com/questions/33664488/how-to-use-setm-in-puppet

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