Giter Club home page Giter Club logo

puppetlabs-tomcat's Introduction

tomcat

Table of Contents

  1. Overview
  2. Module Description - What the module does and why it is useful
  3. Setup - The basics of getting started with tomcat
  4. Usage - Configuration options and additional functionality
  5. Reference - An under-the-hood peek at what the module is doing and how
  6. Limitations - OS compatibility, etc.
  7. License
  8. Development - Guide for contributing to the module

Overview

The tomcat module lets you use Puppet to install, deploy, and configure Tomcat web services.

Module Description

Tomcat is a Java web service provider. The tomcat module lets you use Puppet to install Tomcat, manage its configuration file, and deploy web apps to it. It supports multiple instances of Tomcat spanning multiple versions.

Setup

Requirements

The tomcat module requires puppetlabs-stdlib version 4.0 or newer. On Puppet Enterprise you must meet this requirement before installing the module. To update stdlib, run:

puppet module upgrade puppetlabs-stdlib

Beginning with tomcat

The simplest way to get Tomcat up and running with the tomcat module is to install the Tomcat source and start the service:

tomcat::install { '/opt/tomcat':
  source_url => 'https://www-us.apache.org/dist/tomcat/tomcat-8/v8.0.x/bin/apache-tomcat-8.0.x.tar.gz',
}
tomcat::instance { 'default':
  catalina_home => '/opt/tomcat',
}

Note: look up the correct version you want to install on the version list.

Usage

I want to run multiple instances of multiple versions of Tomcat

class { 'java': }

tomcat::install { '/opt/tomcat9':
  source_url => 'https://www.apache.org/dist/tomcat/tomcat-9/v9.0.x/bin/apache-tomcat-9.0.x.tar.gz'
}
tomcat::instance { 'tomcat9-first':
  catalina_home => '/opt/tomcat9',
  catalina_base => '/opt/tomcat9/first',
}
tomcat::instance { 'tomcat9-second':
  catalina_home => '/opt/tomcat9',
  catalina_base => '/opt/tomcat9/second',
}
# Change the default port of the second instance server and HTTP connector
tomcat::config::server { 'tomcat9-second':
  catalina_base => '/opt/tomcat9/second',
  port          => '8006',
}
tomcat::config::server::connector { 'tomcat9-second-http':
  catalina_base         => '/opt/tomcat9/second',
  port                  => '8081',
  protocol              => 'HTTP/1.1',
  additional_attributes => {
    'redirectPort' => '8443'
  },
}

Note: look up the correct version you want to install on the version list.

I want to upgrade the version of Tomcat to use

See information about running multiple versions above. Instead of upgrading in-place, install a second version to a new directory and then point the catalina_home of your instance to it. This gives you the ability to validate and rollback if needed. After validation, you may remove the older instance if you'd like. The links can be updated in order to match programmer preferences:

class { 'java': }

tomcat::install { '/opt/tomcat/9.0.24':
  source_url => 'https://archive.apache.org/dist/tomcat/tomcat-9/v9.0.24/bin/apache-tomcat-9.0.24.tar.gz'
}
tomcat::install { '/opt/tomcat/9.0.44':
  source_url => 'https://www-us.apache.org/dist/tomcat/tomcat-9/v9.0.46/bin/apache-tomcat-9.0.46.tar.gz'
}
tomcat::instance { 'my_tomcat_app':
# catalina_home => '/opt/tomcat/9.0.24',
  catalina_home => '/opt/tomcat/9.0.46',
  catalina_base => '/opt/my_tomcat_app',
}

I want to configure SSL and specify which protocols and ciphers to use

  file { $keystore_path:
    ensure => present,
    source => $keystore_source,
    owner => $keystore_user,
    mode => '0400',
    checksum => 'md5',
    checksum_value => $keystore_checksum,
  } ->

  tomcat::config::server::connector { "${tomcat_instance}-https":
    catalina_base         => $catalina_base,
    port                  => $https_port,
    protocol              => $http_version,
    purge_connectors      => true,
    additional_attributes => {
      'SSLEnabled'          => bool2str($https_enabled),
      'maxThreads'          => $https_connector_max_threads,
      'scheme'              => $https_connector_scheme,
      'secure'              => bool2str($https_connector_secure),
      'clientAuth'          => bool2str($https_connector_client_auth),
      'sslProtocol'         => $https_connector_ssl_protocol,
      'sslEnabledProtocols' => join($https_connector_ssl_protocols_enabled, ","),
      'ciphers'             => join($ciphers_enabled, ","),

      'keystorePass'        => $keystore_pass.unwrap,
      'keystoreFile'        => $keystore_path,
    },
  }

See also: SSL/TLS Configuration HOW-TO

I want to deploy WAR files

Add the following to any existing installation with your own war source:

tomcat::war { 'sample.war':
  catalina_base => '/opt/tomcat9/first',
  war_source    => '/opt/tomcat9/webapps/docs/appdev/sample/sample.war',
}

The name of the WAR file must end with .war.

The war_source can be a local path or a puppet:///, http://, or ftp:// URL.

I want to remove some configuration

Different configuration defined types will allow an ensure parameter to be passed, though the name may vary based on the defined type.

To remove a connector, for instance, the following configuration ensure that it is absent:

tomcat::config::server::connector { 'tomcat9-jsvc':
  connector_ensure => 'absent',
  catalina_base    => '/opt/tomcat9/first',
  port             => '8080',
  protocol         => 'HTTP/1.1',
}

I want to manage a Connector or Realm that already exists

Describe the Realm or HTTP Connector element using tomcat::config::server::realm or tomcat::config::server::connector, and set purge_realms or purge_connectors to true.

tomcat::config::server::realm { 'org.apache.catalina.realm.LockOutRealm':
  realm_ensure => 'present',
  purge_realms => true,
}

Puppet removes any existing Connectors or Realms and leaves only the ones you've specified.

Reference

See REFERENCE.md

Limitations

For an extensive list of supported operating systems, see metadata.json

The tomcat::config::server* defined types require Augeas version 1.0.0 or newer.

Multiple Instances

Some Tomcat packages do not let you install more than one instance. You can avoid this limitation by installing Tomcat from source.

License

This codebase is licensed under the Apache2.0 licensing, however due to the nature of the codebase the open source dependencies may also use a combination of AGPL, BSD-2, BSD-3, GPL2.0, LGPL, MIT and MPL Licensing.

Development

Puppet Labs modules on the Puppet Forge are open projects, and community contributions are essential for keeping them great. We can't access the huge number of platforms and myriad of hardware, software, and deployment configurations that Puppet is intended to serve.

We want to keep it as easy as possible to contribute changes so that our modules work in your environment. There are a few guidelines that we need contributors to follow so that we can have a chance of keeping on top of things.

For more information, see our module contribution guide.

Contributors

To see who's already involved, see the list of contributors.

Running tests

This project contains tests for both rspec-puppet and beaker-rspec to verify functionality. For in-depth information, please see their respective documentation.

Quickstart:

gem install bundler
bundle install
bundle exec rake spec
bundle exec rspec spec/acceptance
RS_DEBUG=yes bundle exec rspec spec/acceptance

puppetlabs-tomcat's People

Contributors

ackiejoe avatar bmjen avatar chelnak avatar cmurphy avatar daianamezdrea avatar david22swan avatar davids avatar eimlav avatar eputnam avatar glennsarti avatar gspatton avatar hail9000 avatar hunner avatar jonnytdevops avatar jordanbreen28 avatar joshbeard avatar juame avatar lionce avatar lukasaud avatar malikparvez avatar michaeltlombardi avatar pmcmaw avatar rajat-puppet avatar ramesh7 avatar sanfrancrisko avatar sheenaajay avatar simonrondelez avatar tphoney avatar transifex-bot avatar uoe-pjackson 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

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  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

puppetlabs-tomcat's Issues

Breaking changes introduced in 6.4.0

Describe the Bug

When upgrading this module from 6.3.0 to 6.4.0 using Stdlib::Port data type as argument to tomcat::config::server::port fails with

Tomcat::Config::Server[am-server]: parameter 'port' expects a value of type Undef or String, got Integer

Expected Behavior

Minor version upgrades should never break like this.
Stdlib data types should always be allowed in puppetlabs modules.

Support for Tomcat 8.5+

Use Case

Maybe I missed it, but I can't figure out how to use this module to configure a tomcat 10 with TLS support. Since Version 8.5 an SSLHostConfig within the connector in the server.xml is possible and how it seems to me since version 10 it is mandatory.

https://tomcat.apache.org/tomcat-10.1-doc/ssl-howto.html#Edit_the_Tomcat_Configuration_File

Describe the Solution You Would Like

Please add support for an SSLHostConfig to tomcat::config::server::connector

Best regards and many thanks in advance,
Dirk

Allow setting attributes of Context element in context.xml

Use Case

I am attempting to add the attribute crossContext="true" to the Context element in $CATALINA_BASE/conf/context.xml

On reading the documentation tomcat::config::context suggests it might be something it can do:

Configure attributes for the Context element in $CATALINA_BASE/conf/context.xml

However it appears that this define type is hard coded to just set Context/WatchedResource/#text "WEB-INF/web.xml"

Describe the Solution You Would Like

The ability to set attributes of the Context element. Potentially through adding $additional_attributes and $attributes_to_remove to tomcat::config::context define type

Describe Alternatives You've Considered

I've not found another way of achieving this result using this module.

Additional Context

Missing dependency on File['server.xml'] when connector, host or valve classes are used

Describe the Bug

It appears that the following classes act on the server.xml file before that file is actually copied to the instance's config directory from the home config directory. The result is a mis-formatted server.xml file that includes the connector, host and valve sections only, preventing tomcat from starting.

  • tomcat::config::server::connector
  • tomcat::config::server::host
  • tomcat::config::server::valve

The only way to successfully deploy is using

    require => File["${catalina_base}/conf/server.xml"], # Added to solve a dependency problem in tomcat module

This file resource comes from tomcat::instance::copy_from_home, which suggests that the dependency is missing in this module.

Expected Behavior

Manipulation of server.xml (as well as other config files) should occur only after the tomcat::instance class has completed copying these files from the home config directory.

Steps to Reproduce

  1. create tomcat:;instance
  2. attempt to manipulate server.xml using tomcat::config::server::connector
  3. Result is a server.xml file that only contains this stanza, instead of editing a previously-existing server.xml file

Environment

  • Puppet 8
  • mod 'puppetlabs-tomcat', '7.1.0'
  • Ubuntu 22

Additional Context

This excerpt from my tomcat server configuration demonstrates the workaround.

...  

  ### MINGLE INSTANCE
  tomcat::instance { 'mingle':
    catalina_home         => $catalina_home,
    catalina_base         => $catalina_base,
    require               => File['Mingle Unit File'],
    service_name          => 'mingle',
    use_init              => true,
    manage_service        => true,
    manage_copy_from_home => true, # Copy initial config files from tomcat to this instance
    user                  => $t['user'],
    group                 => $t['user'],
  }

...

  # Listen Socket
  # - removes 'redirectPort' because this instance only listens on http
  # - adds 'relaxed' attributes to allow mingle to use '[]' in urls, which is now bad practice
  tomcat::config::server::connector { "mingle-http-${port['http']}": 
    catalina_base         => $catalina_base,
    port                  => $port['http'],     # Server socket port
    protocol              => 'HTTP/1.1',
    purge_connectors      => true,
    attributes_to_remove  => ['redirectPort'],  # This instance is behind a reverse proxy and only listens on http
    additional_attributes => {
      'relaxedPathChars'  => '[ ]',             # Mingle requires "relaxed path" characters
      'relaxedQueryChars' => '[ ]',
    },
    require               => File["${catalina_base}/conf/server.xml"], # Added to solve a dependency problem in tomcat module
  }

...

Wrong package_ensure type

Describe the Bug

In previous version 6.3.0 no type was given to for paramter $package_ensure in define tomcat::install
But with 6.4.0 a type is given but the type is boolean which i think is wrong because you pass it through to an other class and there the type is Optional[String[1]] which in my opinion is the correct one.

Expected Behavior

That i can use a string for package_ensure.

Steps to Reproduce

Steps to reproduce the behavior:
Trying to run this code
tomcat::install { $catalina_home:
install_from_source => false,
package_name => 'tomcat',
package_ensure => '10.1.5',
}

Environment

  • Version [7.23.0] (puppet)
  • Version [6.4.0] (module)
  • Platform [Rhel 8]

Tomcat module declares Puppet 8 compatibility, but its dependency modules do not

Describe the Bug

The puppetlabs-tomcat module states it has Puppet 8 compatibility, however it has a dependency upon a version of the puppet-archive module which doesn't support Puppet 8. Currently puppetlabs-tomcat 7.1.0 requires a version of puppet-archive >= 1.0.0 < 7.0.0. However puppet-archive is not Puppet 8 compatible until version 7.1.0, which is outside of the puppet-tomcat dependency range.

Installation from archive location problem

Describe the Bug

The way archive is used with the installation from source does not work in my setup. It seems curl doesn't download the archive.

Expected Behavior

curl should download the archive which in turn should be extracted in place.

Environment

  • module version 7.2.0
  • Rocky Linux 9
  • puppet 7.28.0
  • archive 7.1.0
  • curl 7.76.1 (x86_64-redhat-linux-gnu) libcurl/7.76.1 OpenSSL/3.0.7 zlib/1.2.11 brotli/1.0.9 libidn2/2.3.0 libpsl/0.21.1 (+libidn2/2.3.0) libssh/0.10.4/openssl/zlib nghttp2/1.43.0
  • tar 1.34

I provided PR #559 as a workaround

WARNING property "name" in resources unfixed

Describe the Bug

Property "name" don't exist in tomcat documentation and generate a warning

Expected Behavior

define tomcat::config::context::resources add a unexisting property "name"

Steps to Reproduce

tomcat::config::context::resources { 'resources':
  ensure                    => 'present',
  catalina_base         => '/opt/tomcat',
  additional_attributes => { 'cachingAllowed' => 'false' },
  notify                     => Service['tomcat'],
}

context.xml

<Context>
….
<Resources name="resources" cachingAllowed="false"></Resources>
</Context>

catalina.out
WARNING property name (value resources) can't fixed

AVERTISSEMENT [main] org.apache.tomcat.util.digester.SetPropertiesRule.begin La correspondance [Context/Resources] n'a pu fixer la propriété [name] à [resources]

Environment

  • Debian 11
  • Module tomcat 6.3.0
  • Tomcat 9.0.67

Optimizing puppet var types

Use Case

Previously i opened an issue with a type being wrong but i'm facing an other issue which can be resolved on my side but i think an overal review of the different new var types should be considered.

I'll try to describe some "wrong" types.

Describe the Solution You Would Like

To match var types better with their purpose

Additional Context

I'll add examples from where i would change types i will not include all params or go through all classes but just pasting some most used probably.

define tomcat::config::server (
Optional[String[1]] $address = undef, => since this has to be TCP/IP address check better instead of string
Optional[String[1]] $port = undef, => Change to integer or variant [string, integer]
Optional[String[1]] $server_config = undef, => Change to absolutepath since docs says "valid option string containing absolutepath"
) {

define tomcat::install (
String[1] $catalina_home = $name, => Change to absolutepath since docs says "valid option string containing absolutepath"
Optional[String[1]] $source_url = undef, => Change to enum or update docs this is not check but docs says "Valid options: a string containing a puppet://, http(s)://, or ftp://"
Optional[String[1]] $proxy_server = undef, => Could be checked better to since you have an enum on proxy_type
) {

This is ofc just a suggestion but stricter checking or using the correct types will help everyone in my opinion :)

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.