Ask Your Question

How to change configuration file using Puppet?

asked 2015-03-23 05:51:09 -0500

abhishekb gravatar image

I want to change configuration file persistence.xml. Please suggest how it can be done?

<property name="javax.persistence.jdbc.url" value="jdbc:oracle:thin:@172.x.x.11:1521:XE"/>

Note: I want to change IP in above line using puppet i.e from 172.x.x.11 to 172.x.x.35?

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted

answered 2015-03-23 12:59:22 -0500

lorcutt gravatar image

A couple of possibilities - if there are no other lines in the file that start with "value=", you could use the puppetlabs-stdlib module file_line:

Assume you have a variable with the IP in it:

$jdbc_ip = "172.x.x.35"

file_line {'persistence.xml jdbc ip':
  path  => '<fullpath>/persistence.xml',
  line   => "value=\"jdbc:oracle:thin:@$jdbc_ip:1521:XE\"/>",
  match => '^value="jdbc:oracle:thin:@',

Alternatively you could create a template file:

<property name="javax.persistence.jdbc.url" 
value="jdbc:oracle:thin:@<%= @jdbc_ip %>:XE"/>

and call it from a file declaration:

file {'<fullpath>/persistence.xml':
  content => template('module_name/persistence.xml.erb'),

Hope that helps!

edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower


Asked: 2015-03-23 05:51:09 -0500

Seen: 1,452 times

Last updated: Mar 23 '15