简体   繁体   English

如何在 puppet 中使用 setm

[英]How to use setm in puppet

I would like to change a one property name ( " modcluster.proxylist " ) with setm Command in Puppet.我想在 Puppet 中使用setm命令更改一个属性名称(“ modcluster.proxylist ”)。 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.以下是我想更改的源 XML。

<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>

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.您提供的domain.xml代码似乎是错误的,因为没有您的 Puppet 代码所建议的domainserver-groups节点。 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使用incllens时无需设置context ,它是自动的

  • 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您误解了setm工作方式:第一个参数是 Augeas 将在其上循环的节点集,第二个是要设置的子节点,第三个是值
  • the change you want to do with setm is inherently idempotent, there's really no need to use onlyif here.你想用setm做的改变setm是幂等的,真的没有必要在这里使用onlyif

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",
 }

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM