0

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"],
}
ArunRaj
  • 1,780
  • 2
  • 26
  • 48
  • 1
    Your example seems to miss a `server-groups` level, or else the path in your Puppet example doesn't make sense. – raphink Feb 15 '16 at 09:31
  • @ℝaphink : Yeap, I have missed it. Now I have updated the example. Please review it. – ArunRaj Feb 15 '16 at 09:35
  • I'm trying to understand what you want to do. Do you want to make sure this proxylist entry exists for every server-group, or do you want to exclude some groups? – raphink Feb 15 '16 at 09:44
  • @ℝaphink : If the "modcluster.proxylist" property exist, I want to change the values of it in server-group. If any Server-Group doesn't contain the property, It should be left as it is. – ArunRaj Feb 15 '16 at 09:55
  • You have a `require` in your Puppet code. Are you trying to manage that file twice? – raphink Feb 15 '16 at 10:15

1 Answers1

1

Summing up your need, you want to:

  • Select modcluster.proxylist properties that already exist
  • Replace their values with ${proxylist}

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}",
}
raphink
  • 3,625
  • 1
  • 28
  • 39
  • @Raphink : Could me please explain bit about the code. – ArunRaj Feb 15 '16 at 10:29
  • @ArunRaj that means Augeas was not able to parse your XML file. Please give the full error message. – raphink Feb 16 '16 at 05:38
  • @ArunRaj Are you accepting answers and downvoting them at the same time? – raphink Feb 16 '16 at 11:07
  • @Raphink: I am extremely sorry about it. It was my mistake. I down voted it without properly trying the solution. Once I have analyzed and tried it out , It is working good as i have expected. Now I couldn't up vote it back. Can you please edit the answer So that I will upvote it. Please forgive my mistake. – ArunRaj Feb 16 '16 at 14:49