Search code examples
puppetpuppet-enterprise

Best way to change xml values in puppet


I would like to change values in domain.xml ( JBoss Configuration file ). Please suggest me the best way to do it with sample examples to change it.

I have found the following ways. But No idea, How to use the following functions for xml files.

( i ) inline_template

( ii ) regsubst

I have to change the following four property as per each group. For Each Group, values of the 4 properties will be changed. Please suggest me the best Industry practise standard.

<system-properties>
    <property name="jboss.default.multicast.address" value="230.0.1.1" boot-time="true"/>
    <property name="modcluster.balancer.name" value="mylb" boot-time="true"/>
    <property name="modcluster.proxylist" value="172.28.168.153:6777" boot-time="true"/>
    <property name="mycluster.modcluster.lbgroup" value="coollb" boot-time="true"/>
</system-properties>

Solution

  • inline_template are executed on master, so they won't solve your problem.

    The easiest solution is erb templates. But this means that you will control from puppet the entire file, not only the properties.

    The best solution: there seems to be an augeas lens for xml: https://twiki.cern.ch/twiki/bin/view/Main/TerjeAndersenAugeas

    Edit:

    • have an erb template in your module (templates/jboss_config.xml.erb)

      <bla bla>....
      <system-properties>
          <property name="jboss.default.multicast.address" value="<%= @multicast_address %>" boot-time="true"/>
          <property name="modcluster.balancer.name" value="<%= @balancer_name %>" boot-time="true"/>
          <property name="modcluster.proxylist" value="<%= @proxylist %>" boot-time="true"/>
          <property name="mycluster.modcluster.lbgroup" value="<%= @lbgroup %>" boot-time="true"/>
      </system-properties>
      </bla bla>....
      

    In your puppet class declare the parameters/variables (those can came from hiera also, if you want to do overwrites based on some facts):

        $multicast_address = '230.0.1.1'
        $balancer_name = 'mylb'
        $proxylist = '172.28.168.153:6777'
        $lbgroup = 'coollb'
    
        # and write your file:
        file { 'jboss_config_file':
          ensure  => file,
          path    => '/path/to/jboss/config/file.xml',
          content => template("${module_name}/jboss_config.xml.erb"),
        }