top of page

Agnuslims in the Middle East

Public·9 members

Apache Tomcat Cookbook

Installs Apache Tomcat and configures the HTTPS listener. If the node['tomcat']['forward_ports'] attribute is true (default value), the recipe also configures port forwarding (80 to 8080 and 443 to 8443) using the iptables or firewalld recipes.

Apache Tomcat Cookbook

Provides resources for installing Tomcat and managing the Tomcat service for use in wrapper cookbooks. Installs Tomcat from tarballs on the website and installs the appropriate configuration for your platform's init system.

Due to the complexity of Tomcat cookbooks it's not possible to create an attribute driven cookbook that solves everyone's problems. Instead this cookbook provides resources for installing Tomcat and managing the Tomcat service, which are best used in your own wrapper cookbook. The best way to understand how this could be used is to look at the helloworld test recipe located at -cookbooks/tomcat/blob/master/test/cookbooks/test/recipes/helloworld_example.rb

tomcat_install installs an instance of the tomcat binary direct from Apache's mirror site. As distro packages are not used we can easily deploy per-instance installations and any version available on the Apache archive site can be installed.

COMPATIBILIY WARNING!!!! This version removes the existing recipes, attributes, and instance provider in favor of the new tomcat_install and tomcat_service resources. Why not just leave them in place? Well unfortunately they were utterly broken for anything other than the most trivial usage. Rather than continue the user pain we've opted to remove them and point users to a more modern installation method. If you need the legacy installation methods simply pin to the 1.3.0 release.

5.0.9 passed this metric Contributing File Metric 5.0.9 failed this metric Failure: To pass this metric, your cookbook metadata must include a source url, the source url must be in the form of , and your repo must contain a file Cookstyle Metric 5.0.9 passed this metric No Binaries Metric 5.0.9 passed this metric Testing File Metric 5.0.9 failed this metric Failure: To pass this metric, your cookbook metadata must include a source url, the source url must be in the form of , and your repo must contain a file Version Tag Metric 5.0.9 failed this metric Failure: To pass this metric, your cookbook metadata must include a source url, the source url must be in the form of , and your repo must include a tag that matches this cookbook version number sous-chefs Sous Chefs Details View Source View Issues Updated March 1, 2023 Created on November 29, 2010 Supported Platforms License Apache-2.0

Let us look at how to run a web project with Tomcat 7. The steps will be identical for Tomcat 6, except that the plugin would be tomcat6-maven-plugin instead of tomcat7-maven-plugin, and the plugin prefix would be tomcat6 instead of tomcat7.

Due to the multitude of Java implementations you might want to use, this cookbook does not attempt to address the installation of a JRE/JDK. Please make sure that Java has been configured on the machine prior to the application any resources or recipes shipped in this cookbook.

To run multiple instances of Tomcat, populate the instances attribute, which is a dictionary of instance name => array of attributes. Most of the same attributes that can be used globally for the tomcat cookbook can also be set per-instance - see resources/instance.rb for details.

If they are not set for a particular instance, the base, home, config_dir, log_dir, work_dir, context_dir, and webapp_dir attributes are created by modifying the global values to use the instance name. For example, under Tomcat 7, with home /usr/share/tomcat7, home for instance "instance1" would be set to /usr/share/tomcat7-instance1. The port attributes - port, proxy_port, ssl_port, ssl_proxy_port, ajp_port, and shutdown_port - are not inherited and must be set per-instance, ajp_redirect_port is also not inherited but defaults to ssl_port. The ajp_listen_ip is also not inherited and must be set per instance, when not set it defaults to listening on all adresses. Other attributes that are not set are inherited unmodified from the global attributes. Each instance must define shutdown_port, and at least one of port, ssl_port or ajp_port.

Users are defined by creating a tomcat_users data bag and placing Encrypted Data Bag Items in that data bag. Each encrypted data bag item requires an 'id', 'password', and a 'roles' field. The data bag key is retrieved from the default location /etc/chef/encrypted_data_bag_secret.

This cookbook is currently undergoing a ground up rewrite that will convert it to a pure library cookbook, more appropriate for the multitude of ways that Tomcat can be installed. The existing attribute driven installs and tomcat_instance provider will eventually be deprecated in favor of a provider for installation, service management, and 1 or more providers for configuration.

tomcat::setup recipe is largely a metarecipe. It includes a set of dependent recipes that handle most of the details of installing and configuring Tomcat and related packages. The first part of tomcat::setup runs the following recipes, which are discussed later:

You can often save time and effort by using built-in recipes to perform some of the required tasks. This recipe uses the built in apache2::default recipe to install Apache rather than implementing it from scratch. For another example of how to use built-in recipes, see Deploy Recipes.

The Tomcat version is specified by the ['tomcat']['base_version'] attribute, which is set to 6 in the attributes file. To install Tomcat 7, you can use custom JSON attributes to override the attribute. Just edit your stack settings and enter the following JSON in the Custom Chef JSON box, or add it to any existing custom JSON:

The recipe uses the Chef service resource to specify the Tomcat service name (tomcat6, by default) and sets the supports attribute to define how Chef manages the service's restart, reload, and status commands on the different operating systems.

Notice that the action is set to :nothing. For each lifecycle event, AWS OpsWorks Stacks initiates a Chef run to execute the appropriate set of recipes. The Tomcat cookbook follows a common pattern of having a recipe create the service definition, but not restart the service. Other recipes in the Chef run handle the restart, typically by including a notifies command in the template resources that are used to create configuration files. Notifications are a convenient way to restart a service because they do so only if the configuration has changed. In addition, if a Chef run has multiple restart notifications for a service, Chef restarts the service at most once. This practice avoids problems that can occur when attempting to restart a service that is not fully operational, which is a common source of Tomcat errors.

The Tomcat service must be defined for any Chef run that uses restart notifications. tomcat::service is therefore included in several recipes, to ensure that the service is defined for every Chef run. There is no penalty if a Chef run includes multiple instances of tomcat::service because Chef ensures that a recipe executes only once per run, regardless of how many times it is included.

The recipe first calls tomcat::service, which defines the service if necessary. The bulk of the recipe consists of two template resources, each of which creates a configuration file from one of the cookbook's template files, sets the file properties, and notifies Chef to restart the service.

The first template resource uses the tomcat_env_config.erb template file to create a Tomcat environment configuration file, which is used to set environment variables such as JAVA_HOME. The default file name is the template resource's argument. tomcat::container_config uses a path attribute to override the default value and name the configuration file /etc/sysconfig/tomcat6 (Amazon Linux) or /etc/default/tomcat6 (Ubuntu). The template resource also specifies the file's owner, group, and mode settings and directs Chef to not create backup files.

If you look at the source code, there are actually three versions of tomcat_env_config.erb, each in a different subdirectory of the templates directory. The ubuntu and amazon directories contain the templates for their respective operating systems. The default folder contains a dummy template with a single comment line, which is used only if you attempt to run this recipe on an instance with an unsupported operating system. The tomcat::container_config recipe doesn't need to specify which tomcat_env_config.erb to use. Chef automatically picks the appropriate directory for the instance's operating system based on rules described in File Specificity.

JAVA_OPTS can be used to specify Java options such as the library path. Using the default attribute values, the template sets no Java options for Amazon Linux. You can set your own Java options by overriding the ['tomcat']['java_opts'] attribute, for example, by using custom JSON attributes. For an example, see Create a Stack.

The tomcat::apache_tomcat_bind recipe enables the Apache server to act as Tomcat's front end, receiving incoming requests and forwarding them to Tomcat and returning the responses to the client. This example uses mod_proxy as the Apache proxy/gateway.

The template resource uses apache_tomcat_bind.conf.erb to create a configuration file, named tomcat_bind.conf by default. It places the file in the ['apache']['dir']/.conf.d directory. The ['apache']['dir'] attribute is defined in the built-in apache2 attributes file, and is set by default to /etc/httpd (Amazon Linux), or /etc/apache2 (Ubuntu). If the template resource creates or changes the configuration file, the notifies command schedules an Apache service restart. 041b061a72


Welcome to the group! You can connect with other members, ge...
Group Page: Groups_SingleGroup
bottom of page