Created
October 31, 2011 13:45
-
-
Save vhata/1327526 to your computer and use it in GitHub Desktop.
Tomcat Chef recipe
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
default[:tomcat][:standalone] = false | |
default[:tomcat][:port] = 8009 | |
default[:tomcat][:timeout] = 30 | |
default[:tomcat][:default_host] = 'localhost' | |
# java options | |
default[:tomcat][:java_opts] = [] | |
# listeners handle events across the server. The following are defaults | |
# which will probably be enough. The jasper listener will be needed where jsp | |
# are used. | |
# If Apr then add AprLifecycleListener | |
# If Jsp then add JasperListener | |
# If MBean then add ServerLifecycleListener | |
# If JNDI then add GlobalResourcesLifecycleListener | |
# | |
default[:tomcat][:listeners] = [] | |
normal[:tomcat][:default_host] = 'brell.yola.net' | |
normal[:tomcat]['vhosts']['brell.yola.net']['app'] = 'brell' | |
normal[:tomcat]['vhosts']['brell.yola.net']['base'] = 'brell' | |
normal[:tomcat]['vhosts']['brell.yola.net']['path'] = '/' |
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
# | |
# Cookbook Name:: tomcat | |
# Recipe:: default | |
# | |
# Copyright 2011, Yola | |
# | |
# All rights reserved - Do Not Redistribute | |
# | |
package 'tomcat6' do | |
action :install | |
end | |
service 'tomcat6' do | |
action :nothing | |
end | |
# defaults file read by init script | |
template 'tomcat6' do | |
action :create | |
source 'defaults-tomcat6.erb' | |
path '/etc/default/tomcat6' | |
owner 'root' | |
group 'root' | |
mode 0644 | |
variables(:opts => node[:tomcat]) | |
notifies :restart, "service[tomcat6]" | |
end | |
# main server configuration | |
template 'server.xml' do | |
action :create | |
source 'server.xml.erb' | |
path '/etc/tomcat6/server.xml' | |
owner 'root' | |
group 'tomcat6' | |
mode 0644 | |
# we have to use to_hash on the next line because we do a .each do |fqdn,cnf| in the template, which is a | |
# dictionary-like each, and the node thing behaves like a list, not a dictionary | |
variables(:opts => node[:tomcat].to_hash) | |
notifies :restart, "service[tomcat6]" | |
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
<?xml version='1.0' encoding='utf-8'?> | |
<!-- Sending shutdown to server port is only available on windows, disabling (port=-1) since we dont use windows. --> | |
<Server port="-1" shutdown="SHUTDOWN"> | |
<!-- listeners define handlers for triggers across the server --> | |
<% @opts['listeners'].each do |listener| %> | |
<Listener className="<%= listener %>" /> | |
<% end %> | |
<Service name="Catalina"> | |
<Connector port="<%= @opts['port'] %>" protocol="AJP/1.3" connectionTimeout="<%= @opts['timeout'] %>" useIPVHosts="true" URIEncoding="UTF-8" tomcatAuthentication="false"/> | |
<Engine name="Catalina" defaultHost="<%=@opts['default_host']%>"> | |
<!-- Virtual Hosts --> | |
<% @opts['vhosts'].each do |fqdn,cnf| -%> | |
<Host | |
name="<%=fqdn%>" | |
appBase="<%=cnf['app']%>" | |
unpackWARs="true" | |
autoDeploy="true"> | |
<Context | |
displayName="<%=fqdn%>" | |
docBase="<%=cnf['base']%>" | |
path="<%=cnf['path']%>" /> | |
<Valve | |
className="org.apache.catalina.valves.AccessLogValve" | |
directory="logs" | |
prefix="<%=cnf['app']%>_access_log." | |
suffix=".log" | |
pattern="common" | |
resolveHosts="false"/> | |
</Host> | |
<% end -%> | |
</Engine> | |
</Service> | |
</Server> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment