Simple configuration handling in tomcat
Keeping configuration in sync and making it easy to change is extremly important. When doing changes in production you want to know that thera are no human errors in editing. And you want to be sure that the exact same configuration was tested in development before putting it live. There are several solutions that solve this problem. My favorite and probably the most known is puppet. But although puppet seems awesome, for many reasons we are not ready to implement puppet at work now. But i still wanted to fix my problem with configuration handling, atleast for some things. My first target beeing server.xml of tomcat. Mostly since we have been tuning our connectionpools alot lately, and it is tedious to change a number in 15+ places everytime. I looked around and didnt find anything simple enough. So i went the classic way and did it myself. I decided to use python (despite i don't really know it), mostly because i know al the servers can run python and its a simple language. My script ended up as follows:import os, sys,host Info
f=open("server.xml", "r")
text = f.read();
text = text.format(**hostInfo.info);
print textinfo={
'mysqlHost': '192.168.65.1,
'hostname': 'myawesomeserver',
'logdir' : '/mount/logs/myawesomeserver',
'workerName' : 'tomcat1'
} <Resource name="jdbc/MySQL/myawesomedb" auth="Container"
type="javax.sql.DataSource"
initialSize="1" maxActive="10" maxIdle="4" maxWait="10000"
username="user" password="topsecret" driverClassName="com.mysql.jdbc.Driver"
url="jdbc:mysql://{mysqlHost}:3306/myawesomedb"
/>
blog comments powered by Disqus