Skip to content
Browse files

postgres changes for app_tomcat

  • Loading branch information...
1 parent b2d63cf commit d60b88ab9cb622a3cd1debddbdb083057b84865b @anandu committed Mar 30, 2012
View
15 cookbooks/app_tomcat/attributes/tomcat.rb
@@ -13,6 +13,7 @@
set_unless[:tomcat][:java][:maxpermsize] = "256m"
set_unless[:tomcat][:java][:newsize] = "256m"
set_unless[:tomcat][:java][:maxnewsize] = "256m"
+set_unless[:tomcat][:db_adapter] = "postgresql"
set[:tomcat][:module_dependencies] = [ "proxy", "proxy_http", "deflate", "rewrite"]
@@ -23,24 +24,24 @@
case node[:platform]
when "ubuntu", "debian"
- set[:tomcat][:app_user] = "tomcat6"
+ set[:tomcat][:app_user] = "tomcat7"
set[:tomcat][:alternatives_cmd] = "update-alternatives --auto java"
- if(app[:db_adapter] == "mysql")
+ if(tomcat[:db_adapter] == "mysql")
set[:db_mysql][:socket] = "/var/run/mysqld/mysqld.sock"
- elsif(app[:db_adapter] == "postgresql")
+ elsif(tomcat[:db_adapter] == "postgresql")
set[:db_postgres][:socket] = "/var/run/postgresql"
else
- raise "Unrecognized database adapter #{node[:app][:db_adapter]}, exiting "
+ raise "Unrecognized database adapter #{node[:tomcat][:db_adapter]}, exiting "
end
when "centos", "fedora", "suse", "redhat", "redhatenterpriseserver"
set[:tomcat][:app_user] = "tomcat"
set[:tomcat][:alternatives_cmd] = "alternatives --auto java"
- if(app[:db_adapter] == "mysql")
+ if(tomcat[:db_adapter] == "mysql")
set[:db_mysql][:socket] = "/var/lib/mysql/mysql.sock"
- elsif(app[:db_adapter] == "postgresql")
+ elsif(tomcat[:db_adapter] == "postgresql")
set[:db_postgres][:socket] = "/var/run/postgresql"
else
- raise "Unrecognized database adapter #{node[:app][:db_adapter]}, exiting "
+ raise "Unrecognized database adapter #{node[:tomcat][:db_adapter]}, exiting "
end
else
raise "Unrecognized distro #{node[:platform]}, exiting "
View
15 cookbooks/app_tomcat/metadata.json
@@ -69,6 +69,21 @@
"display_name": "Tomcat Java XMX",
"description": "The java Xmx argument (i.e. 512m)"
},
+ "tomcat/db_adapter": {
+ "required": "optional",
+ "calculated": false,
+ "choice": [
+ "mysql",
+ "postgresql"
+ ],
+ "default": "postgresql",
+ "type": "string",
+ "recipes": [
+ "app_tomcat::default"
+ ],
+ "display_name": "Database adapter for application ",
+ "description": "Enter database adpter wich will be used to connect to the database Default: postgresql"
+ },
"tomcat/java/NewSize": {
"required": "optional",
"calculated": false,
View
7 cookbooks/app_tomcat/metadata.rb
@@ -63,3 +63,10 @@
:description => "The java MaxNewSize argument (i.e. 256m)",
:required => "optional",
:default => "256m"
+
+attribute "tomcat/db_adapter",
+ :display_name => "Database adapter for application ",
+ :description => "Enter database adpter wich will be used to connect to the database Default: postgresql",
+ :default => "postgresql",
+ :choice => [ "mysql", "postgresql" ],
+ :recipes => ["app_tomcat::default"]
View
8 cookbooks/app_tomcat/providers/default.rb
@@ -57,7 +57,7 @@
action :run
end
- db_adapter = node[:app][:db_adapter]
+ db_adapter = node[:tomcat][:db_adapter]
if db_adapter == "mysql"
# Link mysql-connector plugin to Tomcat6 lib
file "/usr/share/tomcat6/lib/mysql-connector-java.jar" do
@@ -82,7 +82,7 @@
to "/usr/share/java/postgresql-9.1-901.jdbc4.jar"
end
else
- raise "Unrecognized database adapter #{node[:app][:db_adapter]}, exiting "
+ raise "Unrecognized database adapter #{node[:tomcat][:db_adapter]}, exiting "
end
# "Linking RightImage JAVA_HOME to what Tomcat6 expects to be..."
@@ -316,7 +316,7 @@
action :setup_db_connection do
db_name = new_resource.database_name
- db_adapter = node[:app][:db_adapter]
+ db_adapter = node[:tomcat][:db_adapter]
log " Creating context.xml"
if db_adapter == "mysql"
@@ -338,7 +338,7 @@
cookbook 'app_tomcat'
end
else
- raise "Unrecognized database adapter #{node[:app][:db_adapter]}, exiting "
+ raise "Unrecognized database adapter #{node[:tomcat][:db_adapter]}, exiting "
end
log " Creating context.xml"
View
13 cookbooks/app_tomcat/recipes/default.rb
@@ -15,7 +15,7 @@
case node[:platform]
when "ubuntu", "debian"
- if(app[:db_adapter] == "mysql")
+ if node[:tomcat][:db_adapter] == "mysql"
node[:app][:packages] = ["ecj-gcj",\
# "java-gcj-compat-dev",\
"tomcat6",\
@@ -25,7 +25,7 @@
"libmysql-java",\
"libtcnative-1"
]
- elsif(app[:db_adapter] == "postgresql")
+ elsif node[:tomcat][:db_adapter] == "postgresql"
node[:app][:packages] = ["ecj-gcj",\
# "java-gcj-compat-dev",\
"tomcat6",\
@@ -35,28 +35,27 @@
"libtcnative-1"
]
else
- raise "Unrecognized database adapter #{node[:app][:db_adapter]}, exiting "
+ raise "Unrecognized database adapter #{node[:tomcat][:db_adapter]}, exiting "
end
when "centos", "fedora", "suse", "redhat", "redhatenterpriseserver"
- if(app[:db_adapter] == "mysql")
+ if node[:tomcat][:db_adapter] == "mysql"
node[:app][:packages] = ["eclipse-ecj",\
"tomcat6",\
"tomcat6-admin-webapps",\
"tomcat6-webapps",\
"tomcat-native",\
"mysql-connector-java"]
- elsif(app[:db_adapter] == "postgresql")
+ elsif node[:tomcat][:db_adapter] == "postgresql"
node[:app][:packages] = ["eclipse-ecj",\
"tomcat6",\
"tomcat6-admin-webapps",\
"tomcat6-webapps",\
"tomcat-native"]
else
- raise "Unrecognized database adapter #{node[:app][:db_adapter]}, exiting "
+ raise "Unrecognized database adapter #{node[:tomcat][:db_adapter]}, exiting "
end
else
raise "Unrecognized distro #{node[:platform]}, exiting "
end
-
rs_utils_marker :end
View
4 cookbooks/app_tomcat/templates/default/context_xml.erb
@@ -34,10 +34,10 @@
<Resource name="jdbc/ConnDB" auth="Container" type="javax.sql.DataSource"
maxActive="100" maxIdle="30" maxWait="10000"
- <% if node[:app][:db_adapter] == "mysql" -%>
+ <% if node[:tomcat][:db_adapter] == "mysql" -%>
username="<%= @user %>" password="<%= @password %>" driverClassName="com.mysql.jdbc.Driver"
url="jdbc:mysql://<%= @fqdn %>:3306/<%= @database %>"/>
- <% elsif node[:app][:db_adapter] == "postgresql"-%>
+ <% elsif node[:tomcat][:db_adapter] == "postgresql"-%>
username="<%= @user %>" password="<%= @password %>" driverClassName="org.postgresql.Driver"
url="jdbc:postgresql://<%= @fqdn %>:5432/<%= @database %>"/>
<% end -%>

0 comments on commit d60b88a

Please sign in to comment.
Something went wrong with that request. Please try again.