Giter VIP home page Giter VIP logo

tomcat's Introduction

SIG's Parameterized Tomcat Role

Install and configure Apache Tomcat.

Requirements

  • tomcat_java_home must be set to an appropriate JAVA_HOME path.

Role Variables

  • stage_dir (string) - Required - Path to a staging directory used during the installation process.

    • Note: While no default is provided, /tmp is usually sufficient.
  • tomcat_java_home (string) - Required - Path to the JAVA_HOME Tomcat will use.

  • tomcat_version (string) - Recommended - Tomcat version to install.

    • Default: 8.5.68
    • Allowed Values: 8.5.4, 8.5.40, 8.5.66, 8.5.68, 8.5.89, 9.0.43
    • Note: It is recommended that you supply a tomcat_version rather than using the default as the default is subject to change without notice.
  • tomcat_add_jars (list of strings) - A list of paths to JAR files to be added to the Tomcat lib directory.

    • Note: These files must be pre-staged on the server. To have the role download the JARs, use tomcat_download_jars instead.
  • tomcat_ajp_enabled (boolean) - When false the AJP connector will be removed from conf/server.xml.

    • Default: false
    • Known Issue: If the role is applied with tomcat_ajp_enabled set to false, a subsequent run with it set to true will not restore the AJP connector. It will have to be added back by hand.
  • tomcat_ajp_port (integer) - Tomcat AJP port.

    • Default: {{ 8009 + tomcat_port_offset }}
  • tomcat_base (string) - Base directory for the Tomcat installation.

    • Note: By default, Tomcat will be installed at {{ tomcat_base }}/{{ tomcat_service_name}}-{{ tomcat_version }} with as symlink at {{ tomcat_base }}/{{ tomcat_service_name }}
  • tomcat_catalina_extra_opts (string) - Extra JVM arguments to include at start time.

  • tomcat_censor_ansible_output (boolean) - When true certain output will be elided from the log to avoid exposing secrets. You can set this to false to troubleshoot failures in those steps.

    • Default: true
  • tomcat_context_cookie_processor_same_site_cookies - Sets the value for the sameSiteCookies attribute of the CookieProcessor in conf/context.xml.

  • tomcat_download_jars (list of JAR Download Objects) - JARS to be downloaded to Tomcat's lib directory.

  • tomcat_connector_extra_attrs (list of Extra Attribute Objects) - Additional attributes to be added to the HTTP and HTTPS connector tags in server.xml.

  • tomcat_group (string) - Primary group for tomcat_user

    • Default: tomcat
  • tomcat_http_port (integer) - HTTP listener port

    • Default: {{ 8080 + tomcat_port_offset }}
  • tomcat_https_port (integer) - SSL listener port

    • Default: {{ 8443 + tomcat_port_offset }}
  • tomcat_log_retain_days (integer) - Number of days to retain Tomcat logs.

    • Default: 30
  • tomcat_manage_context_xml (boolean) - Set to false to prevent the role making changes to conf/context.xml.

    • Default: true
  • tomcat_manage_logging (boolean) - Set to false to prevent the role making changes to conf/logging.properties

    • Default: true
  • tomcat_manage_server_xml (boolean) - Set to false to prevent the role making changes to conf/server.xml.

    • Default: true
  • tomcat_manage_tomcat_users_xml (boolean) - Set to false to prevent the role making changes to conf/users.xml.

    • Default: true
  • tomcat_max_http_header_size (integer) - When specified, sets the maxHttpHeaderSize attribute of the HTTP and HTTPS connectors.

  • tomcat_memory_args (string) - Memory arguments passed to the JVM. These will often need to be adjusted to suit the deployed webapps.

    • Default: -Xms512M -Xmx1024M
  • tomcat_port_offset (integer) - This value is added to all default port numbers.

    • Default: 0
    • Example: If you are installing two Tomcat instances, "A" and "B" then you can set tomcat_port_offset for instance B to 1000 so that instance A will listen on port 8080 and instance B on 9080.
  • tomcat_remove_delivered_apps (boolean) - The Tomcat installation package comes with several applications which are usually not desired in a production environment. When this value is true these apps will be removed after installation.

    • Default: true
  • tomcat_resource_links (list of JNDI Resource Link Objects) - JNDI resource links to add to conf/context.xml.

  • tomcat_resources (list of JNDI Resource Objects) - JNDI resources to add to conf/server.xml.

  • tomcat_self_signed (boolean) - When true the role will create a self-signed certificate and enable the SSL listener.

    • Default: false
  • tomcat_service_name (string) - The name of the system service created to start & stop Tomcat. You can install multiple versions of Tomcat by specifying different values for tomcat_service_name.

    • Default: tomcat
  • tomcat_shutdown_port (integer) - Tomcat shutdown port.

    • Default: {{ 8005 + tomcat_port_offset }}
  • tomcat_ssl_fqdn (string) - The FQDN used for the self-signed certificate.

    • Default: {{ ansible_fqdn }}
  • tomcat_ssl_org_name (string) - The organization name used in the self-signed CSR.

    • Default: {{ ansible_domain }}
  • tomcat_ssl_max_threads (integer) - Number of threads for the SSL listener.

    • Default: 150
  • tomcat_timezone (string) - Time zone setting for the JVM. This value is passed with -Duser.timezone= at start time.

    • Default: If current_timezone is set the role will use its value. Otherwise it will attempt to detect the time zone.
    • Note: A time zone is required because certain JDBC drivers will throw errors if none is set in the JVM.
  • tomcat_urandom (boolean) - If true, the JVM will be set to use /dev/urandom instead of /dev/random. This is often critical to performance on virtual machines.

    • Default: true
  • tomcat_user (string) - Name of the O/S user Tomcat runs under.

    • Default: tomcat
  • tomcat_user_shell (string) - Default shell for tomcat_user

    • Default: /sbin/nologin
  • tomcat_users (list of Tomcat User Objects) - Users to add to conf/tomcat-users.xml.

  • tomcat_x_forwarded_enable (boolean) - Enable support for X-Forwarded-For headers.

    • Default: true

JAR Download Objects

  • checksum (string) - Required - Checksum of the downloaded file. This value is required for security.
    • Note: It is recommended to use the SHA1 hash for compatibility.
    • Example: checksum: "sha1:1ec446f2bfab6f87f4e4ab1c738469c982bc5961"
  • url (string) - Required - URL to download
  • filename (string) - Name of the file to be stored in lib
    • Default: The filename in the URL

Extra Attribute Objects

  • attribute (string) - Required - Attribute to set
  • value (string) - Required - Value to set

JNDI Resource Link Objects

  • global_name (string) - Required - Global JNDI name for the resource link.
  • name (string) - Required - Name of the resource

Example:

      tomcat_resource_links:
        - name: jdbc/bannerDataSource
        - global_name: jdbc/bannerDataSource

JNDI Resource Objects

  • name (string) - Required - Name of the resource.
  • attrs (string:string dict) - Attributes for the resource.

Example:

      tomcat_resources:
        - name: jdbc/bannerDataSource
          attrs:
            auth: Container
            type: javax.sql.DataSource
            url: "{{ banner_jdbc_url }}"
            username: banproxy
            password: "{{ banproxy_pw }}"
            driverClassName: oracle.jdbc.OracleDriver
            initialSize: 25
            maxIdle: 10
            maxTotal: 400
            maxWaitMillis: 30000
            minIdle: 10
            timeBetweenEvictionRunsMillis: 1800000
            testOnBorrow: true
            testWhileIdle: true
            accessToUnderlyingConnectionAllowed: true
            validationQuery: select * from dual

Tomcat User Objects

  • name (string) - Required - User's login name
  • password (string) - User's password
  • roles (string) - Comma-separated list of user's roles
  • append (boolean) - When true the specified roles will be appended to the user's existing role list rather than replacing it.
    • Default: false

Dependencies

This role has no required dependencies. It will, however, create "about" info if the sig-ansible.about role is enabled.

Example Playbook

  - role: sig-ansible.tomcat
    vars:
      stage_dir: /tmp
      tomcat_self_signed: yes
      tomcat_base: /u01/app
      tomcat_memory_args: "-Xms2048m -Xmx6g -XX:MaxPermSize=2048m -Doracle.jdbc.autoCommitSpecCompliant=false"
      tomcat_catalina_extra_opts: "-Dbanner.logging.dir=/u01/app/logs"
      tomcat_download_jars:
        - url: https://repo1.maven.org/maven2/com/oracle/database/jdbc/ojdbc8/19.3.0.0/ojdbc8-19.3.0.0.jar
          checksum: 'sha256:a66d27a14f3adee484427cc4de008af85a5c3e78e2e3285a4dba1277332978a5'
          filename: ojdbc8.jar
        - url: https://repo1.maven.org/maven2/com/oracle/database/xml/xdb/19.3.0.0/xdb-19.3.0.0.jar
          checksum: 'sha256:a3f0545da9651359f05e6538886679f546632f63d409bb7247a0e2c8ae07d078'
          filename: xdb.jar
        - url: https://repo1.maven.org/maven2/com/oracle/database/jdbc/ucp/19.3.0.0/ucp-19.3.0.0.jar
          checksum: 'sha256:23d8debe40a764df74d5eda7e8c1ce9b2c190a34f739ca4d751eaa94114d31cc'

      tomcat_resources:
        - name: jdbc/bannerDataSource
          attrs:
            auth: Container
            type: javax.sql.DataSource
            url: "{{ banner_jdbc_url }}"
            username: banproxy
            password: "{{ banproxy_pw }}"
            driverClassName: oracle.jdbc.OracleDriver
            initialSize: 25
            maxIdle: 10
            maxTotal: 400
            maxWaitMillis: 30000
            minIdle: 10
            timeBetweenEvictionRunsMillis: 1800000
            testOnBorrow: true
            testWhileIdle: true
            accessToUnderlyingConnectionAllowed: true
            validationQuery: select * from dual
            validationQueryTimeout: 300

        - name: jdbc/bannerSsbDataSource
          attrs:
            auth: Container
            type: javax.sql.DataSource
            url: "{{ banner_jdbc_url }}"
            username: ban_ss_user
            password: "{{ ban_ss_user_pw }}"
            driverClassName: oracle.jdbc.OracleDriver
            initialSize: 25
            maxIdle: 10
            maxTotal: 400
            maxWaitMillis: 30000
            minIdle: 10
            timeBetweenEvictionRunsMillis: 1800000
            testOnBorrow: true
            testWhileIdle: true
            accessToUnderlyingConnectionAllowed: true
            validationQuery: select * from dual
            validationQueryTimeout: 300

      tomcat_resource_links:
        - name: jdbc/bannerDataSource
          global_name: jdbc/bannerDataSource
        - name: jdbc/bannerSsbDataSource
          global_name: jdbc/bannerSsbDataSource

License

Copyright 2021 Strata Information Group

Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:

  1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.

  2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.

  3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

Author Information

tomcat's People

Contributors

dboitnot avatar ibecker11 avatar

Stargazers

 avatar  avatar

Watchers

James Cloos avatar  avatar

tomcat's Issues

Need alternate way to determine timezone

The timedatectl utility doesn't exist in the Docker tomcat image and appears to only be installed with systemd which seems to carry a lot of overhead. A possible low cost option would be to use the /usr/share/zoneinfo to relink the localtime. It would look something like this:

ln -sf /usr/share/zoneinfo/US/Central /etc/localtime
or
ln -sf /usr/share/zoneinfo/America/Chicago /etc/localtime

CATALINA_PID is failing to be created due to permissions issue on CATALINA_HOME directory

The current usage of the setting the CATALINA_PID variable is done via the tomcat/templates/setenv.sh:

CATALINA_PID="${CATALINA_HOME}/pid"; export CATALINA_PID

However during a recent deployment using release v0.11.4, I received the following error message during startup:

Using CATALINA_PID:    /u01/app/esmadmin-9.0.84/pid
/u01/app/esmadmin/bin/catalina.sh: line 516: /u01/app/esmadmin-9.0.84/pid: Permission denied

Since the PID never gets created, executing the shutdown down produces this error:

./shutdown.sh && tail -f ../logs/catalina.out
Using CATALINA_BASE:   /u01/app/esmadmin
Using CATALINA_HOME:   /u01/app/esmadmin-9.0.84
Using CATALINA_TMPDIR: /u01/app/esmadmin/temp
Using JRE_HOME:        /etc/alternatives/java_sdk_11
Using CLASSPATH:       /u01/app/esmadmin-9.0.84/bin/bootstrap.jar:/u01/app/esmadmin/bin/tomcat-juli.jar
Using CATALINA_OPTS:   -Djava.awt.headless=true -Djava.security.egd=file:/dev/../dev/urandom -Dfile.encoding=UTF-8 -server -Xms2560m -Xmx2560m -XX:NewSize=512m -XX:MaxNewSize=512m -XX:+DisableExplicitGC
Using CATALINA_PID:    /u01/app/esmadmin-9.0.84/pid
$CATALINA_PID was set but the specified file does not exist. Is Tomcat running? Stop aborted.

This requires a kill command on the tomcat process.

Since files cannot be created on the CATALINA_HOME directory, there needs to be a provision for changing the value of the CATALINA_PID variable. Based on what I'm seeing in the template file, the variable seems to be hardcoded to be a certain value. This is fine if the tomcat instance is being run as root inside a container, however, in the case of ESM where it's run on an VM as the tomcat or esmadmin user, it's an issue.

Changing the location to the logs directory was more successful

CATALINA_PID="${CATALINA_HOME}/logs/pid"; export CATALINA_PID
./startup.sh && tail -f ../logs/catalina.out
Using CATALINA_BASE:   /u01/app/esmadmin
Using CATALINA_HOME:   /u01/app/esmadmin-9.0.84
Using CATALINA_TMPDIR: /u01/app/esmadmin/temp
Using JRE_HOME:        /etc/alternatives/java_sdk_11
Using CLASSPATH:       /u01/app/esmadmin-9.0.84/bin/bootstrap.jar:/u01/app/esmadmin/bin/tomcat-juli.jar
Using CATALINA_OPTS:   -Djava.awt.headless=true -Djava.security.egd=file:/dev/../dev/urandom -Dfile.encoding=UTF-8 -server -Xms2560m -Xmx2560m -XX:NewSize=512m -XX:MaxNewSize=512m -XX:+DisableExplicitGC
Using CATALINA_PID:    /u01/app/esmadmin-9.0.84/logs/pid
Tomcat started.

./shutdown.sh && tail -f ../logs/catalina.out
Using CATALINA_BASE:   /u01/app/esmadmin
Using CATALINA_HOME:   /u01/app/esmadmin-9.0.84
Using CATALINA_TMPDIR: /u01/app/esmadmin/temp
Using JRE_HOME:        /etc/alternatives/java_sdk_11
Using CLASSPATH:       /u01/app/esmadmin-9.0.84/bin/bootstrap.jar:/u01/app/esmadmin/bin/tomcat-juli.jar
Using CATALINA_OPTS:   -Djava.awt.headless=true -Djava.security.egd=file:/dev/../dev/urandom -Dfile.encoding=UTF-8 -server -Xms2560m -Xmx2560m -XX:NewSize=512m -XX:MaxNewSize=512m -XX:+DisableExplicitGC
Using CATALINA_PID:    /u01/app/esmadmin-9.0.84/logs/pid
NOTE: Picked up JDK_JAVA_OPTIONS:....

ParallelGC no longer provides best performance

Remove -XX:+UseParallelGC from this line in defaults/main.yml:

tomcat_catalina_opts: "{{ tomcat_memory_args }} {{ '-Djava.security.egd=file:/dev/../dev/urandom' if tomcat_urandom else '' }} -server -XX:+UseParallelGC {{ tomcat_catalina_extra_opts | default('') }}"

Received warning during password update for tomcat_users.xml file

Receiving a warning when updating a password via the tomcat_users_xml.yml:

TASK [sig-ansible.tomcat : Add Tomcat users] ***********************************
changed: [localhost] => (item={'name': 'cashconnector', 'password': '', 'roles': 'cashnetinterface', 'append': True})
[WARNING]: Module did not set no_log for update_password
[WARNING]: Module did not set no_log for obfuscate_password

Possible update would be to add the no_log option to the tomcat_user creation:

- name: Add Tomcat users
  tomcat_user:
    catalina_home: "{{ tomcat_root }}"
    name: "{{ item.name }}"
    password: "{{ item.password }}"
    roles: "{{ item.roles }}"
    append: "{{ item.append }}"
  no_log: true
  with_items: "{{ tomcat_users }}"
  tags: tomcat_conf

Add "always" tag to detect_timezone

Running with the tomcat_conf tag might fail if a timezone isn't provided because detect_timezone doesn't run. Add the always tag to it's include_tasks and to the the tasks in detect_timezone.yml.

Ability to stage Tomcat Zip

Currently the role does not offer an option to use a staged zip. This may be necessary at sites without outbound internet.

Add ability to specify docBase to server.xml

While containerizing the BannerAdmin pages, the ability to display images was lost due to the missing docBase statement in the server.xml similar to this:

<Context docBase="/mnt/ban_appdata_test/photos" path="/banneridimages" reloadable="true" allowLinking="true" />

Provide the option to add this if needed, unless there is a better way to do this.

Python3 incompatibility

Data source setup fails on Python3

An exception occurred during task execution. To see the full traceback, use -vvv. The error was: TypeError: a bytes-like object is required, not 'str'
failed: [localhost] (item={'name': 'jdbc/bannerDataSource', 'attrs': {'auth': 'Container', 'type': 'javax.sql.DataSource', 'url': 'jdbc:oracle:thin:@db.school.edu:1521:PROD', 'username': 'banproxy', 'password': 'super_secret', 'driverClassName': 'oracle.jdbc.OracleDriver', 'initialSize': 25, 'maxIdle': 10, 'maxTotal': 400, 'maxWaitMillis': 30000, 'minIdle': 10, 'timeBetweenEvictionRunsMillis': 1800000, 'testOnBorrow': True, 'testWhileIdle': True, 'accessToUnderlyingConnectionAllowed': True, 'validationQuery': 'select * from dual', 'validationQueryTimeout': 300}}) => changed=false
  ansible_loop_var: item
  item:
    attrs:
      accessToUnderlyingConnectionAllowed: true
      auth: Container
      driverClassName: oracle.jdbc.OracleDriver
      initialSize: 25
      maxIdle: 10
      maxTotal: 400
      maxWaitMillis: 30000
      minIdle: 10
      password: super_secret
      testOnBorrow: true
      testWhileIdle: true
      timeBetweenEvictionRunsMillis: 1800000
      type: javax.sql.DataSource
      url: jdbc:oracle:thin:@db.school.edu:1521:PROD
      username: banproxy
      validationQuery: select * from dual
      validationQueryTimeout: 300
    name: jdbc/bannerDataSource
  module_stderr: |-
    Traceback (most recent call last):
      File "~banproxy/.ansible/tmp/ansible-tmp-1624454424.6911378-275-268111921290993/AnsiballZ_tomcat_resource.py", line 102, in <module>
        _ansiballz_main()
      File "~banproxy/.ansible/tmp/ansible-tmp-1624454424.6911378-275-268111921290993/AnsiballZ_tomcat_resource.py", line 94, in _ansiballz_main
        invoke_module(zipped_mod, temp_path, ANSIBALLZ_PARAMS)
      File "~banproxy/.ansible/tmp/ansible-tmp-1624454424.6911378-275-268111921290993/AnsiballZ_tomcat_resource.py", line 40, in invoke_module
        runpy.run_module(mod_name='ansible.modules.tomcat_resource', init_globals=None, run_name='__main__', alter_sys=True)
      File "/usr/lib/python3.7/runpy.py", line 205, in run_module
        return _run_module_code(code, init_globals, run_name, mod_spec)
      File "/usr/lib/python3.7/runpy.py", line 96, in _run_module_code
        mod_name, mod_spec, pkg_name, script_name)
      File "/usr/lib/python3.7/runpy.py", line 85, in _run_code
        exec(code, run_globals)
      File "/tmp/ansible_tomcat_resource_payload_dz78szld/ansible_tomcat_resource_payload.zip/ansible/modules/tomcat_resource.py", line 131, in <module>
      File "/tmp/ansible_tomcat_resource_payload_dz78szld/ansible_tomcat_resource_payload.zip/ansible/modules/tomcat_resource.py", line 76, in go
      File "/usr/lib/python3.7/xml/dom/minidom.py", line 853, in writexml
        writer.write(indent+"<" + self.tagName)
    TypeError: a bytes-like object is required, not 'str'
  module_stdout: ''
  msg: |-
    MODULE FAILURE
    See stdout/stderr for the exact error
  rc: 1

Remove shebang from library scripts

The library scripts include a shebang for "python" which is sometimes not available (where python3 is). It turns out removing those lines avoids the error.

Automated Tomcat release tracking

When Tomcat makes a new official release, it should be immediately available in this role. Create a job to:

  • Push updated versions of this role to Galaxy; or
  • Provide a public file repository where version details can be downloaded from the role.

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.