puppetpuppet-enterpriseaugeas

How to use Setm with some condition


I would like to change one property name ( "modcluster.proxylist" ) with setm Command and with constraint in Puppet. Following code is not checking my constraint. Any help is much appreciated.

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

Constraint : In the below, Two Group doesn't have the property name. In those groups, the changes shouldn't be applied.

<server-groups>
    <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"/>
        </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>
    <server-group name="ServiceGroupFour" profile="full-ha">
    </server-group>
</server-groups>

Augeas Code :

The following code editing all the server groups. It is also inserting the Second and Fourth Server Group in which we don't have the property( modcluster.proxylist ).

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

Solution

  • Summing up your need, you want to:

    This should do:

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