On Monday, April 7, 2014 5:24:15 PM UTC-5, Edward wrote: > > Hello, > > I am automating with Puppet the installation of a software on a Windows > puppet agent. At a moment I need to edit a configuration file (xml file). >
No, in fact you need to ensure that a particular attribute of a particular element has the specified value. You don't need or want to modify the file if it already is in the state you want. > I need to change the value of the "address" property in this bean: > > <bean id="IMFactory" > class="org.apache.cxf.jaxws.JaxWsProxyFactoryBean"> > <property name="serviceClass" > value="com.nano.imcommunication.IMWebServiceAPI" /> > <property name="address" value="http://10.126.81.152:8088/MockIM" > /> > </bean> > > I searched for documentation and found out that Augeas can only be used > for Unix puppet agents.. I'm new to Puppet but I wonder if I can use > templates to solve my problem, and if yes, how I have to do it. > > You can manage the whole file via Puppet, using a template to generate the content, but templates are not a mechanism to "edit" a file. That might look something like this: modules/myapp/manifests/myapp/config.pp: ------ class myapp::config( $im_factory_address ) { file { '/path/to/myapp.conf.xml': ensure => 'file', content => template('myapp.conf.xml.erb'), # owner => 'WhoKnows', # group => 'WhoKnows', # mode => 0640, } } modules/myapp/templates/myapp.conf.xml.erb: ------ <bean id="IMFactory" class="org.apache.cxf.jaxws. JaxWsProxyFactoryBean"> <property name="serviceClass" value="com.nano.imcommunication.IMWebServiceAPI" /> <property name="address" value="<%= @im_factory_address %><http://10.126.81.152:8088/MockIM>" /> </bean> Of course, you also have to feed the desired value to your class, which should be arranged for by recording it in an hiera data file, and you have to declare that class for the target node(s). John -- You received this message because you are subscribed to the Google Groups "Puppet Users" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To view this discussion on the web visit https://groups.google.com/d/msgid/puppet-users/688f0830-1bfa-49c2-8606-aca6a2d0dd45%40googlegroups.com. For more options, visit https://groups.google.com/d/optout.
