forked from chef-boneyard/cookbooks
-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
11 changed files
with
97 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -19,7 +19,6 @@ | |
|
||
def get_distro | ||
if platform? [ "centos","redhat","fedora"] | ||
package "redhat-lsb" | ||
"el" | ||
else | ||
"debian" | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
ruby_block "get jdbc password" do | ||
block do | ||
app_name = node['tomcat']['application'] | ||
app_env = node['app_env'] | ||
bag, item = node[:passwd_data_bag].split('/') | ||
db = Chef::EncryptedDataBagItem.load(bag, item) | ||
node['tomcat']['jdbc']['password'] = db[app_name][app_env]['jdbc'] | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
|
||
ruby_block "load jdbc parameters" do | ||
block do | ||
app_name = node['tomcat']['application'] | ||
db = data_bag_item("apps", app_name)[node['app_env']] | ||
node['tomcat']['java_opts'] = db['java_opts'] | ||
node['tomcat']['jdbc']['schema'] = db['jdbc']['schema'] | ||
node['tomcat']['jdbc']['user'] = db['jdbc']['user'] | ||
node['tomcat']['jdbc']['host'] = db['jdbc']['host'] | ||
jdbc_url = "jdbc:#{node['tomcat']['jdbc']['driver']['name']}://" + | ||
"#{node['tomcat']['jdbc']['host']}:" + | ||
"#{node['tomcat']['jdbc']['port']}/" + | ||
"#{node['tomcat']['jdbc']['schema']}" | ||
node['tomcat']['jdbc']['url'] = jdbc_url | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
# | ||
# Cookbook Name:: tomcat | ||
# Recipe:: webapp_jdbc | ||
# Author:: Bryan W. Berry (<bryan.berry@gmail.com>) | ||
# Copyright 2012, Food and Agriculture Organization of the United Nations | ||
# | ||
# license Apache v2.0 | ||
# | ||
|
||
include_recipe "ark" | ||
include_recipe "tomcat::base" | ||
include_recipe "maven" | ||
include_recipe "tomcat::_jdbc_password" | ||
include_recipe "tomcat::_load_jdbc_params" | ||
|
||
t = tomcat node['tomcat']['user'] do | ||
user node['tomcat']['user'] | ||
action :install | ||
jvm_opts node['tomcat']['java_opts'] | ||
end | ||
|
||
maven node['tomcat']['jdbc']['driver']['name'] do | ||
groupId node['tomcat']['jdbc']['driver']['name'] | ||
version node['tomcat']['jdbc']['driver']['version'] | ||
dest "#{t.base}/lib" | ||
owner node['tomcat']['user'] | ||
end | ||
|
||
directory "#{t.base}/conf/Catalina/localhost" do | ||
recursive true | ||
owner node['tomcat']['user'] | ||
end | ||
|
||
template "jdbc context" do | ||
path "#{t.base}/conf/Catalina/localhost/#{node['tomcat']['application']}.xml" | ||
source "context.xml.erb" | ||
owner node['tomcat']['user'] | ||
end | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
<Context path="/<%= node['tomcat']['application'] %>" debug="0" useHttpOnly="true"> | ||
|
||
<Resource name="UserTransaction" auth="Container" type="javax.transaction.UserTransaction" | ||
factory="org.objectweb.jotm.UserTransactionFactory" jotm.timeout="60"/> | ||
|
||
|
||
<Resource name="jdbc/<%= node['tomcat']['application'].capitalize %>DS" auth="Container" | ||
type="javax.sql.DataSource" | ||
username="<%= node['tomcat']['jdbc']['user'] %>" | ||
password="<%= node['tomcat']['jdbc']['password'] %>" | ||
driverClassName="<%= node['tomcat']['jdbc']['driver']['name'] %>" | ||
url="<%= node['tomcat']['jdbc']['url'] %>" | ||
maxActive="20" | ||
validationQuery="select 1" | ||
/> | ||
</Context> |