Coder Social home page Coder Social logo

chef-tomcat's Introduction

Description

Installs and configures the Tomcat, Java servlet engine and webserver.

Requirements

Platform:

  • CentOS, Red Hat, Fedora (OpenJDK)

The following Opscode cookbooks are dependencies:

  • java, ark, maven

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
  • package.rb -- installs tomcat7 unless node['tomcat']['version'] set to 6. The package typically installs a system service.
  • ark.rb installs a vanilla tomcat and creates a service
  • base.rb installs the tomcat from the binary provided by tomcat.apache.org, will use version 7 unless node['tomcat']['version'] set to 6. No tomcat service is installed.

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

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}

base

It creates an installation of tomcat to prefix_dir. It does very little besides that.

By default it uses the tomcat 7 by including tomcat7 recipe

This recipe is intended to be used together with the CATALINA_BASE method to install 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

and creates a symlink to that directory

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

Resources/Providers

tomcat

Actions

  • :install: install
  • :remove: remove the instance

Attribute Parameters

  • http_port: port_num or true/false, default to true and 8080
  • ajp_port: port_num or true/false, default to true and 8009
  • shutdown_port: port_num or true/false, default to 8005
  • host_name: name for Host element, defaults to localhost
  • session_timeout: global session timeout set in conf/web.xml
  • unpack_wars: defaults to true
  • auto_deploy: defaults to true
  • jvm_opts: Array of options for the JVM
  • jmx_opts: Array of JMX monitoring options
  • jmx_access: String containing username and access permissions, will be written to the jmxremote.access file
  • jmx_password: String containing username and password, will be written to the jmxremote.password file
  • jmx_access_file: the file that the access role and permissions will be written to, defaults to CATALINA_BASE/conf/jmxremote.access
  • jmx_password_file: the file that the username and password will be written to, defaults to CATALINA_BASE/conf/jmxremote.password
  • manage_config_file: whether to update the configuration files /etc/default/app_name, CATALINA_BASE/conf/server.xml, and /etc/init.d/app_name after initial creation. If false, those files will not be changed after initial templating. Useful if you have devs who want control of their tomcat instance but don't want to learn chef. Great for massive configuration drift.
  • webapp_opts: (Deprecated) Array of directives passed to a webapp
  • more_opts: (Deprecated) crap that doesn't fit anywhere else
  • service_name: an alternate name for the init script, useful if you are using a clustering tool like Pacemaker or heartbeat to manage the tomcat service
  • clustered: set to true if you do not want the tomcat service to start automatically, defaults to false
  • env: environment variables to export in init script
  • user: user to run the tomcat as
  • shutdown_wait: how long the shutdown script should wait before killing the process

An exception will be thrown if one of the values specified by *_port is already in use by another tomcat lwrp

Example

tomcat "pentaho" do
  http_port  false
  https_port "8443"
  version    "7"
end

To deploy a webapp to the new tomcat, you use a deploy resource or a maven resource (coming soon).

Example using JMX

tomcat "liferay" do
  user liferay_user
  action :install
  jvm_opts node['liferay']['jvm_opts']
  jmx_opts node['liferay']['jmx_opts']
  jmx_access node['liferay']['jmx_access']
  jmx_password node['liferay']['jmx_password']
end

Clustered configuration

tomcat "liferay" do
  user liferay_user
  action :install
  jvm_opts node['liferay']['jvm_opts']
  service_name "liferay-tomcat"
  clustered true
end

TODO

License and Author

Author:: Bryan W. Berry ([email protected])

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. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

chef-tomcat's People

Contributors

bryanwb avatar nathenharvey avatar schisamo avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

chef-tomcat's Issues

Default recipe fails (ubuntu-12.04 w/ vagrant)

Included are the relevant lines from the vagrant output. This happens on a fresh ubuntu-12.04 install.

2012-09-24T03:22:00+00:00] INFO: Processing package[tomcat7] action install (tomcat::package line 46)
[2012-09-24T03:22:00+00:00] DEBUG: package[tomcat7] checking package status for tomcat7
[2012-09-24T03:22:00+00:00] DEBUG: package[tomcat7] current version is nil
[2012-09-24T03:22:00+00:00] DEBUG: package[tomcat7] candidate version is 7.0.26-1ubuntu1.1
[2012-09-24T03:22:00+00:00] DEBUG: Executing apt-get -q -y install tomcat7=7.0.26-1ubuntu1.1
[2012-09-24T03:22:14+00:00] DEBUG: ---- Begin output of apt-get -q -y install tomcat7=7.0.26-1ubuntu1.1 ----
[2012-09-24T03:22:14+00:00] DEBUG: STDOUT: Reading package lists...
Building dependency tree...
Reading state information...
The following extra packages will be installed:
authbind libcommons-collections3-java libcommons-dbcp-java
libcommons-pool-java libecj-java libservlet3.0-java libtomcat7-java

/opt/ruby/lib/ruby/gems/1.9.1/gems/chef-10.14.2/lib/chef/mixin/template.rb:43:in rescue in render_template' /opt/ruby/lib/ruby/gems/1.9.1/gems/chef-10.14.2/lib/chef/mixin/template.rb:39:inrender_template'
/opt/ruby/lib/ruby/gems/1.9.1/gems/chef-10.14.2/lib/chef/provider/template.rb:104:in render_with_context' /opt/ruby/lib/ruby/gems/1.9.1/gems/chef-10.14.2/lib/chef/provider/template.rb:50:inaction_create'
/opt/ruby/lib/ruby/gems/1.9.1/gems/chef-10.14.2/lib/chef/provider.rb:119:in run_action' /opt/ruby/lib/ruby/gems/1.9.1/gems/chef-10.14.2/lib/chef/resource.rb:593:inrun_action'
/opt/ruby/lib/ruby/gems/1.9.1/gems/chef-10.14.2/lib/chef/runner.rb:49:in run_action' /opt/ruby/lib/ruby/gems/1.9.1/gems/chef-10.14.2/lib/chef/runner.rb:81:inblock (2 levels) in converge'
/opt/ruby/lib/ruby/gems/1.9.1/gems/chef-10.14.2/lib/chef/runner.rb:81:in each' /opt/ruby/lib/ruby/gems/1.9.1/gems/chef-10.14.2/lib/chef/runner.rb:81:inblock in converge'
/opt/ruby/lib/ruby/gems/1.9.1/gems/chef-10.14.2/lib/chef/resource_collection.rb:94:in block in execute_each_resource' /opt/ruby/lib/ruby/gems/1.9.1/gems/chef-10.14.2/lib/chef/resource_collection/stepable_iterator.rb:116:incall'
/opt/ruby/lib/ruby/gems/1.9.1/gems/chef-10.14.2/lib/chef/resource_collection/stepable_iterator.rb:116:in call_iterator_block' /opt/ruby/lib/ruby/gems/1.9.1/gems/chef-10.14.2/lib/chef/resource_collection/stepable_iterator.rb:85:instep'
/opt/ruby/lib/ruby/gems/1.9.1/gems/chef-10.14.2/lib/chef/resource_collection/stepable_iterator.rb:104:in iterate' /opt/ruby/lib/ruby/gems/1.9.1/gems/chef-10.14.2/lib/chef/resource_collection/stepable_iterator.rb:55:ineach_with_index'
/opt/ruby/lib/ruby/gems/1.9.1/gems/chef-10.14.2/lib/chef/resource_collection.rb:92:in execute_each_resource' /opt/ruby/lib/ruby/gems/1.9.1/gems/chef-10.14.2/lib/chef/runner.rb:80:inconverge'
/opt/ruby/lib/ruby/gems/1.9.1/gems/chef-10.14.2/lib/chef/client.rb:378:in converge' /opt/ruby/lib/ruby/gems/1.9.1/gems/chef-10.14.2/lib/chef/client.rb:420:indo_run'
/opt/ruby/lib/ruby/gems/1.9.1/gems/chef-10.14.2/lib/chef/client.rb:176:in run' /opt/ruby/lib/ruby/gems/1.9.1/gems/chef-10.14.2/lib/chef/application/client.rb:283:inblock in run_application'
/opt/ruby/lib/ruby/gems/1.9.1/gems/chef-10.14.2/lib/chef/application/client.rb:270:in loop' /opt/ruby/lib/ruby/gems/1.9.1/gems/chef-10.14.2/lib/chef/application/client.rb:270:inrun_application'
/opt/ruby/lib/ruby/gems/1.9.1/gems/chef-10.14.2/lib/chef/application.rb:70:in run' /opt/ruby/lib/ruby/gems/1.9.1/gems/chef-10.14.2/bin/chef-client:26:in<top (required)>'
/opt/ruby/bin/chef-client:19:in load' /opt/ruby/bin/chef-client:19:in

'
[2012-09-24T03:22:15+00:00] FATAL: Chef::Mixin::Template::TemplateError: undefined method `shutdown_wait' for #Hash:0x86fb654
The following SSH command responded with a non-zero exit status.
Vagrant assumes that this means the command failed!

chef-client -c /tmp/vagrant-chef-1/client.rb -j /tmp/vagrant-chef-1/dna.json

Init script stop process is problematic (or is it just me?)

Prefer this Tomcat to any others I've seen. Thanks for the great work, Brian (and others). Am having an issue with the init script shutdown function. Curious if anyone else is experiencing this:

$ sudo service tomcat7 restart
Error: Exception thrown by the agent : java.rmi.server.ExportException: Port already in use: 9000; nested exception is:
    java.net.BindException: Address already in use
Application still alive, sleeping for 20 seconds before sending SIGKILL
Killed with extreme prejudice
Using CATALINA_BASE:   /usr/local/tomcat/default
Using CATALINA_HOME:   /usr/local/tomcat/default
Using CATALINA_TMPDIR: /usr/local/tomcat/default/temp
Using JAVA_HOME:       /usr/lib/jvm/java
Using CLASSPATH:       /usr/local/tomcat/default/bin/tomcat-juli.jar:/usr/local/tomcat/default/bin/bootstrap.jar

Issue appears to be related to this:
https://issues.apache.org/bugzilla/show_bug.cgi?id=36976

Solution appears to be to only pass CATALINA_OPTS to shutdown, vs sending all JAVA_OPTS though I'm presently not literate enough as it relates to multi-instance Tomcat (not using it) to know if that breaks it. Will investigate. At the very least, perhaps ensuring that JAVA_OPTS does not include JMX_OPTS when performing shutdown will fix the bug. Will hack a bit at it early next week and report back. Just posting this as the fact that nobody else has mentioned it leads me to suspect PEBKAC. If anyone else has anything to share on the topic, would love to hear your thoughts before I commence to shaving that yak come Monday. Cheers!

ToddMichael

undefined method 'join' when used with chef-solo (packer.io)

Using chef-solo with version 11.10.4 via packer.io 0.51:

complains about Chef::Mixin:Template::TemplateError (undefined methoed `join' for " ..jvm_opts values... ").

Workaround, modify /templates/default/default_tomcat.erb, replace JAVA_OPTS with JAVA_OPTS="<%= @TOMCAT['jvm_opts'] %>"

Merge into official tomcat cookbook

Hey Bryan! I'm guessing the only reason this hasn't been done is because of the ark dependency, huh? What would have to happen in order to allow it to be merged? Would ark need to become an official opscode cookbook?

Just wondering, as you seem to be onto the right idea with this :)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.