Giter Club home page Giter Club logo

tomcat's Introduction

tomcat Cookbook

Cookbook Version CI State OpenCollective OpenCollective License

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

Requirements

Platforms

  • Debian / Ubuntu derivatives
  • RHEL and derivatives
  • Fedora
  • openSUSE / SUSE Linux Enterprises

Chef

  • Chef 13+

Cookbooks

  • none

Usage

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 https://github.com/chef-cookbooks/tomcat/blob/master/test/cookbooks/test/recipes/helloworld_example.rb

Resources

tomcat_install

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.

properties

  • version: The version to install. Default: 8.5.54
  • version_archive: The filename of the versioned archive to install. Default: apache-tomcat-VERSION.tar.gz
  • install_path: Full path to the install directory. Default: /opt/tomcat_INSTANCENAME_VERSION
  • tarball_base_uri: The base uri to the apache mirror containing the tarballs. Default: `http://archive.apache.org/dist/tomcat/'
  • checksum_base_uri: The base uri to the apache mirror containing the md5 or sha512 file. Default: 'http://archive.apache.org/dist/tomcat/'
  • verify_checksum: Whether the checksum should be verified against checksum_base_uri. Default: true.
  • dir_mode: Directory permissions of the install_path. Default: '0750'.
  • tarball_uri: The complete uri to the tarball. Default: TARBALL_BASE_URI/tomcat-#{major_version(version)}/v#{version}/bin/#{version_archive}.#{version_checksum_algorithm(version)}
  • checksum_uri: The complete uri to the tarball checksum. Default: CHECKSUM_BASE_URI/tomcat-#{major_version(version)}/v#{version}/bin/#{version_archive}.#{version_checksum_algorithm(version)}
  • tarball_path: Local path on disk to the tarball. If the file does not exist, or the checksum does not match, it will be downloaded from tarball_uri.
  • tarball_validate_ssl: Validate the SSL certificate, if tarball_uri is using HTTPS. Default true.
  • exclude_docs: Exclude ./webapps/docs from installation. Default true.
  • exclude_examples: Exclude ./webapps/examples from installation. Default true.
  • exclude_manager: Exclude ./webapps/manager from installation. Default: false.
  • exclude_hostmanager: Exclude ./webapps/host-manager from installation. Default: false.
  • tomcat_user: User to run tomcat as. Default: tomcat_INSTANCENAME
  • tomcat_group: Group of the tomcat user. Default: tomcat_INSTANCENAME
  • tomcat_user_shell: Shell of the tomcat user. Default: /bin/false
  • create_user: Creates the specified tomcat_user within the OS. Default true.
  • create_group: Creates the specified tomcat_group within the OS. Default true.
  • service_template_source: Source template file for the upstart/systemd service definition. Default: init_#{node['init_package']}.erb
  • service_template_cookbook: Cookbook from which to source the upstart/systemd service definition template. Default: tomcat
  • create_symlink: Creates symlink at SYMLINK_PATH to INSTALL_PATH. Default: true
  • symlink_path: Full path to where the symlink will be created targetting INSTALL_PATH. Default: /opt/tomcat_INSTANCE_NAME

example

Install an Tomcat 8.0.36 instance named 'helloworld' to /opt/tomcat_helloworld_8_0_36/ with a symlink at /opt/tomcat_helloworld/

tomcat_install 'helloworld' do
  version '8.0.36'
end

Install an Tomcat instance named 'helloworld' from a local tarball to /opt/tomcat_helloworld_8_0_36/ with a symlink at /opt/tomcat_helloworld/

tomcat_install 'helloworld' do
  version '8.0.36'
  verify_checksum false
  tarball_path '/tmp/apache-tomcat-8.0.36.tar.gz'
end

tomcat_service

tomcat_service sets up the installed tomcat instance to run using the appropriate init system (upstart or systemd)

properties

  • install_path: Full path to the install directory. Default: /opt/tomcat_INSTANCENAME
  • env_vars: An array of hashes containing the environmental variables for Tomcat's setenv.sh script. Note: If CATALINA_BASE is not passed it will automatically be added as the first item in the array. Default: [ {'CATALINA_BASE' => '/opt/INSTANCE_NAME/'}, {'CATALINA_PID' => '$CATALINA_BASE/bin/tomcat.pid'} ]
  • service_vars: An array of hashes containing additional systemd directives when setting up a service under systemd.
  • sensitive: Excludes diffs that may expose ENV values from the chef-client logs. Default: false
  • service_name: The service name to configure. Default: tomcat_INSTANCE_NAME
  • tomcat_user: The user the service runs under
  • tomcat_group: The group the service runs under
  • service_template_source: The service template source for the appropriate init system.
  • service_template_cookbook: The cookbook that contains the service template source template. Default: tomcat
  • service_template_local: Specifies if service_template_source is a local path rather than sourced from a cookbook. Default: false

actions

  • start
  • create
  • stop
  • enable
  • disable
  • restart

example

tomcat_service 'helloworld' do
  action :start
  env_vars [{ 'CATALINA_PID' => '/my/special/path/tomcat.pid' }]
end

Contributors

This project exists thanks to all the people who contribute.

Backers

Thank you to all our backers!

https://opencollective.com/sous-chefs#backers

Sponsors

Support this project by becoming a sponsor. Your logo will show up here with a link to your website.

https://opencollective.com/sous-chefs/sponsor/0/website https://opencollective.com/sous-chefs/sponsor/1/website https://opencollective.com/sous-chefs/sponsor/2/website https://opencollective.com/sous-chefs/sponsor/3/website https://opencollective.com/sous-chefs/sponsor/4/website https://opencollective.com/sous-chefs/sponsor/5/website https://opencollective.com/sous-chefs/sponsor/6/website https://opencollective.com/sous-chefs/sponsor/7/website https://opencollective.com/sous-chefs/sponsor/8/website https://opencollective.com/sous-chefs/sponsor/9/website

tomcat's People

Contributors

b0d0nne11 avatar bob2build avatar cwebberops avatar damacus avatar davidbernick avatar eheydrick avatar ekanaisint avatar elliotkendallucsf avatar guilhem avatar iennae avatar jakauppila avatar juliandunn avatar kitchen-porter avatar mcortesi avatar mengesb avatar nathenharvey avatar ncerny avatar nickpetrovic avatar ramereth avatar renovate[bot] avatar reset avatar ressl avatar rhass avatar rojomisin avatar schisamo avatar sethvargo avatar tas50 avatar thefynx avatar xorima avatar xorimabot avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

tomcat's Issues

What does this cookbook do? Exactly?

I added this to my Chef repository and ran the recipe.

Not sure what the result is. Should there be something up and running? How can it be accessed?

As a suggestion: I would structure cookbook in such a way that with just including recipe you will end up with something that works. Then provide documentation on what is working using the default path.

Then add documentation how things can be improved. Made more secure. Etc etc.

So start with the simplest case and allow for improvements. Rather than start with most complete and complicated case.

OpenSSL changes introduce dependency errors in 0.16.x

The change in the OpenSSL cookbook:
chef-boneyard/openssl@0a1033c

Reflected in the Tomcat cookbook:
ce2183c

Breaks the latest Tomcat release:
https://github.com/opscode-cookbooks/tomcat/blob/v0.16.0/recipes/default.rb#L21

Since Tomcat is not pinning the OpenSSL version:
https://github.com/opscode-cookbooks/tomcat/blob/v0.16.0/metadata.rb#L10

I'd say that we should either backport the master change to the 0.16.0 tree or pin OpenSSL to 2.0.2 - which IMO should be there in the first place.

Add 'address' parameter for Connectors

There isn't currently a means to specify an address parameter for Connectors. This is handy when you have an application (in my case, Solr) that you don't want listening on INADDR_ANY. For example,

<Connector address="<%= @address %>" port="<%= @port %>" protocol="HTTP/1.1" ...

I'm currently using an older version of the Tomcat cookbook and a custom server.xml.erb to get around this, which works well enough. Maybe there's some other place to specify a default address for Connectors to listen on, but if there is, I haven't found it.

Thanks!

missing source_url and issues_url in metadata.rb

generating metadata.json AND/OR uploading to supermarket requires manual intervention to locate the source and issues URLs and add them to the supermarket. as we don't trust humans, this is a job best performed by the computer by reading metadata source code, metadata.rb.
NOTE: old versions of chef (pre 12) may fail when faced with these new attributes

proposed fix:

source_url "https://github.com/opscode-cookbooks/tomcat" if respond_to?(:source_url)
issues_url "https://github.com/opscode-cookbooks/tomcat/issues" if respond_to?(:issues_url)

reference: chef/chef#2937

Multiple instances creates unusable init script

Multiple instances (with ubuntu 14.04) is broken.

  1. As you can see in my comment here, you have to pass the webapp_dir attribute to prevent the recipe from failing
  2. After that the recipe fails because it can not start the service. It copies /etc/init.d/tomcat7 to /etc/init.d/tomcat7-INSTANCE_NAME. After that all occurrences of tomcat7 are replaced by tomcat7-INSTANCE_NAME. Sadly this also changes user and group to values that do not exist:
execute "/etc/init.d/#{instance}" do
 command <<-EOH
    cp /etc/init.d/#{base_instance} /etc/init.d/#{instance}
    perl -i -pe 's/#{base_instance}/#{instance}/g' /etc/init.d/#{instance}
 EOH
end

Thus the recipe fails because during start of /etc/init.d/tomcat7-INSTANCE_NAME the user is unknown.

Instance support on CentOS 7

With CentOS 7 (systemd) and the supplied version of Tomcat 7.0.54, multiple instance support with this cookbook does not work. This occurs because the systemd service template shipped with this cookbook references /usr/sbin/tomcat-sysd, which does not exist.

Where should we find this executable? Or is it possible to make this configurable?

Overriding default['tomcat']['version'] in a wrapper cookbook does not work

We attempted this two ways:

This still installs version 6
default['tomcat']['base_version'] = 7

This also installs version 6
override['tomcat']['base_version'] = 7

This is confusing for new users who are trying to leverage the community cookbook as a 'library' cookbook, inside of a wrapper cookbook.

tomcat::users recipe tries to restart non-existent service (hardcoded resource)

[2014-06-20T14:26:25-05:00] ERROR: resource template[/etc/tomcat6/tomcat-users.xml] is configured to notify resource service[tomcat] with action restart, but service[tomcat] cannot be found in the resource collection. template[/etc/tomcat6/tomcat-users.xml] is defined in /var/chef/cache/cookbooks/tomcat/recipes/users.rb:22:in `from_file'

The users recipe does not consider which version of tomcat is configured.

Multi instance symlink error when running chef-client

v0.16.2
run_base_instance true or false seems to make no difference

Config

"override_attributes": {
      "tomcat": {
        "base_version": "7",
        "java_options": "-Xmx512M -Djava.awt.headless=true",
        "run_base_instance": true,
        "instances": {
          "test": {
            "port": 8081,
            "shutdown_port": 8006
          },
          "test2": {
            "port": 8082,
            "shutdown_port": 8007
          }
        }
      }

 }

Output

Errno::EISDIR
-------------
Is a directory - /var/lib/tomcat7-test/webapps


Resource Declaration:
---------------------
# In /var/chef/cache/cookbooks/tomcat/providers/instance.rb

 80:       link "#{new_resource.base}/#{name}" do
 81:         to new_resource.instance_variable_get("@#{attr}")
 82:       end
 83:     end



Compiled Resource:
------------------
# Declared in /var/chef/cache/cookbooks/tomcat/providers/instance.rb:80:in `block (2 levels) in class_from_file'

link("/var/lib/tomcat7-test/webapps") do
  provider Chef::Provider::Link
  action :create
  retries 0
  retry_delay 2
  to "/var/lib/tomcat7-test/webapps"
  link_type :symbolic
  target_file "/var/lib/tomcat7-test/webapps"
  cookbook_name "tomcat"
end

Adding tomcat::users causes errors

Adding the tomcat::users recipe to chef-solo right after tomcat::default in my Vagrant file causes the following error:

ERROR: resource template[/etc/tomcat6/tomcat-users.xml] is configured to notify resource service[tomcat] with action restart, but service[tomcat] cannot be found in the resource collection. template[/etc/tomcat6/tomcat-users.xml] is defined in /tmp/vagrant-chef-3/chef-solo-1/cookbooks/tomcat/recipes/users.rb:22:in `from_file'

removing the following line in users.rb

notifies :restart, 'service[tomcat]'

helps. I don't think the line is necessary at all, since the tomcat service will be restarted anyways in the end.

Tomcat7 and Centos6.x

Tomcat 7.0.x is available to CentOS 6.x users via the EPEL-testing repository.
The issue is naming convention; recipe/default.rb assume that Tomcat with Base Version 7 would be named 'tomcat7' while EPEL-testing name is 'tomcat' (or 'tomcat-7.0.x')

tomcat directories: Why is the CB not creating them?

Hi there ...
What is the assumption of not creating these directories by the cb itself?

node["tomcat"]["base"] -
node["tomcat"]["config_dir"] -
node["tomcat"]["log_dir"] -
node["tomcat"]["tmp_dir"] -
node["tomcat"]["work_dir"] -
node["tomcat"]["context_dir"] -
node["tomcat"]["webapp_dir"] -
node["tomcat"]["lib_dir"] -

Multi-instance install results in service "is not installed"

Executing the multi-instance install results in deployed services that can't start. They're reporting as "not installed".

vagrant@host:/etc/init.d$ sudo service tomcat7-myinstance status
 * tomcat7-myinstance is not installed

Platform is Ubuntu 12.04 with Chef 11.4.0, via Vagrant.

using tomcat7 doesn't honor default attributes

When setting "node.default['tomcat']['base_version'] = 7" - you must also set all of the attrs in attributes/default.rb again in your recipe/env in order for /etc/sysconfig/tomcat7 to be created corrected. If you do not, there is a config file set for tomcat6 settings placed in /etc/sysconfig/tomcat7 which is odd. I don't understand the multi instance stuff enough to provide a fix

USERS_DATA_BAG warning

when using this cookbook, i am getting this warning:

/var/folders/h2/xkndkjjj691fwycxl07qv8240000gn/T/d20150608-27406-o5nkpz/cookbooks/tomcat/libraries/chef_tomcat_cookbook.rb:44: warning: already initialized constant Chef::TomcatCookbook::USERS_DATA_BAG
/var/folders/h2/xkndkjjj691fwycxl07qv8240000gn/T/d20150608-27406-o5nkpz/cookbooks/tomcat/libraries/chef_tomcat_cookbook.rb:44: warning: previous definition of USERS_DATA_BAG was here

cookbook_file resource should not be used in tomcat_instance provider to set certificate file modes

The instance provider uses coobook_file resource to set the file mode of SSL Certificate file, SSL Key file and the SSL Certificate Chain files, here: https://github.com/opscode-cookbooks/tomcat/blob/847a2aa2fa53fed4f87ab35c006fbf2f19de7640/providers/instance.rb#L221

The documentation states that one should:

Use the cookbook_file resource to transfer files from a sub-directory of COOKBOOK_NAME/files/ to a specified path located on a host that is running the chef-client.

However, the files mentioned above are not included in the cookbook; they are provided by the user of the recipe. In my experience, if you specify ssl_cert_file, ssl_key_file and ssl_chain_files settings, the cookbook_file step always fail because Chef cannot find the referenced files.

I think using the file resource is more appropriate in this case.

If the case above makes sense, I'm ready to send a pull request with the necessary modifications. Please also let me know if there is a particular reason to keep using the cookbook_file resource; I'm fairly new to Chef and may be ignoring something important.

#116 doesn't work with Amazon Linux having EPEL enabled

The package changes in #116 do not work with Amazon Linux when EPEL is enabled.

Amazon Linux has three packages:
tomcat6 (6.0.43-1.2.amzn1)
tomcat (7.0.33-4.el6) -> coming from EPEL
tomcat7 (7.0.62-1.9.amzn1)

So with the base version being six, it ends up installing "tomcat" which installs version 7.0.33.

Error executing action `create` on resource 'link[/var/lib/tomcat7-kms/webapps]'

I am trying to configure tomcat to run multiple instances. I put the following code in the file I have to describe roles.
.............
"override_attributes": {
"tomcat": {
"run_base_instance": true,
"base_version": 7,
"instances": {
"kms":{
"port": 9198,
"ssl_port": 9199,
"shutdown_port":8092,
}
}
}
..............

On trying to deploy this on vagrant, I get the following error,

==> default: ================================================================================
==> default: Error executing action create on resource 'link[/var/lib/tomcat7-kms/webapps]'
==> default: ================================================================================
==> default:
==> default:
==> default: Errno::EISDIR
==> default: -------------
==> default: Is a directory @ unlink_internal - /var/lib/tomcat7-kms/webapps
==> default:
==> default:
==> default: Resource Declaration:
==> default: ---------------------
==> default: # In /tmp/vagrant-chef-3/chef-solo-1/cookbooks/tomcat/providers/instance.rb
==> default:
==> default: 80: link "#{new_resource.base}/#{name}" do
==> default: 81: to new_resource.instance_variable_get("@#{attr}")
==> default: 82: end
==> default: 83: end
==> default:
==> default:
==> default:
==> default: Compiled Resource:
==> default: ------------------
==> default: # Declared in /tmp/vagrant-chef-3/chef-solo-1/cookbooks/tomcat/providers/instance.rb:80:in `block (2
levels) in class_from_file'
==> default:
==> default: link("/var/lib/tomcat7-kms/webapps") do
==> default: provider Chef::Provider::Link
==> default: action :create
==> default: retries 0
==> default: retry_delay 2
==> default: guard_interpreter :default
==> default: to "/var/lib/tomcat-kms/webapps"
==> default: link_type :symbolic
==> default: target_file "/var/lib/tomcat7-kms/webapps"
==> default: cookbook_name :tomcat
==> default: end
==> default:

tomcat installs openjdk, even though oracle jdk was specified

I try to install a tomcat7 with oracle java 7.

Using vagrant with image ubuntu/trusty64 and the following role, oracle java is installed but alongside openjdk is installed as well and is set as the default java.

if i change recipe[tomcat] to recipe[java] only the oracle jdk is installed.

role:
description "blank"
name "myName"
run_list(
"recipe[apt]",
"recipe[tomcat]",
"recipe[apache2]",
"recipe[apache2::mod_proxy]",
"recipe[apache2::mod_proxy_ajp]",
"recipe[apache2::mod_proxy_balancer]",
"recipe[apache2::mod_proxy_connect]",
"recipe[apache2::mod_proxy_http]",
"recipe[apache2::mod_proxy_ftp]",
"recipe[apache2::mod_rewrite]"
)
default_attributes(
"apache" => {
"listen_ports" => [ "80", "81", "82", "85", "90" ]
}, "java" => {
"install_flavor" => "oracle",
"jdk_version" => "7",
"oracle" => {
"accept_oracle_download_terms" => true
}
},
"tomcat" => {
"base_version" => 7,
"java_options" => "...stuff..."
}
)

Instanced Tomcat breaks template overrides

This style of template override now longer works (it worked through 0.15.12):

begin
  t = resources(:template => "#{node[:tomcat][:config_dir]}/logging.properties")
  t.source 'logging.properties.erb'
  t.cookbook 'tomcat_config'
rescue Chef::Exceptions::ResourceNotFound
  Chef::Log.warn "could not find template #{node[:tomcat][:config_dir]}/logging.properties to modify"
end

This prevents me from implementing production-appropriate logging (e.g. NOT double-logging entries to catalina.out and catalina.2015-01-28.log, skipping localhost.*.log, etc.).

Add support for Tomcat 7/8. Remove 6

For our refactor we need to focus on modern Tomcat releases. 7/8 are both stable releases and we should focus on solid support for those platforms and remove support Tomcat 6.

['tomcat']['base_version'] is not getting overridden?

chef client versions afftected:

11.16.4 , 12.0.3

cookbook version

[email protected]

node ohai info (platform):

$ ohai  | grep platform
  "platform": "centos",
  "platform_version": "6.5",
  "platform_family": "rhel",

How to reproduce:

cat metadat/default.rb

name             'test'
version          '0.1.0'
depends          'tomcat'

cat recipes/default.rb

 node.override['tomcat']['base_version'] = 7
 include_recipe "tomcat"

chef-client -l info -r test


Starting Chef Client, version 12.0.3
[2015-03-05T12:21:13+00:00] INFO: *** Chef 12.0.3 ***
[2015-03-05T12:21:13+00:00] INFO: Chef-client pid: 12094
[2015-03-05T12:21:14+00:00] INFO: Setting the run_list to [#<Chef::RunList::RunListItem:0x00000002436cd0 @version=nil, @type=:recipe, @name="test">] from CLI options
[2015-03-05T12:21:14+00:00] INFO: Run List is [recipe[test]]
[2015-03-05T12:21:14+00:00] INFO: Run List expands to [test]
[2015-03-05T12:21:14+00:00] INFO: Starting Chef Run for ********
[2015-03-05T12:21:14+00:00] INFO: Running start handlers
[2015-03-05T12:21:14+00:00] INFO: Start handlers complete.
[2015-03-05T12:21:14+00:00] INFO: HTTP Request Returned 404 Object Not Found: 
resolving cookbooks for run list: ["test"]
[2015-03-05T12:21:14+00:00] INFO: Loading cookbooks [[email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected]]
Synchronizing Cookbooks:
  - yum-epel
  - yum
  - openssl
  - chef-sugar
  - java
  - tomcat
  - test
Compiling Cookbooks...
Converging 4 resources
Recipe: yum-epel::default
  * yum_repository[epel] action create[2015-03-05T12:21:14+00:00] INFO: Processing yum_repository[epel] action create (yum-epel::default line 22)

    * template[/etc/yum.repos.d/epel.repo] action create[2015-03-05T12:21:14+00:00] INFO: Processing template[/etc/yum.repos.d/epel.repo] action create (/var/chef/cache/cookbooks/yum/providers/repository.rb line 39)
 (up to date)
    * execute[yum-makecache-epel] action nothing[2015-03-05T12:21:14+00:00] INFO: Processing execute[yum-makecache-epel] action nothing (/var/chef/cache/cookbooks/yum/providers/repository.rb line 55)
 (skipped due to action :nothing)
    * ruby_block[yum-cache-reload-epel] action nothing[2015-03-05T12:21:14+00:00] INFO: Processing ruby_block[yum-cache-reload-epel] action nothing (/var/chef/cache/cookbooks/yum/providers/repository.rb line 62)
 (skipped due to action :nothing)
     (up to date)
Recipe: tomcat::default
  * yum_package[tomcat6] action install

I just wonder why tomcat6 package gets installed? I expect according to the following code , i should be `tomcat' package ?

cat tomcat/attributes/default.rb :

default['tomcat']['base_version'] = 6
...
...
...
...

case node['platform_family']

when 'rhel', 'fedora'
  suffix = node['tomcat']['base_version'].to_i < 7 ? node['tomcat']['base_version'] : ""
  ....
  default['tomcat']['packages'] = ["tomcat#{suffix}"]

Tomcat 7 & openSUSE

The cookbook does not use correct package names (and directories, etc.) for the openSUSE platform.

Multiple instance support prevents template overrides

With the latest pull request (#70) to support multiple Tomcat instances, we can't override the /etc/default/tomcat7 template any more. Using the below override, we hit the exception and the override fails

begin
    r = resources("template[/etc/default/tomcat#{node['tomcat']['base_version']}]")
    r.cookbook "wrapper"
rescue Chef::Exceptions::ResourceNotFound
    Chef::Log.warn "Could not find template /etc/default/tomcat#{node['tomcat']['base_version']} to override"
end

It seems that the resource is being defined at runtime, instead of at compile time as before.

tomcat::users recipe not aware of tomcat7 detail

From line 31 of users.rb:

  notifies :restart, 'service[tomcat]'

This fails if the tomcat recipe has been configured for version 7.

Then, the service name is "tomcat7" and not simply "tomcat".

No Method Error

While trying to create multiple tomcat instances, I am running into following error.

Recipe Compile Error in /var/chef/cache/cookbooks/tomcat-cxf/recipes/default.rb

NoMethodError


No resource or method named tomcat_instance' forChef::Recipe "default"'

Cookbook Trace:


/var/chef/cache/cookbooks/tomcat-cxf/recipes/default.rb:75:in `block in from_file'
/var/chef/cache/cookbooks/tomcat-cxf/recipes/default.rb:74:in `each'
/var/chef/cache/cookbooks/tomcat-cxf/recipes/default.rb:74:in `from_file'

Relevant File Content:


/var/chef/cache/cookbooks/tomcat-cxf/recipes/default.rb:

68: ajp_port node['tomcat']['ajp_port']
69: shutdown_port node['tomcat']['shutdown_port']
70: end
71: end
72:
73: tomcat_instance = 'instances1'
74: node['tomcat']['instances'].each do |name, attrs|
75>> tomcat_instance "#{name}" do
76: port attrs['port']
77: proxy_port attrs['proxy_port']
78: ssl_port attrs['ssl_port']
79: ssl_proxy_port attrs['ssl_proxy_port']
80: ajp_port attrs['ajp_port']
81: shutdown_port attrs['shutdown_port']
82: config_dir attrs['config_dir']
83: log_dir attrs['log_dir']
84: work_dir attrs['work_dir']

Errors still in CentOS

Running handlers:
[2015-02-24T22:58:46+00:00] ERROR: Running exception handlers
Running handlers complete

[2015-02-24T22:58:46+00:00] ERROR: Exception handlers complete
[2015-02-24T22:58:46+00:00] FATAL: Stacktrace dumped to /var/chef/cache/chef-stacktrace.out
Chef Client failed. 0 resources updated in 10.481473314 seconds
[2015-02-24T22:58:46+00:00] ERROR: resource template[/etc/tomcat/tomcat-users.xml] is configured to notify resource service[tomcat] with action restart, but service[tomcat] cannot be found in the resource collection. template[/etc/tomcat/tomcat-users.xml] is defined in /var/chef/cache/cookbooks/tomcat/recipes/users.rb:22:in `from_file'

[2015-02-24T22:58:46+00:00] FATAL: Chef::Exceptions::ChildConvergeError: Chef run process exited unsuccessfully (exit code 1)
root@tomcat-test1 ~ #

Tomcat server.xml file is overwritten

Not sure if this is a problem from the cookbook or I missed something.
If I try to replace the server.xml with my version , chef always replaces with the default template back.
Now if I move my template resource after tomcat the config is correct but this change triggers double service restart.
Is there a way to add an additional element to the server.xml without the problem above?

Chef Zero Support

Hello.

I am unable to use unencrypted data bags with Chef Zero. Specifically, I am using chefdk, KCI, vagrant with zero as the provisioner. I suspect its user error, but after some code review not certain. If I create a databag via chef-shell and then run the cookbook tomcat::users it tries to decrypt and in turns fails due to missing the encryption key configuration.

Per tomcat-0.17.3/libraries/chef_tomcat_cookbook.rb

def find_users
        users = if Chef::Config[:solo]
                  data_bag = Chef::DataBag.load(USERS_DATA_BAG)
                  data_bag.keys.map do |name|
            Chef::DataBagItem.load(USERS_DATA_BAG, name)
          end
                else
                  begin
                    items = Chef::Search::Query.new.search(USERS_DATA_BAG)[0]
                  rescue Net::HTTPServerException => e
                    raise TomcatUserDataBagNotFound if e.message.match(/404/)
                    raise e
                  end
                  decrypt_items(items)
                end

        users.each { |user| validate_user_item(user) }
        users
      end

Should this include zero support similar to solo? I only have a basic understanding here, so I could be wrong.

I have been unable to find any tutorial using unencrypted databags with Tomcat (at least trying to add users.)

Regards.

Ron

Tomcat service name is hardcoded in tomcat_instance provider

The create_keystore-#{instance} script in instance provider is referencing an unregistered service. The error occurs in this line. The problem is that the name of the tomcat service is hardcoded.

The following is part of the output Chef generates when it tries to restart the unregistered service:

==> app_server: [2014-11-26T00:05:54+00:00] ERROR: Running exception handlers
==> app_server: [2014-11-26T00:05:54+00:00] ERROR: Exception handlers complete
==> app_server: [2014-11-26T00:05:54+00:00] FATAL: Stacktrace dumped to /var/chef/cache/chef-stacktrace.out
==> app_server: [2014-11-26T00:05:54+00:00] ERROR: resource script[create_keystore-tomcat7] is configured to notify resource service[tomcat] with action restart, but service[tomcat] cannot be found in the resource collection. script[create_keystore-tomcat7] is defined in /tmp/vagrant-chef-2/chef-solo-1/cookbooks/tomcat/providers/instance.rb:204:in `block in class_from_file'

tomcat 7 doesn't start

I'm guessing this could be fixed by modifying the template for server.xml to exclude the listener on version >= 7.

Stack trace

Mar 30, 2015 7:05:42 PM org.apache.catalina.startup.Catalina load
WARNING: Catalina.start using conf/server.xml: Error at (37, 78) : org.apache.catalina.mbeans.ServerLifecycleListener
Mar 30, 2015 7:05:42 PM org.apache.catalina.startup.Catalina start
SEVERE: Cannot start server. Server instance is not configured.
Mar 30, 2015 7:06:17 PM org.apache.tomcat.util.digester.Digester startElement
SEVERE: Begin event threw exception
java.lang.ClassNotFoundException: org.apache.catalina.mbeans.ServerLifecycleListener
        at java.net.URLClassLoader$1.run(URLClassLoader.java:366)
        at java.net.URLClassLoader$1.run(URLClassLoader.java:355)
        at java.security.AccessController.doPrivileged(Native Method)
        at java.net.URLClassLoader.findClass(URLClassLoader.java:354)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:425)
                                                                                                                                                                                                                                                              310,2-9       79%
        at java.net.URLClassLoader.findClass(URLClassLoader.java:354)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:425)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:358)
        at org.apache.tomcat.util.digester.ObjectCreateRule.begin(ObjectCreateRule.java:144)
        at org.apache.tomcat.util.digester.Digester.startElement(Digester.java:1276)
        at com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.startElement(AbstractSAXParser.java:509)
        at com.sun.org.apache.xerces.internal.parsers.AbstractXMLDocumentParser.emptyElement(AbstractXMLDocumentParser.java:182)
        at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanStartElement(XMLDocumentFragmentScannerImpl.java:1343)
        at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl$FragmentContentDriver.next(XMLDocumentFragmentScannerImpl.java:2786)
        at com.sun.org.apache.xerces.internal.impl.XMLDocumentScannerImpl.next(XMLDocumentScannerImpl.java:606)
        at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanDocument(XMLDocumentFragmentScannerImpl.java:510)
        at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Configuration.java:848)
        at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Configuration.java:777)
        at com.sun.org.apache.xerces.internal.parsers.XMLParser.parse(XMLParser.java:141)
        at com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.parse(AbstractSAXParser.java:1213)
        at com.sun.org.apache.xerces.internal.jaxp.SAXParserImpl$JAXPSAXParser.parse(SAXParserImpl.java:648)
        at org.apache.tomcat.util.digester.Digester.parse(Digester.java:1537)
        at org.apache.catalina.startup.Catalina.load(Catalina.java:576)
        at org.apache.catalina.startup.Catalina.load(Catalina.java:619)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.lang.reflect.Method.invoke(Method.java:606)
        at org.apache.catalina.startup.Bootstrap.load(Bootstrap.java:281)
        at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:449)

Tomcat 7 / CentOS 7 fails to install

Created a base CentOS7 box, set the base version to Tomcat 7:

 node.default['tomcat']['base_version'] = '7'
 include_recipe 'tomcat'

Get this error about Tomcat 6 (why 6? why is it trying to install Tomcat 6)?

   Recipe: tomcat::default

       * No candidate version available for tomcat6
       ================================================================================
       Error executing action `install` on resource 'yum_package[tomcat6]'
       ================================================================================

       Chef::Exceptions::Package
       -------------------------
       No candidate version available for tomcat6

       Resource Declaration:
       ---------------------
       # In /tmp/kitchen/cache/cookbooks/tomcat/recipes/default.rb

        31:   package pkg do
        32:     action :install
        33:   end
        34: end

       Compiled Resource:
       ------------------
       # Declared in /tmp/kitchen/cache/cookbooks/tomcat/recipes/default.rb:31:in `block in from_file'

       yum_package("tomcat6") do
         action [:install]
         retries 0
         retry_delay 2
         default_guard_interpreter :default
         package_name "tomcat6"
         timeout 900
         flush_cache {:before=>false, :after=>false}
         declared_type :package
         cookbook_name "tomcat"
         recipe_name "default"
       end


   Running handlers:
   [2015-06-01T21:25:19+00:00] ERROR: Running exception handlers
   Running handlers complete

I looked at your code and tried to hack it to install only Tomcat 7:

  node.default['tomcat']['packages'] = ["tomcat7"]

but it gave me a similar error:

       No candidate version available for tomcat7

keystore generation of keystores with keys that are specified

There is a problem with keystore generation with keys that are specified.
In this code:
https://github.com/opscode-cookbooks/tomcat/blob/master/providers/instance.rb
Lines starting at 218:
script "create_keystore-#{instance}" do
interpreter 'bash'
action :nothing
cwd new_resource.config_dir
code <<-EOH
cat #{new_resource.ssl_chain_files.join(' ')} > cacerts.pem
openssl pkcs12 -export
-inkey #{new_resource.ssl_key_file}
-in #{new_resource.ssl_cert_file}
-chain
-CAfile cacerts.pem
-password pass:#{node['tomcat']['keystore_password']}
-out #{new_resource.keystore_file}
EOH
notifies :restart, "service[tomcat]"
end

This is creating a p12 file, and not changing the server.xml file to use a p12 file so it fails to load.

-Gary

Multi-instance deploy creating symlink to nonexistent directories

The instance.rb provider appears to create bad symlinks, meaning the particular instance can't start.

At the end of the install, it attempts to start the service...

==> cis: [2014-08-20T21:59:16+00:00] INFO: Processing service[tomcat7-myinstance] action start (/tmp/vagrant-chef-2/chef-solo-1/cookbooks/tomcat/providers/instance.rb line 245)
==> cis: [2014-08-20T21:59:16+00:00] DEBUG: service[tomcat7-myinstance] supports status, running
==> cis: [2014-08-20T21:59:16+00:00] INFO: Retrying execution of service[tomcat7-myinstance], 3 attempt(s) left

... but hangs on this step (retrying the 3 times and failing).

Inspecting the /var/lib/tomcat7-myinstance directory reveals that the bin and lib directories are symlinked to /var/lib/tomcat7/bin and /var/ilb/tomcat7/lib respectively...

vagrant@host:/var/lib/tomcat7-myinstance$ ll
total 8
drwxr-xr-x  2 root root 4096 Aug 20 21:57 ./
drwxr-xr-x 37 root root 4096 Aug 20 21:57 ../
lrwxrwxrwx  1 root root   20 Aug 20 21:57 bin -> /var/lib/tomcat7/bin
lrwxrwxrwx  1 root root   23 Aug 20 21:57 conf -> /etc/tomcat7-myinstance/
lrwxrwxrwx  1 root root   20 Aug 20 21:57 lib -> /var/lib/tomcat7/lib
lrwxrwxrwx  1 root root   27 Aug 20 21:57 logs -> /var/log/tomcat7-myinstance/
lrwxrwxrwx  1 root root   16 Aug 20 21:57 temp -> /tmp/tomcat7-tmp
lrwxrwxrwx  1 root root   24 Aug 20 21:57 webapps -> /var/lib/tomcat7/webapps/
lrwxrwxrwx  1 root root   29 Aug 20 21:57 work -> /var/cache/tomcat7-myinstance/

However these directories don't exist:

vagrant@host:/var/lib/tomcat7$ ll
total 24
drwxr-xr-x  6 root    root    4096 Aug 20 21:57 ./
drwxr-xr-x 37 root    root    4096 Aug 20 21:57 ../
drwxr-xr-x  3 tomcat7 tomcat7 4096 Aug 20 21:57 common/
lrwxrwxrwx  1 root    root      12 Apr  1  2013 conf -> /etc/tomcat7/
lrwxrwxrwx  1 root    root      17 Apr  1  2013 logs -> ../../log/tomcat7/
drwxr-xr-x  3 tomcat7 tomcat7 4096 Aug 20 21:57 server/
drwxr-xr-x  3 tomcat7 tomcat7 4096 Aug 20 21:57 shared/
drwxr-xr-x  3 tomcat7 tomcat7 4096 Aug 20 21:57 webapps/
lrwxrwxrwx  1 root    root      19 Apr  1  2013 work -> ../../cache/tomcat7/

I'm deploying with run_base_instance as false.

ADD ALL THE TESTS!

Add tests for:

  • Is tomcat getting installed?
  • Test the thing where a base tomcat instance gets created
  • Test the thing where you have more than one instance

tomcat7/ubuntu14

Since the CATALINA_BASE does not have bin/lib dirs, I've updated this to point to CATALINA_HOME

Also ubuntu 14 uses conf/policy.d/*.policy files, so I've updated changed catalina.policy to policy.d in the soft-linking section. Platform and version check validation may be needed to determine the variations that's needed.

@@ -62,7 +62,7 @@
     end

     # config_dir needs symlinks to the files we're not going to create
-    ['catalina.policy', 'catalina.properties', 'context.xml',
+    ['policy.d', 'catalina.properties', 'context.xml',
      'tomcat-users.xml', 'web.xml'].each do |file|
       link "#{new_resource.config_dir}/#{file}" do
         to "#{node['tomcat']['config_dir']}/#{file}"
 @@ -70,9 +70,10 @@
     end

     # The base also needs a bunch of to symlinks inside it
+    # These symlinks should point back to tomcat home.
     ['bin', 'lib'].each do |dir|
       link "#{new_resource.base}/#{dir}" do
-        to "#{node['tomcat']['base']}/#{dir}"
+        to "#{node['tomcat']['home']}/#{dir}"
       end
     end
     {'conf' => 'config_dir', 'logs' => 'log_dir', 'temp' => 'tmp_dir',

Feedback: Refactor of Tomcat Cookbook

Would you consider a major refactor of this cookbook? This cookbook has done a great job and has many users. I'm simply wondering if you would consider a major refactor for the sake of more flexibility and ease of maintenance in the future.

The biggest issue we faced was the lack of Tomcat 8 support (inc. downloading a tarball since EL distros don't have access to Tomcat 8.x RPMs) and some inflexibility in templates. So I am in the process of writing my own cookbook to solve the issue in the short term. I am happy to share and merge those changes into this cookbook if you are open to changes.

Here's a quick snippet of what the resources look like in my current development version.

# Install tomcat
tomcat 'my_tomcat8' do
  version '8.0.24'
end

# Create one or more instances
apache_tomcat_instance 'instance1'

tomcat_config 'web' do
  type :web # also :server, :context, :entity
  instance 'instance1' 
  config_options do
    include_defaults true
    # ... various other config options that end up as XML
    servlets(
      [
         {
            'name'                 => 'my_servlet',
            'class'                  => 'org.mycompany.MyServlet',
            'init_params'        => { 'debug' => '1', 'listings' => true },
            'load_on_startup' => '1'
         }
      ]
     # servlets, mappings, filters, mime types, etc all have config hashes that are flexible
     # at the end of the day, if this doesn't meet a user's needs, they can pass a new template source in
  end 
end

tomcat_service 'instance1' do
  action [:enable, :start]
end

Default Tomcat SSL Configuration yields ERR_SSL_VERSION_OR_CIPHER_MISMATCH

Using Vagrant + Chef to provision an Ubuntu 14.04 VM with tomcat (and using stock default options), I found that the SSL (HTTPS) connection didn't allow any browsers (excluding the wget command) to browse on the HTTPS port. After some googling, I found this SO article that helped me identify the problem: http://stackoverflow.com/questions/14362819/tomcat-6-err-ssl-version-or-cipher-mismatch-ssl-error-no-cypher-overlap

According to the article, when generating the self-signed certificate using keytool, you need to provide -keyalg RSA. I will be providing a pull request shortly that will address this issue It simply allows for a keytool algorithm property (and defaults it to RSA).

LWRP to create multiple instances doesn't appear to work.

  1. resources/instances.rb doesn't appear to have any reference to these 2 attributes:
    ajp_packetsize attrs['ajp_packetsize']
    uriencoding attrs['uriencoding']
    I had to comment them out to move forward in cookbook.
  2. it seems in providers/instance.rb when you provide overrides like below:
    "run_base_instance": false,
    "instances": {"instance2": { "port": 8085, "shutdown_port": 8008}, "instance3": { "port": 8086, "shutdown_port": 8009}},
    the templates appear to be having issues generating the files. platform_family=rhel. does this function work?

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.