Skip to content

Commit

Permalink
basic recipe install tomcat 6 and 7 on ubuntu 11.10
Browse files Browse the repository at this point in the history
  • Loading branch information
bryanwb committed Feb 12, 2012
1 parent f209aa8 commit 44854e0
Show file tree
Hide file tree
Showing 6 changed files with 226 additions and 51 deletions.
25 changes: 17 additions & 8 deletions tomcat/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ Attributes
* prefix_dir - /usr/local/, /var/lib/, etc.

Recipes
==========
=======

* default.rb -- installs tomcat via debian package only on a
debian based distribution. Otherwise installs via tomcat7_binary.rb
Expand All @@ -34,8 +34,19 @@ to 6. No tomcat service is installed.

All of the default webapps such as "ROOT" and "manager" are removed in the tomcat::ark recipe

binary
------
ark
---

This recipe creates a vanilla tomcat installation based on the tarball
of bytecode available from http://tomcat.apache.org and places it in
${prefix_dir}. Additionally, it configures a system v
init script and creates the symlink

${prefix_dir}/tomcat/default -> ${prefix_dir}/tomcat/tomcat{6,7}


ark_base
--------

It creates an installation of tomcat to prefix_dir. It does very
little besides that.
Expand All @@ -46,11 +57,11 @@ This recipe is intended to be used together with the CATALINA_BASE method to ins
multiple tomcat instances that use the same set of tomcat installation
files. This recipe does not add any services. It is intended to be used together with the tomcat lwrp.

${prefix_dir}/tomcat/tomcat{6,7} # CATALINA_HOME
${prefix_dir}/tomcat/tomcat{6,7} # CATALINA_HOME

and creates a symlink to that directory

${prefix_dir}/tomcat/default -> ${prefix_dir}/tomcat/tomcat{6,7}
${prefix_dir}/tomcat/default -> ${prefix_dir}/tomcat/tomcat{6,7}



Expand Down Expand Up @@ -81,14 +92,12 @@ tomcat
- unpack_wars: defaults to true
- auto_deploy: defaults to true
- version: 6 or 7
- webapp_url: url to tarball or to a single .war file. The tarball
may hold multiple war files #TODO add maven support
- webapps_dir: location of the webapps directory
- tmp_dir: location of temporary directory
- work_dir: location of work directory
- java_opts: hash of options for the JVM
- jmx_opts: hash of JMX monitoring options
- webapps_opts: hash of directives passed to the webapp
- webapp_opts: hash of directives passed to the webapp
- user: user to run the tomcat as
- java_home: location of JDK

Expand Down
56 changes: 30 additions & 26 deletions tomcat/attributes/default.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
# Author:: Bryan Berry (<[email protected]>)
#
# Copyright 2010, Opscode, Inc.
# Copyright 2012, Bryan W. Berry
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
Expand All @@ -17,35 +18,38 @@
# See the License for the specific language governing permissions and
# limitations under the License.

default["tomcat"]["version"] = "6"
default["tomcat"]["version"] = "7"
version = node["tomcat"]["version"]
default["tomcat"]["prefix_dir"] = "/usr/local"
prefix_dir = node["tomcat"]["prefix_dir"]
default["tomcat"]["home"] = "#{prefix_dir}/tomcat/tomcat#{version}"
default["tomcat"]["base"] = "#{prefix_dir}/tomcat/tomcat#{version}"
tomcat_base = node["tomcat"]["base"]
default["tomcat"]["context_dir"] = "#{tomcat_base}/conf/Catalina/localhost"
default["tomcat"]["log_dir"] = "#{tomcat_base}/logs"
default["tomcat"]["tmp_dir"] = "#{tomcat_base}/temp"
default["tomcat"]["work_dir"] = "#{tomcat_base}/work"
default["tomcat"]["webapp_dir"] = "#{tomcat_base}/webapps"

# runtime settings
default["tomcat"]["use_security_manager"] = false
default["tomcat"]["user"] = "tomcat"
default["tomcat"]["group"] = "tomcat"
default["tomcat"]["port"] = 8080
default["tomcat"]["ssl_port"] = 8443
default["tomcat"]["ajp_port"] = 8009
default["tomcat"]["java_opts"] = "-Xmx128M -Djava.awt.headless=true"
default["tomcat"]["use_security_manager"] = false
default["tomcat"]["shutdown_port"] = 8005
default["tomcat"]["unpack_wars"] = true
default["tomcat"]["auto_deploy"] = true

case platform
when "centos","redhat","fedora"
default["tomcat"]["user"] = "tomcat"
default["tomcat"]["group"] = "tomcat"
default["tomcat"]["home"] = "/usr/share/tomcat6"
default["tomcat"]["base"] = "/usr/share/tomcat6"
default["tomcat"]["context_dir"] = "#{tomcat["config_dir"]}/Catalina/localhost"
when "debian","ubuntu"
default["tomcat"]["user"] = "tomcat6"
default["tomcat"]["group"] = "tomcat6"
default["tomcat"]["home"] = "/usr/share/tomcat6"
default["tomcat"]["base"] = "/var/lib/tomcat6"
default["tomcat"]["config_dir"] = "/etc/tomcat6"
default["tomcat"]["log_dir"] = "/var/log/tomcat6"
default["tomcat"]["tmp_dir"] = "/tmp/tomcat6-tmp"
default["tomcat"]["work_dir"] = "/var/cache/tomcat6"
default["tomcat"]["context_dir"] = "#{tomcat["config_dir"]}/Catalina/localhost"
default["tomcat"]["webapp_dir"] = "/var/lib/tomcat6/webapps"
end
# all the *_opts are later combined into CATALINA_OPTS
default["tomcat"]["java_opts"] = "-Xmx128M -Djava.awt.headless=true"
default["tomcat"]["jmx_opts"] = ""
default["tomcat"]["webapp_opts"] = ""
default["tomcat"]["more_opts"] = ""

default['tomcat']['6']['url'] = ''
default['tomcat']['6']['checksum'] = ''
default['tomcat']['7']['url'] = ''
default['tomcat']['7']['checksum'] = ''
# urls for arks and sha256 checksum for each
default['tomcat']['6']['url'] = 'http://www.apache.org/dist/tomcat/tomcat-6/v6.0.35/bin/apache-tomcat-6.0.35.tar.gz'
default['tomcat']['6']['checksum'] = 'b28c9cbc2a8ef271df646a50410bab7904953b550697efb5949c9b2d6a9f3d53'
default['tomcat']['7']['url'] = 'http://www.apache.org/dist/tomcat/tomcat-7/v7.0.25/bin/apache-tomcat-7.0.25.tar.gz'
default['tomcat']['7']['checksum'] = '7ba03b6703b43da6868613fd625bfb13a791d57478b4a4e49bdb56f9fc3994b4'
16 changes: 10 additions & 6 deletions tomcat/recipes/package.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,25 +18,29 @@
# limitations under the License.
#

# let's set the tomcat attributes to the ones that match the ubuntu packages
version = node['tomcat']['version']
# let's set the tomcat attributes to the ones that match the ubuntu
# packages, damn the FHS

version = node['tomcat']['version'].to_s
node["tomcat"]["user"] = "tomcat#{version}"
node["tomcat"]["group"] = "tomcat#{version}"
node["tomcat"]["home"] = "/usr/share/tomcat#{version}"
node["tomcat"]["base"] = "/var/lib/tomcat#{version}"
node["tomcat"]["config_dir"] = "/etc/tomcat#{version}"
config_dir = node["tomcat"]["config_dir"]
node["tomcat"]["log_dir"] = "/var/log/tomcat#{version}"
node["tomcat"]["tmp_dir"] = "/tmp/tomcat#{version}-tmp"
node["tomcat"]["work_dir"] = "/var/cache/tomcat#{version}"
node["tomcat"]["context_dir"] = "#{tomcat["config_dir"]}/Catalina/localhost"
node["tomcat"]["context_dir"] = "#{config_dir}/Catalina/localhost"
node["tomcat"]["webapp_dir"] = "/var/lib/tomcat#{version}/webapps"

# this recipe only supports debian or ubuntu
unless platform? ["debian", "ubuntu"]
Chef::Application::fatal!("This recipe only supports Ubuntu or Debian")
end

tomcat_pkgs = ["tomcat#{version}", "tomcat#{version}-admin"]
tomcat_pkgs = [ "tomcat#{version}", "tomcat#{version}-admin"]


tomcat_pkgs.each do |pkg|
package pkg do
Expand All @@ -51,7 +55,7 @@
end

template "/etc/default/tomcat#{version}" do
source "default_tomcat6.erb"
source "package_default_tomcat6.erb"
owner "root"
group "root"
mode "0644"
Expand All @@ -60,7 +64,7 @@


template "/etc/tomcat#{version}/server.xml" do
source "server.xml.erb"
source "server.tomcat#{version}.xml.erb"
owner "root"
group "root"
mode "0644"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ CATALINA_BASE=<%= node["tomcat"]["base"] %>

# You may pass JVM startup parameters to Java here. If unset, the default
# options (-Djava.awt.headless=true -Xmx128m) will be used.
JAVA_OPTS="<%= node["tomcat"]["java_options"] %>"
JAVA_OPTS="<%= node["tomcat"]["java_opts"] %>"

# Use a CMS garbage collector for improved response time
JAVA_OPTS="${JAVA_OPTS} -XX:+UseConcMarkSweepGC"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
define subcomponents such as "Valves" at this level.
Documentation at /docs/config/server.html
-->
<Server port="8005" shutdown="SHUTDOWN">
<Server port="<%= node['tomcat']['shutdown_port'].to_s %>" shutdown="SHUTDOWN">

<!--APR library loader. Documentation at /docs/apr.html -->
<!--
Expand Down Expand Up @@ -72,10 +72,11 @@
APR (HTTP/AJP) Connector: /docs/apr.html
Define a non-SSL HTTP/1.1 Connector on port <%= node["tomcat"]["port"] %>
-->
<Connector port="<%= node["tomcat"]["port"] %>" protocol="HTTP/1.1"
connectionTimeout="20000"
<Connector port="<%= node["tomcat"]["port"].to_s %>"
protocol="HTTP/1.1"
connectionTimeout="20000"
URIEncoding="UTF-8"
redirectPort="<%= node["tomcat"]["ssl_port"] %>" />
redirectPort="<%= node["tomcat"]["ssl_port"].to_s %>" />
<!-- A "Connector" using the shared thread pool-->
<!--
<Connector executor="tomcatThreadPool"
Expand All @@ -87,14 +88,17 @@
This connector uses the JSSE configuration, when using APR, the
connector should be using the OpenSSL style configuration
described in the APR documentation -->
<!--
<Connector port="<%= node["tomcat"]["ssl_port"] %>" protocol="HTTP/1.1" SSLEnabled="true"
<!--
<Connector port="<%= node["tomcat"]["ssl_port"].to_s %>"
protocol="HTTP/1.1" SSLEnabled="true"
maxThreads="150" scheme="https" secure="true"
clientAuth="false" sslProtocol="TLS" />
-->
-->

<!-- Define an AJP 1.3 Connector on port <%= node["tomcat"]["ajp_port"] %> -->
<Connector port="<%= node["tomcat"]["ajp_port"] %>" protocol="AJP/1.3" redirectPort="<%= node["tomcat"]["ssl_port"] %>" />
<Connector port="<%= node["tomcat"]["ajp_port"].to_s %>"
protocol="AJP/1.3"
redirectPort="<%= node["tomcat"]["ssl_port"].to_s %>" />


<!-- An Engine represents the entry point (within Catalina) that processes
Expand Down Expand Up @@ -133,7 +137,8 @@
Note: XML Schema validation will not work with Xerces 2.2.
-->
<Host name="localhost" appBase="webapps"
unpackWARs="true" autoDeploy="true"
unpackWARs="<%= node['tomcat']['unpack_wars'].to_s %>"
autoDeploy="<%= node['tomcat']['auto_deploy'].to_s %>"
xmlValidation="false" xmlNamespaceAware="false">

<!-- SingleSignOn valve, share authentication between web applications
Expand All @@ -152,4 +157,4 @@
</Host>
</Engine>
</Service>
</Server>
</Server>
Loading

0 comments on commit 44854e0

Please sign in to comment.